feat(http): implement to_mcp 4-tool gateway projection (rmcp ServerHandler, StreamableHttpService at /mcp)
to_mcp is the MCP-direction gateway projection (ADR-041): exposes 4 fixed gateway tools (search, schema, call, batch) over rmcp StreamableHttpService nested into the axum Router at /mcp, not one MCP tool per registry operation. The LLM discovers operations on demand via search+schema. - ToMcpGateway implements rmcp ServerHandler (call_tool, list_tools, get_info) - tools/list returns the 4 fixed gateway tools, never the registry's ops - search dispatches services/list via GatewayDispatch::invoke, excludes Subscription ops (ADR-041 §2), returns names + descriptions - schema dispatches services/schema, returns the full OperationSpec - call dispatches via GatewayDispatch::invoke (shared spine), maps ResponseEnvelope -> CallToolResult::structured (Ok) / CallToolResult::structured_error (Err(CallError)) - batch loops over invoke, returns an array of results - Bearer auth via shared bearer_auth_middleware applied around nest_service (rmcp simple_auth_streamhttp pattern); Identity read from RequestContext.extensions -> http::request::Parts.extensions (research §6 #2 identity-survives-framing assumption, confirmed via test) - to_mcp is a pure projection (consumes registry, produces no entries) - Feature-gated behind mcp; stdio NOT built (ADR-037) - /mcp route wired in adapter.rs replacing the placeholder 501 cargo test -p alknet-http --features mcp: 172 passed cargo clippy -p alknet-http --features mcp --all-targets: clean cargo check -p alknet-http (no mcp): clean
This commit is contained in:
@@ -13,7 +13,13 @@ pub mod from_openapi;
|
||||
#[cfg(feature = "mcp")]
|
||||
pub mod from_mcp;
|
||||
|
||||
#[cfg(feature = "mcp")]
|
||||
pub mod to_mcp;
|
||||
|
||||
pub use from_openapi::{FromOpenAPI, HttpAuthScheme, HttpServiceConfig, OpenAPISpec};
|
||||
|
||||
#[cfg(feature = "mcp")]
|
||||
pub use from_mcp::FromMCP;
|
||||
|
||||
#[cfg(feature = "mcp")]
|
||||
pub use to_mcp::{ToMcpGateway, ToMcpService, to_mcp_service};
|
||||
|
||||
Reference in New Issue
Block a user