litellm-admin-mcp
Exposes LiteLLM Proxy admin APIs as MCP tools for managing internal users, virtual keys, and spend logs via streamable-http, enabling agents to administer LiteLLM without custom HTTP glue.
README
litellm-admin-mcp
LiteLLM Admin MCP server for OpenClaw. Exposes LiteLLM Proxy admin APIs (internal users, virtual keys, spend logs) as MCP tools over streamable-http, so agents can manage LiteLLM without custom HTTP glue.
将 LiteLLM Proxy 的管理能力封装为 MCP Server,供 OpenClaw Agent 通过
streamable-http调用。
Overview
| Item | Detail |
|---|---|
| Transport | MCP Streamable HTTP at /mcp |
| Backend | LiteLLM Proxy REST API (LITELLM_BASE_URL) |
| Auth | Authorization: Bearer sk-* pass-through per request (not env var) |
| Tools | 11 admin tools (litellm_user_*, litellm_key_*, litellm_usage_*) |
| Health | GET /health → {"status":"ok"} |
OpenClaw Agent ──streamable-http + Bearer sk-*──► litellm-admin-mcp :3100/mcp
│
▼ Authorization pass-through
LiteLLM Proxy
Prerequisites
- Node.js 20+ (
engines.nodeinpackage.json) - A running LiteLLM Proxy with a valid admin key (
sk-*) - For OpenClaw integration: OpenClaw CLI with MCP support
Install & Run
# Install dependencies
npm install
# Development (hot reload)
npm run dev
# Production build
npm run build
npm start
Default listen address: http://0.0.0.0:3100
- Health:
http://localhost:3100/health - MCP:
http://localhost:3100/mcp
Docker Deployment
Quick start (docker compose)
docker compose up -d --build
docker compose logs -f litellm-admin-mcp
curl -s http://localhost:3100/health
Optional .env beside docker-compose.yml:
LITELLM_BASE_URL=http://192.168.91.200:8888
PORT=3100
Network note: The container must reach LiteLLM at
LITELLM_BASE_URL. From inside Docker,127.0.0.1points to the container itself — use the host LAN IP orhost.docker.internal(Docker Desktop).
Build and run manually
docker build -t litellm-admin-mcp:latest .
docker run -d \
--name litellm-admin-mcp \
-p 3100:3100 \
-e LITELLM_BASE_URL=http://192.168.91.200:8888 \
--restart unless-stopped \
litellm-admin-mcp:latest
Stop: docker compose down or docker stop litellm-admin-mcp && docker rm litellm-admin-mcp
Environment Variables
Copy .env.example and adjust as needed:
cp .env.example .env
| Variable | Required | Default | Description |
|---|---|---|---|
LITELLM_BASE_URL |
No | http://192.168.91.200:8888 |
LiteLLM Proxy base URL (no trailing slash) |
PORT |
No | 3100 |
HTTP port for this MCP server |
HOST |
No | 0.0.0.0 |
Bind address |
Example:
export LITELLM_BASE_URL=http://your-litellm-host:8888
export PORT=3100
export HOST=0.0.0.0
npm run dev
Admin key is not an environment variable. Configure it in the MCP client (e.g. OpenClaw headers), not in this server's env.
Authentication
Every request to /mcp must include:
Authorization: Bearer sk-<your-litellm-admin-key>
Behavior:
- Missing or invalid header (must start with
Bearer sk-) → 401 from this server; LiteLLM is not called. - Valid header → forwarded unchanged to LiteLLM API calls made by tool handlers.
OpenClaw (or any MCP client) supplies the key per session. Rotate keys in the client config without redeploying this server.
OpenClaw Configuration
Add to your OpenClaw MCP config (e.g. ~/.openclaw/config.json or project-level MCP settings):
{
"mcp": {
"servers": {
"litellm-admin": {
"url": "http://192.168.91.200:3100/mcp",
"transport": "streamable-http",
"headers": {
"Authorization": "Bearer sk-your-admin-key"
}
}
}
}
}
Replace:
url— host/port wherelitellm-admin-mcpruns (path must be/mcp)Authorization— your LiteLLM admin key (sk-*)
If OpenClaw and this server run on the same machine, http://127.0.0.1:3100/mcp works. For remote hosts, use the reachable IP/hostname and ensure firewall access to PORT.
MCP Tools (11)
| Tool | Description |
|---|---|
litellm_user_list |
List LiteLLM internal users with optional filters and pagination |
litellm_user_create |
Create a new LiteLLM internal user |
litellm_user_update |
Update an existing LiteLLM internal user |
litellm_user_delete |
Delete one or more LiteLLM internal users |
litellm_user_info |
Get LiteLLM user details by user_id or user_email |
litellm_key_list |
List LiteLLM virtual keys with optional filters and pagination |
litellm_key_generate |
Generate a new LiteLLM virtual key |
litellm_key_update |
Update an existing LiteLLM virtual key |
litellm_key_delete |
Delete one or more LiteLLM virtual keys |
litellm_key_info |
Get LiteLLM virtual key details by key hash or alias |
litellm_usage_spend_logs |
Query LiteLLM spend logs with optional filters and pagination |
Tool responses use a unified envelope:
{ "success": true, "data": {} }
{ "success": false, "error": { "status": 400, "message": "...", "detail": {} } }
Verification
Health check (no auth)
curl -s http://localhost:3100/health
# {"status":"ok"}
OpenClaw MCP probe
With the server running and OpenClaw configured:
openclaw mcp doctor --probe
Confirm litellm-admin (or your server alias) reports a healthy streamable-http connection and lists the 11 tools.
Testing
# Unit tests (default, no live LiteLLM)
npm test
# Optional integration tests against a real LiteLLM instance
RUN_INTEGRATION=1 npm test
# With custom LiteLLM URL / admin key for integration
LITELLM_BASE_URL=http://your-host:8888 LITELLM_ADMIN_KEY=sk-your-key RUN_INTEGRATION=1 npm test
Integration tests are read-only (user/list, key/list). They are skipped unless RUN_INTEGRATION=1.
Security
Treat the LiteLLM admin key (sk-*) as a root credential.
- It can create/delete users and keys, change budgets, and read spend data.
- Store it only in trusted MCP client config (OpenClaw headers), secret managers, or CI secrets — never commit it to git.
- This server does not add a second auth layer; anyone who can reach
/mcpwith a valid admin key can perform admin actions on your LiteLLM Proxy. - Bind to
127.0.0.1or place the service behind a private network / reverse proxy with TLS if exposed beyond localhost. - Do not log full
sk-*values.key_generatemay return a new plaintext key once (LiteLLM behavior); handle that response carefully.
Project Layout
Dockerfile # Multi-stage production image
docker-compose.yml # One-command deployment
src/
server.ts # Hono app, /health, /mcp transport
litellm-client.ts # LiteLLM HTTP client with auth pass-through
tools/
users.ts # 5 user tools
keys.ts # 5 key tools
usage.ts # 1 usage tool
index.ts # MCP server registration
utils/response.ts # ok() / fail() helpers
tests/ # Vitest unit + optional integration tests
License
See repository license file if present.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。