Repository navigation
feat(mcp,a2a): opt-in tool exposure with hard floor + tier filter + no-builtins #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
de305ed
feat(mcp,a2a): opt-in tool exposure with hard floor + tier filter + n…
rohitg00 ad9aa10
fix(mcp,a2a): close cross-protocol infra leak, distinct a2a hard-floo…
rohitg00 f6d3801
fix(mcp): advertise real MCP protocol version
rohitg00 e359bb3
fix(mcp,a2a): CodeRabbit review — hard-floor coverage, fail-closed po…
rohitg00 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| # iii-a2a | ||
|
|
||
| A2A (Agent-to-Agent) JSON-RPC surface for the iii engine. Registers two | ||
| HTTP triggers on the engine: | ||
|
|
||
| - `GET /.well-known/agent-card.json` — discovery / capability card | ||
| - `POST /a2a` — JSON-RPC dispatch (`message/send`, `tasks/get`, | ||
| `tasks/cancel`, `tasks/list`) | ||
|
|
||
| ## Exposure model | ||
|
|
||
| Functions are **invisible to remote agents by default**. Authors opt in | ||
| per-function. Mirrors the iii-mcp design — same metadata keys, same hard | ||
| floor, same optional tier filter. | ||
|
|
||
| ### Opt-in metadata | ||
|
|
||
| ```rust | ||
| // Rust worker | ||
| iii.register_function_with( | ||
| RegisterFunctionMessage { | ||
| id: "pricing::quote".into(), | ||
| description: Some("Quote a price for SKU + quantity".into()), | ||
| metadata: Some(json!({ | ||
| "a2a.expose": true, | ||
| "a2a.tier": "partner", // optional — free-form string | ||
| })), | ||
| ..Default::default() | ||
| }, | ||
| handler, | ||
| ); | ||
| ``` | ||
|
|
||
| ```ts | ||
| // Node worker | ||
| iii.registerFunction("pricing::quote", handler, { | ||
| metadata: { "a2a.expose": true, "a2a.tier": "partner" }, | ||
| }) | ||
| ``` | ||
|
|
||
| ```python | ||
| # Python worker | ||
| iii.register_function( | ||
| "pricing::quote", | ||
| handler, | ||
| metadata={"a2a.expose": True, "a2a.tier": "partner"}, | ||
| ) | ||
| ``` | ||
|
|
||
| ### Hard floor (never exposed) | ||
|
|
||
| Even with `--expose-all`, these namespaces never appear as agent-card | ||
| skills and cannot be invoked via `message/send`: | ||
|
|
||
| | Prefix | Why | | ||
| |---|---| | ||
| | `engine::*` | iii engine internals | | ||
| | `state::*` | KV plumbing | | ||
| | `stream::*` | channel plumbing | | ||
| | `iii.*` | SDK callbacks | | ||
| | `a2a::*` | this worker's own JSON-RPC entry | | ||
|
|
||
| ### CLI flags | ||
|
|
||
| ``` | ||
| --engine-url <URL> WebSocket URL of the iii engine (default ws://localhost:49134) | ||
| --expose-all Ignore the a2a.expose gate (dev only). Hard floor still applies. | ||
| --tier <name> Show only functions whose a2a.tier metadata equals <name>. | ||
| E.g. `--tier partner` for B2B surfaces, `--tier public` for open. | ||
| --base-url <URL> Public origin advertised in the agent card. The card is served | ||
| at <base-url>/a2a. Default: http://localhost:3111 | ||
| --debug Verbose logging | ||
| ``` | ||
|
|
||
| ## Function resolution inside `message/send` | ||
|
|
||
| 1. **Data part** with `{ "function_id": "foo::bar", "payload": {...} }` — | ||
| direct invocation. | ||
| 2. **Text part** beginning with `foo::bar <json>` — first token is the | ||
| function id; rest is parsed as the payload. | ||
| 3. Anything else — task fails with "No function_id found". | ||
|
|
||
| Before dispatch, the resolved `function_id` is re-checked against the | ||
| same exposure gate as `tools/list`. Hard-floor namespaces reject | ||
| unconditionally. | ||
|
|
||
| ## Task model | ||
|
|
||
| Tasks are persisted in engine state (`a2a:tasks` scope). Terminal states | ||
| (`Completed`, `Canceled`, `Failed`, `Rejected`) are idempotent — repeated | ||
| `message/send` on the same `task_id` returns the stored result rather | ||
| than re-invoking the function. Mid-flight cancel is honoured: if a | ||
| `tasks/cancel` lands while a function call is in progress, the result is | ||
| discarded and the task keeps its `Canceled` state. | ||
|
|
||
| ## Not implemented | ||
|
|
||
| - `message/stream`, `tasks/resubscribe` (streaming) | ||
| - Push notifications | ||
|
|
||
| Returns JSON-RPC errors `-32004` and `-32003` respectively. | ||
|
|
||
| ## Example: multi-tier partner API | ||
|
|
||
| One worker, three audiences. | ||
|
|
||
| ```rust | ||
| iii.register_function_with( | ||
| RegisterFunctionMessage { | ||
| id: "pricing::public_quote".into(), | ||
| metadata: Some(json!({ "a2a.expose": true, "a2a.tier": "public" })), | ||
| ..Default::default() | ||
| }, | ||
| public_quote_handler, | ||
| ); | ||
|
|
||
| iii.register_function_with( | ||
| RegisterFunctionMessage { | ||
| id: "pricing::partner_quote".into(), | ||
| metadata: Some(json!({ "a2a.expose": true, "a2a.tier": "partner" })), | ||
| ..Default::default() | ||
| }, | ||
| partner_quote_handler, | ||
| ); | ||
|
|
||
| iii.register_function_with( | ||
| RegisterFunctionMessage { | ||
| id: "pricing::internal_cost".into(), | ||
| metadata: Some(json!({ "a2a.expose": true, "a2a.tier": "ops" })), | ||
| ..Default::default() | ||
| }, | ||
| internal_cost_handler, | ||
| ); | ||
| ``` | ||
|
|
||
| Three a2a workers behind three different auth proxies, each with a | ||
| different `--tier`, advertise three different agent cards. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.