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
26 lines
800 B
Rust
26 lines
800 B
Rust
//! HTTP-backed call-protocol adapters: `from_openapi`, `to_openapi`,
|
|
//! `from_mcp`, `to_mcp`.
|
|
//!
|
|
//! `from_openapi`/`from_mcp` are the no-env-vars credential injection point
|
|
//! (ADR-014); `to_openapi`/`to_mcp` are projections of the local registry
|
|
//! (ADR-017). `from_mcp`/`to_mcp` are feature-gated behind `mcp`
|
|
//! (streamable HTTP only — ADR-037). See
|
|
//! `docs/architecture/crates/http/http-adapters.md` and
|
|
//! `docs/architecture/crates/http/http-mcp.md`.
|
|
|
|
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};
|