feat(adapters): from_mcp + to_mcp behind the mcp feature (rmcp 1.8)
from_mcp (src/adapters/from_mcp/): - tools/list discovery over streamable HTTP; per-tool HandlerRegistration (Mutation, Once, FromMCP leaf, Internal; ADR-015/022) - structuredContent-preferred output, ContentBlock-union fallback, isError -> MCP_TOOL_ERROR with content blocks as details (ADR-023) - bearer token flows via capabilities key 'mcp' (ADR-014 no-env-vars) - 19 unit tests + tests/from_mcp_integration.rs (5 tests vs a real rmcp streamable-HTTP MCP server) to_mcp (src/adapters/to_mcp.rs): - 4 fixed gateway tools (search/schema/call/batch, ADR-041); Sub ops excluded from search and uncallable (MCP is request/response) - identity survives rmcp framing: bearer_auth_middleware stashes Option<Identity> in http::request::Parts extensions, call_tool reads it back from RequestContext extensions - StreamableHttpService nested at /mcp in HttpAdapter's router, bearer middleware around it (feature-gated) Streamable HTTP only (ADR-037): rmcp default-features off, no stdio. Default build compiles without rmcp (cargo tree: 0 hits). Verified: cargo test (182 lib default / 218 all-features) + 5 MCP integration + 10 WS, clippy -D warnings (both), fmt.
This commit is contained in:
+38
-8
@@ -1,7 +1,7 @@
|
||||
---
|
||||
id: adapter-mcp
|
||||
name: from_mcp + to_mcp (mcp feature)
|
||||
status: pending
|
||||
status: completed
|
||||
depends_on: [client-http-host, gateway-routes]
|
||||
scope: broad
|
||||
risk: medium
|
||||
@@ -24,11 +24,11 @@ middleware. Shared dispatch spine with to_openapi via GatewayDispatch.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- [ ] Both adapters behind `mcp`; default features compile without rmcp
|
||||
- [ ] from_mcp round-trip against a mock MCP server (tools/list, tools/call, structured + content-block outputs)
|
||||
- [ ] to_mcp: 4 tools listed; call dispatch filtered by ACL; Pub/Sub ops excluded
|
||||
- [ ] stdio transport not present anywhere (dependency audit)
|
||||
- [ ] `cargo test --all-features` passes
|
||||
- [x] Both adapters behind `mcp`; default features compile without rmcp
|
||||
- [x] from_mcp round-trip against a mock MCP server (tools/list, tools/call, structured + content-block outputs)
|
||||
- [x] to_mcp: 4 tools listed; call dispatch filtered by ACL; Pub/Sub ops excluded
|
||||
- [x] stdio transport not present anywhere (dependency audit)
|
||||
- [x] `cargo test --all-features` passes
|
||||
|
||||
## References
|
||||
|
||||
@@ -38,8 +38,38 @@ middleware. Shared dispatch spine with to_openapi via GatewayDispatch.
|
||||
|
||||
## Notes
|
||||
|
||||
> Agent fills during implementation.
|
||||
Port split internally as from_mcp/ (dir: mod.rs + tests.rs) + to_mcp.rs,
|
||||
mirroring the old crate layout. Streamable HTTP only (rmcp 1.8,
|
||||
default-features off; client + server + streamable-http transport
|
||||
features only — no stdio anywhere in the feature set).
|
||||
|
||||
## Summary
|
||||
|
||||
> Agent fills on completion.
|
||||
Ported both MCP adapters behind the `mcp` feature (rmcp 1.8):
|
||||
|
||||
- `src/adapters/from_mcp/` (mod.rs + tests.rs): tools/list discovery
|
||||
over StreamableHttpClientTransport; per-tool HandlerRegistration
|
||||
(Mutation, HandlerKind::Once, FromMCP leaf, Internal, ADR-015/022);
|
||||
structuredContent-preferred output, ContentBlock-union fallback
|
||||
schema (5 variants), isError -> MCP_TOOL_ERROR CallError with
|
||||
content blocks as details; bearer token via capabilities key "mcp"
|
||||
(ADR-014). 19 unit tests + 5 integration tests vs a real rmcp
|
||||
streamable-HTTP server (tests/from_mcp_integration.rs, gated on the
|
||||
mcp feature): tools round-trip incl. structured + legacy
|
||||
content-block outputs, no-env-vars, unreachable-server error
|
||||
classification.
|
||||
- `src/adapters/to_mcp.rs`: ToMcpGateway with exactly 4 gateway tools
|
||||
(search/schema/call/batch — ADR-041), Sub ops excluded from search
|
||||
listings (op_type wire strings "sub"/"subscription"/"Sub"), call
|
||||
dispatch through the shared GatewayDispatch spine with
|
||||
ACL-filtered FORBIDDEN/NOT_FOUND mapping, batch returns per-call
|
||||
result array. Identity survives rmcp framing: bearer_auth_middleware
|
||||
stashes Option<Identity> in http::request::Parts extensions;
|
||||
extract_identity reads it back from RequestContext extensions.
|
||||
StreamableHttpService nested at /mcp in build_router (feature-gated)
|
||||
with bearer middleware around it. 19 tests.
|
||||
- `GET|POST /mcp` reserved path unchanged; default build compiles
|
||||
without rmcp (cargo tree -e normal: 0 rmcp occurrences).
|
||||
|
||||
218 lib tests (default 182 / all-features 218) + 5 MCP integration +
|
||||
10 WS integration green. clippy -D warnings both feature sets, fmt.
|
||||
Reference in New Issue
Block a user