1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! MCP (Model Context Protocol) Gateway
//!
//! This module implements MCP support for litellm-rs, providing a unified gateway
//! for connecting MCP servers (tools) to any LLM provider.
//!
//! # Overview
//!
//! MCP (Model Context Protocol) is a standard for connecting external tools and
//! data sources to LLMs. This implementation supports:
//!
//! - Multiple transport protocols (HTTP, SSE, stdio)
//! - OAuth 2.0 and API key authentication
//! - Permission control by Key, Team, and Organization
//! - Dynamic tool discovery and registration
//! - Cost tracking for tool invocations
//!
//! # Usage
//!
//! ```rust,no_run
//! # use litellm_rs::core::mcp::{McpGateway, McpServerConfig, Transport, AuthConfig};
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Configure MCP servers
//! let config = McpServerConfig {
//! name: "github".to_string(),
//! url: "https://api.github.com/mcp".parse()?,
//! transport: Transport::Http,
//! auth: Some(AuthConfig::bearer("token123")),
//! ..Default::default()
//! };
//!
//! // Create gateway and register server
//! let gateway = McpGateway::new();
//! gateway.register_server(config).await?;
//!
//! // List available tools
//! let tools = gateway.list_tools("github").await?;
//!
//! // Call a tool
//! let params = serde_json::json!({});
//! let result = gateway.call_tool("github", "get_repo", params).await?;
//! # Ok(())
//! # }
//! ```
//!
//! # Configuration
//!
//! MCP servers can be configured via YAML:
//!
//! ```yaml
//! mcp_servers:
//! github:
//! url: "https://api.github.com/mcp"
//! transport: http
//! auth_type: bearer_token
//! auth_value: "${GITHUB_TOKEN}"
//!
//! local_tools:
//! url: "/path/to/mcp-server"
//! transport: stdio
//! ```
// Re-export commonly used types
pub use ;
pub use ;
pub use McpGateway;
pub use ;
pub use ;
pub use McpServer;
pub use ;
pub use Transport;