From 9173685ec2b99bd6bd3f32cdb2c79ddca740ac4c Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Thu, 20 Mar 2025 21:40:47 -0700 Subject: [PATCH] docs mcp tool spec --- docs/my-website/docs/mcp.md | 81 ++++++++++++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/docs/my-website/docs/mcp.md b/docs/my-website/docs/mcp.md index 176ccb504a..4bdca6cf47 100644 --- a/docs/my-website/docs/mcp.md +++ b/docs/my-website/docs/mcp.md @@ -1,3 +1,7 @@ +import Image from '@theme/IdealImage'; +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + # /mcp Model Context Protocol [BETA] ## Overview @@ -50,7 +54,38 @@ mcp_tools: handler: "mcp_tools.get_current_time" ``` -### 2. Start LiteLLM Proxy Server + +### 3. Start LiteLLM Gateway + + + + +Mount your `custom_logger.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)/custom_logger.py:/app/custom_logger.py \ + my-app:latest \ + --config /app/config.yaml \ + --port 4000 \ + --detailed_debug \ +``` + + + + + +```shell +litellm --config config.yaml --detailed_debug +``` + + + + ### 3. Make an LLM API request @@ -99,4 +134,48 @@ if __name__ == "__main__": ``` +## Specification for `mcp_tools` +The `mcp_tools` section in your LiteLLM config defines tools that can be called by MCP-compatible clients. + +### Tool Definition Format + +```yaml +mcp_tools: + - name: string # Required: Name of the tool + description: string # Required: Description of what the tool does + input_schema: object # Required: JSON Schema defining the tool's input parameters + handler: string # Required: Path to the function that implements the tool +``` + +### Field Details + +- `name`: A unique identifier for the tool +- `description`: A clear description of what the tool does, used by LLMs to determine when to call it +- `input_schema`: JSON Schema object defining the expected input parameters +- `handler`: String path to the Python function that implements the tool (e.g., "module.submodule.function_name") + +### Example Tool Definition + +```yaml +mcp_tools: + - name: "get_current_time" + description: "Get the current time in a specified format" + input_schema: { + "type": "object", + "properties": { + "format": { + "type": "string", + "description": "The format of the time to return", + "enum": ["short", "long", "iso"] + }, + "timezone": { + "type": "string", + "description": "The timezone to use (e.g., 'UTC', 'America/New_York')", + "default": "UTC" + } + }, + "required": ["format"] + } + handler: "mcp_tools.get_current_time" +```