Skip to main content

brainwires_mcp_server/
lib.rs

1#![deny(missing_docs)]
2//! # Brainwires MCP Server
3//!
4//! MCP server framework with middleware pipeline for the Brainwires Agent Framework.
5//!
6//! Provides everything needed to build an MCP-compliant tool server:
7//! - [`McpServer`] — async event loop that reads JSON-RPC, runs middleware, dispatches to handler
8//! - [`McpHandler`] — trait defining how your server responds to initialize/list_tools/call_tool
9//! - [`McpToolRegistry`] — stores tool definitions + handlers, dispatches tool calls
10//! - [`MiddlewareChain`] — ordered middleware pipeline (auth, logging, rate-limiting, tool filtering)
11//! - [`ServerTransport`] — pluggable transport (stdio included)
12
13/// WebSocket/HTTP connection types.
14pub mod connection;
15/// Error types for the MCP server.
16pub mod error;
17/// MCP request handler trait.
18pub mod handler;
19/// Stateless HTTP + SSE transport (MCP 2026 spec).
20#[cfg(feature = "http")]
21pub mod http_transport;
22/// MCP server transport (stdio).
23pub mod mcp_transport;
24/// Middleware pipeline (auth, logging, rate-limiting, tool filtering).
25pub mod middleware;
26/// MCP tool registry.
27pub mod registry;
28/// MCP server lifecycle.
29pub mod server;
30/// MCP Tasks primitive (SEP-1686).
31pub mod tasks;
32
33pub use connection::{ClientInfo, RequestContext};
34pub use error::AgentNetworkError;
35pub use handler::McpHandler;
36pub use mcp_transport::{ServerTransport, StdioServerTransport};
37pub use middleware::{Middleware, MiddlewareChain, MiddlewareResult};
38pub use registry::{McpToolDef, McpToolRegistry, ToolHandler};
39pub use server::McpServer;
40pub use tasks::{McpTask, McpTaskState, McpTaskStore};
41
42// Re-export HTTP transport types
43#[cfg(feature = "http")]
44pub use http_transport::{
45    HttpServerTransport, McpAuthInfo, McpServerCard, McpToolCardEntry, McpTransportInfo,
46    OAuthProtectedResource, build_server_card,
47};
48
49// Re-export middleware implementations
50pub use middleware::auth::AuthMiddleware;
51pub use middleware::logging::LoggingMiddleware;
52#[cfg(feature = "oauth")]
53pub use middleware::oauth::OAuthMiddleware;
54pub use middleware::rate_limit::RateLimitMiddleware;
55pub use middleware::tool_filter::ToolFilterMiddleware;