Call Desearch web search through LiteLLM
Tested 17 November 2026.
For developers who want a local LiteLLM MCP gateway to route a search tool call. This example lists Desearch tools and calls web-search through LiteLLM's direct REST endpoints. It does not call an LLM or register Desearch as a model provider.
Tested versions: LiteLLM 1.109.1 with MCP SDK 2.3.0; Desearch MCP server 0.3.3.
Before you begin
Use Node.js 24.16.0, Python 3.12.13 and uv 0.12.1. These examples were tested on macOS with Apple Silicon on 17 November 2026. You need a Desearch API key with available credits, and network access to the npm and Python package registries and Desearch. Set DESEARCH_API_KEY in your shell using your secret manager before running the example. Keep it out of source files.
Desearch API requests use your account credits. Check Desearch pricing for current rates. This example calls the web-search tool once. Search titles and links can change between runs.
Keep the accompanying assets folder beside this guide. Run the commands in that directory. The package lock fixes Desearch MCP server 0.3.3 and its npm dependencies. The Python lock fixes the tested dependency set.
Download the assets
Save these files in an assets folder in your working directory, keeping the paths shown:
assets/desearch-mcp-server/package-lock.jsonassets/desearch-mcp-server/package.jsonassets/litellm.lockassets/litellm.yaml
Install the pinned dependencies
The accompanying configuration uses os.environ/DESEARCH_API_KEY for upstream bearer authentication and os.environ/LITELLM_MASTER_KEY for the local gateway. These are environment references. The example generates a temporary local gateway key in memory and supplies it to the child process; it never writes either key into the configuration file. It starts no database.
Run a search
Save this as litellm_search.py in the same directory:
Run with DESEARCH_API_KEY already set by your secret manager:
Success prints JSON with a nonempty title and link. The test returned Our Documentation | Python.org and a Desearch redirect path beginning /go/v1/. Result order and redirect tokens can change. The example terminates both child processes after the call.
Troubleshooting
Use unused loopback ports 19966 and 19968. The sample binds both services to 127.0.0.1 and is a local evaluation. If readiness fails, confirm these ports are free and install the exact provided dependency lock.
HTTP discovery at the upstream Desearch server is public. An unauthenticated tools/call returned HTTP 401 with isError: true. Successful discovery alone does not prove search access. The local LiteLLM key admits requests to the gateway; DESEARCH_API_KEY authorizes the upstream search. For a rejected Desearch key or insufficient credits, check the key and account balance before retrying.
Use server_id: desearch with the unprefixed web-search name, as in the example. The REST endpoints here are /mcp-rest/tools/list and /mcp-rest/tools/call. They are separate from the MCP JSON-RPC endpoint.