Content
# LiteLLM MCP Server
An MCP server for LiteLLM operations. At startup it reads the LiteLLM proxy
OpenAPI document and registers one FastMCP tool per LiteLLM endpoint.
## Features
- **Full LiteLLM API coverage**: Registers every operation in `GET /openapi.json`.
- **Version-aware tools**: Tool names come from LiteLLM `operationId` values, so
the exposed tools follow the running LiteLLM version.
- **Discovery helpers**: Includes tools to list/search registered LiteLLM tools
and inspect individual endpoint mappings.
- **Environment-based config**: Reads the LiteLLM URL and master key from env vars.
## Prerequisites
- Python 3.10+
- `uv` package manager recommended
- A reachable LiteLLM proxy
- A LiteLLM master key or admin key
## Installation
```bash
uv sync
```
## Configuration
The server reads LiteLLM connection settings from environment variables. It
fetches `${LITELLM_URL}/openapi.json` during startup.
- `LITELLM_URL`: LiteLLM proxy base URL, for example `http://localhost:4000`.
- `LITELLM_MASTER_KEY`: LiteLLM master key or admin key.
- `LITELLM_TIMEOUT_SECONDS`: Optional request timeout in seconds. Defaults to `30`.
## Usage
### Running the Server
```bash
export LITELLM_URL=http://localhost:4000
export LITELLM_MASTER_KEY=sk-...
uv run litellm-mcp
```
### Using Docker
```bash
docker build -t litellm-mcp .
docker run -i --rm \
-e LITELLM_URL=http://host.docker.internal:4000 \
-e LITELLM_MASTER_KEY=sk-... \
litellm-mcp
```
### Claude Desktop Configuration
```json
{
"mcpServers": {
"litellm": {
"command": "<uv PATH>",
"args": [
"--directory",
"<litellm-mcp PATH>",
"run",
"litellm-mcp"
],
"env": {
"LITELLM_URL": "http://localhost:4000",
"LITELLM_MASTER_KEY": "sk-..."
}
}
}
}
```
## Tool Names
Tool names are generated from LiteLLM OpenAPI `operationId` values.
Examples from LiteLLM v1.84.8:
| LiteLLM Endpoint | MCP Tool |
|------------------|----------|
| `GET /health/readiness` | `health_readiness_health_readiness_get` |
| `GET /key/list` | `list_keys_key_list_get` |
| `GET /key/info` | `info_key_fn_key_info_get` |
| `GET /spend/logs/v2` | `ui_view_spend_logs_spend_logs_v2_get` |
| `POST /chat/completions` | `chat_completion_chat_completions_post` |
Two helper tools are always registered:
- `list_litellm_openapi_tools`: Search/list dynamically registered endpoint tools.
- `get_litellm_openapi_tool`: Show the HTTP method, path, and parameter mapping
for one endpoint tool.
## Project Structure
```text
src/litellm_mcp/
├── configs/ # Environment configuration
├── connections/ # LiteLLM HTTP client singleton
├── tools/ # OpenAPI-driven FastMCP tool registration
└── main.py # Entry point and tool registration
```
## Security Notes
`LITELLM_MASTER_KEY` can read and mutate sensitive LiteLLM state. Because this
server exposes every LiteLLM endpoint in the running proxy, including mutating
admin endpoints, prefer running it locally or in a trusted network.