litellm-websearch-mcp
v1.2.1MCP server for web search through a LiteLLM search tool with the caller's own key
A local stdio MCP server for web search through a LiteLLM search tool. Every query is sent with the caller's own LiteLLM key to POST /search/, so usage, budgets and costs are attributed to that key and its user. The server runs locally on purpose: since LiteLLM v1.108 the gateway no longer forwards the caller's x-litellm-api-key to upstream MCP servers, so a central MCP behind the LiteLLM MCP gateway cannot search on the caller's behalf. Den folgenden Eintrag in die globale ~/.config/opencode/opencode.json oder die projektbezogene opencode.json aufnehmen.
Summary extracted from the README.
LiteLLM Websearch MCP
A local stdio MCP server for web search through a LiteLLM search tool. Every query is sent with the caller's own LiteLLM key to POST <LITELLM_BASE_URL>/search/<LITELLM_SEARCH_TOOL>, so usage, budgets and costs are attributed to that key and its user.
The server runs locally on purpose: since LiteLLM v1.108 the gateway no longer forwards the caller's x-litellm-api-key to upstream MCP servers, so a central MCP behind the LiteLLM MCP gateway cannot search on the caller's behalf.
Requirements
- Node.js 22 or newer
- A LiteLLM proxy with a configured search tool
- A LiteLLM key that may use that search tool
OpenCode konfigurieren
Den folgenden Eintrag in die globale ~/.config/opencode/opencode.json oder die projektbezogene opencode.json aufnehmen. Ein vorhandener remote-Eintrag websearch wird damit ersetzt:
{
"mcp": {
"websearch": {
"type": "local",
"command": [
"npx",
"-y",
"--package=@viadee/litellm-websearch-mcp",
"litellm-websearch-mcp"
],
"enabled": true,
"timeout": 35000,
"environment": {
"LITELLM_API_KEY": "{env:OPENCODE_LITELLM_API_KEY}",
"LITELLM_BASE_URL": "https://your-litellm.example"
}
}
}
}
OpenCode danach vollständig neu starten. Das Tool search akzeptiert query und optional max_results (1 bis 20, Standard 10).
Configuration
| Variable | Required | Default | Description |
|---|---|---|---|
LITELLM_API_KEY |
yes | LiteLLM key used for and billed with every search | |
LITELLM_BASE_URL |
yes | LiteLLM base URL, with or without /v1; HTTPS except for localhost |
|
LITELLM_SEARCH_TOOL |
no | default-search |
Name of the LiteLLM search tool |
WEBSEARCH_MAX_RESPONSE_BYTES |
no | 2097152 |
Maximum search response size before parsing |
WEBSEARCH_REQUEST_TIMEOUT_MS |
no | 30000 |
Upstream request timeout |
Results contain only title, url and snippet, each length-bounded. Upstream error bodies are never returned to the model.
Development and releases
This package is part of the ai-platform-mcps monorepo. Development, testing and the shared release workflow are documented in the repository root.