Expand description
§Model Context Protocol (MCP) Support
Implementation of the Model Context Protocol for cortex. MCP provides a standardized way to connect AI agents to external tools and data sources.
§Features
- STDIO Transport: Launch MCP servers as subprocesses
- SSE Transport: Connect to HTTP-based MCP servers
- Tool Integration: Automatic conversion between MCP tools and agent tools
§Example
ⓘ
use cortexai_mcp::{McpClient, StdioTransport};
// Connect to an MCP server via stdio
let transport = StdioTransport::spawn("npx", &["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]).await?;
let client = McpClient::new(transport).await?;
// List available tools
let tools = client.list_tools().await?;
// Call a tool
let result = client.call_tool("read_file", json!({"path": "/tmp/test.txt"})).await?;Re-exports§
pub use agent_handler::simple_agent;pub use agent_handler::AgentMcpConfig;pub use agent_handler::AgentMcpHandler;pub use agent_handler::AgentMcpHandlerBuilder;pub use agent_handler::AgentMcpInput;pub use agent_handler::AgentMcpOutput;pub use crew_handler::CrewMcpConfig;pub use crew_handler::CrewMcpHandler;pub use crew_handler::CrewMcpHandlerBuilder;pub use crew_handler::CrewMcpInput;pub use crew_handler::CrewMcpOutput;pub use crew_handler::TaskResult;pub use graph_handler::GraphMcpConfig;pub use graph_handler::GraphMcpHandler;pub use graph_handler::GraphMcpHandlerBuilder;pub use graph_handler::GraphMcpInput;pub use graph_handler::GraphMcpOutput;pub use graph_handler::NodeExecution;pub use bridge::McpToolBridge;pub use client::McpClient;pub use error::McpError;pub use server::AsyncFnTool;pub use server::FnTool;pub use server::McpServer;pub use server::McpServerBuilder;pub use server::PromptContent;pub use server::PromptHandler;pub use server::PromptMessage;pub use server::ResourceHandler;pub use server::ServerConfig;pub use server::ToolHandler;pub use session_resources::MemorySessionStoreAdapter;pub use session_resources::MemoryTraceStoreAdapter;pub use session_resources::SessionMetadata;pub use session_resources::SessionResourceHandler;pub use session_resources::SessionStoreRead;pub use session_resources::TraceMetadata;pub use session_resources::TraceResourceHandler;pub use session_resources::TraceStoreRead;pub use http_server::HttpServerConfig;pub use sse_server::SseServerConfig;pub use transport::McpTransport;pub use transport::SseTransport;pub use transport::StdioTransport;pub use protocol::*;
Modules§
- agent_
handler - Agent-as-MCP-Tool
- bridge
- Bridge between MCP tools and cortex Tool trait
- client
- MCP Client implementation
- crew_
handler - Crew-as-MCP-Tool
- error
- MCP Error types
- graph_
handler - Graph-as-MCP-Tool
- http_
server - HTTP Server Transport for MCP
- protocol
- MCP Protocol types based on the official specification
- server
- MCP Server implementation
- session_
resources - Session and Trajectory MCP Resources
- sse_
server - SSE Server Transport for MCP
- transport
- MCP Transport implementations