diff --git a/docs/my-website/docs/tutorials/claude_responses_api.md b/docs/my-website/docs/tutorials/claude_responses_api.md index d86b5e2d461..098c311b30f 100644 --- a/docs/my-website/docs/tutorials/claude_responses_api.md +++ b/docs/my-website/docs/tutorials/claude_responses_api.md @@ -209,4 +209,81 @@ claude --model claude-bedrock - \ No newline at end of file + + + +## Connecting MCP Servers + +You can also connect MCP servers to Claude Code via LiteLLM Proxy. + +:::note + +Limitations: + +- Currently, only HTTP MCP servers are supported +- Does not work in Cursor IDE yet. + +::: + +1. Add the MCP server to your `config.yaml` + +In this example, we'll add the Github MCP server to our `config.yaml` + +```yaml title="config.yaml" showLineNumbers +mcp_servers: + github_mcp: + url: "https://api.githubcopilot.com/mcp" + auth_type: oauth2 + authorization_url: https://github.com/login/oauth/authorize + token_url: https://github.com/login/oauth/access_token + client_id: os.environ/GITHUB_OAUTH_CLIENT_ID + client_secret: os.environ/GITHUB_OAUTH_CLIENT_SECRET + scopes: ["public_repo", "user:email"] +``` + +2. Start LiteLLM Proxy + +```bash +litellm --config /path/to/config.yaml + +# RUNNING on http://0.0.0.0:4000 +``` + +3. Use the MCP server in Claude Code + +```bash +claude mcp add --transport http litellm_proxy http://0.0.0.0:4000 --header "Authorization: Bearer sk-LITELLM_VIRTUAL_KEY" +``` + +4. Authenticate via Claude Code + +a. Start Claude Code + +```bash +claude +``` + +b. Authenticate via Claude Code + +```bash +/mcp +``` + +c. Select the MCP server + +```bash +> litellm_proxy +``` + +d. Start Oauth flow via Claude Code + +```bash +> 1. Authenticate + 2. Reconnect + 3. Disable +``` + +e. Once completed, you should see this success message: + + + diff --git a/docs/my-website/img/oauth_2_success.png b/docs/my-website/img/oauth_2_success.png new file mode 100644 index 00000000000..4011b55d35c Binary files /dev/null and b/docs/my-website/img/oauth_2_success.png differ diff --git a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py index 28581c778c6..da1f35a608a 100644 --- a/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py +++ b/litellm/proxy/_experimental/mcp_server/mcp_server_manager.py @@ -355,12 +355,12 @@ class MCPServerManager: ) # Update tool name to server name mapping (for both prefixed and base names) - self.tool_name_to_mcp_server_name_mapping[ - base_tool_name - ] = server_prefix - self.tool_name_to_mcp_server_name_mapping[ - prefixed_tool_name - ] = server_prefix + self.tool_name_to_mcp_server_name_mapping[base_tool_name] = ( + server_prefix + ) + self.tool_name_to_mcp_server_name_mapping[prefixed_tool_name] = ( + server_prefix + ) registered_count += 1 verbose_logger.debug( @@ -1276,7 +1276,7 @@ class MCPServerManager: get_prisma_client_or_throw, ) - verbose_logger.info("Loading MCP servers from database into registry...") + verbose_logger.debug("Loading MCP servers from database into registry...") # perform authz check to filter the mcp servers user has access to prisma_client = get_prisma_client_or_throw( @@ -1292,7 +1292,9 @@ class MCPServerManager: ) self.add_update_server(server) - verbose_logger.info(f"Registry now contains {len(self.get_registry())} servers") + verbose_logger.debug( + f"Registry now contains {len(self.get_registry())} servers" + ) def get_mcp_server_by_id(self, server_id: str) -> Optional[MCPServer]: """ diff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yaml index c0772f964ba..d2e68067acd 100644 --- a/litellm/proxy/_new_secret_config.yaml +++ b/litellm/proxy/_new_secret_config.yaml @@ -1,4 +1,14 @@ model_list: - - model_name: gpt-5-codex + - model_name: gpt-5-mini litellm_params: - model: gpt-5-codex \ No newline at end of file + model: gpt-5-mini + +mcp_servers: + github_mcp: + url: "https://api.githubcopilot.com/mcp" + auth_type: oauth2 + authorization_url: https://github.com/login/oauth/authorize + token_url: https://github.com/login/oauth/access_token + client_id: os.environ/GITHUB_OAUTH_CLIENT_ID + client_secret: os.environ/GITHUB_OAUTH_CLIENT_SECRET + scopes: ["public_repo", "user:email"] \ No newline at end of file