From db12adb3db5e0190b160c7fe4f2a37914e44fe60 Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 29 Mar 2025 20:42:14 -0700 Subject: [PATCH] docs mcp tools --- docs/my-website/docs/mcp.md | 62 ++++++++------------------------- litellm/proxy/proxy_config.yaml | 2 +- 2 files changed, 15 insertions(+), 49 deletions(-) diff --git a/docs/my-website/docs/mcp.md b/docs/my-website/docs/mcp.md index 744c23644e..291de46ec9 100644 --- a/docs/my-website/docs/mcp.md +++ b/docs/my-website/docs/mcp.md @@ -282,8 +282,8 @@ This allows you to define tools that can be called by any MCP compatible client. LiteLLM exposes the following MCP endpoints: -- `/mcp/list_tools` - List all available tools -- `/mcp/call_tool` - Call a specific tool with the provided arguments +- `/mcp/tools/list` - List all available tools +- `/mcp/tools/call` - Call a specific tool with the provided arguments When MCP clients connect to LiteLLM they can follow this workflow: @@ -297,9 +297,9 @@ When MCP clients connect to LiteLLM they can follow this workflow: #### Usage -#### 1. Define your tools on mcp_tools +#### 1. Define your tools on under `mcp_servers` in your config.yaml file. -LiteLLM allows you to define your tools on the `mcp_tools` section in your config.yaml file. All tools listed here will be available to MCP clients (when they connect to LiteLLM and call `list_tools`). +LiteLLM allows you to define your tools on the `mcp_servers` section in your config.yaml file. All tools listed here will be available to MCP clients (when they connect to LiteLLM and call `list_tools`). ```yaml model_list: @@ -308,64 +308,30 @@ model_list: model: openai/gpt-4o api_key: sk-xxxxxxx - - -mcp_tools: - - name: "get_current_time" - description: "Get the current time" - input_schema: { - "type": "object", - "properties": { - "format": { - "type": "string", - "description": "The format of the time to return", - "enum": ["short"] - } - } +mcp_servers: + { + "zapier_mcp": { + "url": "https://actions.zapier.com/mcp/sk-akxxxxx/sse", + }, + "fetch" { + "url": "http://localhost:8000/sse", } - handler: "mcp_tools.get_current_time" + } + ``` -#### 2. Define a handler for your tool -Create a new file called `mcp_tools.py` and add this code. The key method here is `get_current_time` which gets executed when the `get_current_time` tool is called. - -```python -# mcp_tools.py - -from datetime import datetime - -def get_current_time(format: str = "short"): - """ - Simple handler for the 'get_current_time' tool. - - Args: - format (str): The format of the time to return ('short'). - - Returns: - str: The current time formatted as 'HH:MM'. - """ - # Get the current time - current_time = datetime.now() - - # Format the time as 'HH:MM' - return current_time.strftime('%H:%M') -``` - -#### 3. Start LiteLLM Gateway +#### 2. Start LiteLLM Gateway -Mount your `mcp_tools.py` on the LiteLLM Docker container. - ```shell docker run -d \ -p 4000:4000 \ -e OPENAI_API_KEY=$OPENAI_API_KEY \ --name my-app \ -v $(pwd)/my_config.yaml:/app/config.yaml \ - -v $(pwd)/mcp_tools.py:/app/mcp_tools.py \ my-app:latest \ --config /app/config.yaml \ --port 4000 \ diff --git a/litellm/proxy/proxy_config.yaml b/litellm/proxy/proxy_config.yaml index 3956eab23f..22d61ab073 100644 --- a/litellm/proxy/proxy_config.yaml +++ b/litellm/proxy/proxy_config.yaml @@ -5,7 +5,7 @@ model_list: mcp_servers: { - "Zapier MCP": { + "Zapier_MCP": { "url": "os.environ/ZAPIER_MCP_SERVER_URL", "mcp_info": { "logo_url": "https://espysys.com/wp-content/uploads/2024/08/zapier-logo.webp",