mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-24 02:38:06 +02:00
feat(mcp): per-query @mcp(...) annotation + per-param @description + @instruction folding
Wire the `.gq` authoring surface that controls how a stored query is projected
as an MCP tool. All of it rides in the query source (content-addressed,
re-parsed at boot), so there is no cluster.yaml / catalog / serving-snapshot
plumbing — and it is orthogonal to Cedar `invoke_query` (presentation, not
authorization).
- Per-parameter `@description("…")` (leading the variable) → carried on
`Param.description`, mapped through `param_descriptor`, and emitted on the
outer JSON-Schema property by `param_json_schema`, so it shows up in both the
MCP tool input schema and the `GET /queries` catalog.
- Query `@mcp(expose: <bool>, tool_name: "<name>")` → parsed into
`QueryDecl.mcp`; `StoredQuery::is_exposed()` / `effective_tool_name()` resolve
from it. `expose: false` hides a query from the agent surface (`tools/list`,
`stored_query_list`, run-by-name) while keeping it HTTP/service-callable.
- `@instruction` is folded into the MCP tool description (after `@description`),
so the agent-facing how/when-to-use guidance reaches `tools/list`.
- Removes the now-dead `RegistrySpec.{expose, tool_name}` fields (server + CLI);
`settings.rs` no longer hardcodes `expose: true`. Test helpers express
exposure by injecting `@mcp(expose: false)` into the source (the real path).
openapi.json regenerated: `ParamDescriptor` gains an optional `description`.
Tests: compiler parser (param @description, @mcp parse + duplicate rejection),
api-types schema_equivalence (description on the outer property), server mcp
(folded description + param docs + @mcp tool rename, list==call). Full
workspace gate green.
This commit is contained in:
parent
bcd0d9c867
commit
c8e91c11f0
14 changed files with 396 additions and 107 deletions
|
|
@ -145,14 +145,24 @@ pub fn graph_path(root: &Path) -> PathBuf {
|
|||
}
|
||||
|
||||
pub fn stored_query_registry(specs: &[(&str, &str, bool)]) -> QueryRegistry {
|
||||
// MCP `expose` now lives in the `.gq` source `@mcp(...)` annotation. The
|
||||
// `(name, source, expose)` tuple stays for ergonomics: when `expose` is
|
||||
// false, inject `@mcp(expose: false)` between the param-list `)` and the
|
||||
// body `{` (the first `{` in a query source is always the body open), so
|
||||
// the real parse path is exercised.
|
||||
QueryRegistry::from_specs(
|
||||
specs
|
||||
.iter()
|
||||
.map(|(name, source, expose)| RegistrySpec {
|
||||
name: name.to_string(),
|
||||
source: source.to_string(),
|
||||
expose: *expose,
|
||||
tool_name: None,
|
||||
.map(|(name, source, expose)| {
|
||||
let source = if *expose {
|
||||
source.to_string()
|
||||
} else {
|
||||
match source.find('{') {
|
||||
Some(i) => format!("{}@mcp(expose: false) {}", &source[..i], &source[i..]),
|
||||
None => source.to_string(),
|
||||
}
|
||||
};
|
||||
RegistrySpec { name: name.to_string(), source }
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue