Skip to main content

Use Claude Code with MCPs

This tutorial shows how to connect MCP servers to Claude Code via LiteLLM Proxy.

Note: LiteLLM supports OAuth for MCP servers as well. Learn more

Connecting MCP Servers​

You can also connect MCP servers to Claude Code via LiteLLM Proxy.

  1. Add the MCP server to your config.yaml

In this example, we'll add the Github MCP server to our config.yaml

config.yaml
mcp_servers:
github_mcp:
url: "https://api.githubcopilot.com/mcp"
auth_type: oauth2
client_id: os.environ/GITHUB_OAUTH_CLIENT_ID
client_secret: os.environ/GITHUB_OAUTH_CLIENT_SECRET
  1. Start LiteLLM Proxy
litellm --config /path/to/config.yaml

# RUNNING on http://0.0.0.0:4000
  1. Use the MCP server in Claude Code
claude mcp add --transport http litellm_proxy http://0.0.0.0:4000/github_mcp/mcp --header "Authorization: Bearer sk-LITELLM_VIRTUAL_KEY"

For MCP servers that require dynamic client registration (such as Atlassian), please set x-litellm-api-key: Bearer sk-LITELLM_VIRTUAL_KEY instead of using Authorization: Bearer LITELLM_VIRTUAL_KEY.

  1. Authenticate via Claude Code

a. Start Claude Code

claude

b. Authenticate via Claude Code

/mcp

c. Select the MCP server

> litellm_proxy

d. Start Oauth flow via Claude Code

> 1. Authenticate
2. Reconnect
3. Disable

e. Once completed, you should see this success message:

OAuth 2.0 Success