Bridging Ollama to MCP: Using MCPHost for Local LLM Tool Calls
Bridge Ollama to MCP with MCPHost by installing the CLI, configuring JSON, and running mcphost with your model.
Bridge Ollama to MCP with MCPHost by installing the CLI, configuring JSON, and running mcphost with your model.
Summary
Ollama does not implement the MCP protocol; it exposes an OpenAI‑compatible REST API with a /api/chat endpoint and a tools parameter that returns JSON tool calls. To use MCP servers with a local Ollama model, the article recommends MCPHost, a Go CLI that bridges MCP servers to Ollama by negotiating capabilities and routing tool calls. MCPHost is installed via go install github.com/mark3labs/mcphost@latest, configured with a JSON file listing MCP servers (e.g., filesystem) and specifying the Ollama backend URL. The command mcphost --config mcp-config.json --model ollama:qwen2.5:14b --ollama-url http://localhost:11434 starts the bridge, enabling the model to call MCP servers. Supported models that handle tool calling include Qwen2.5, Llama 3.3, Mistral Nemo, and Gemma 3; smaller quantizations may produce malformed JSON. Limitations include tool‑calling reliability, context‑length consumption, and latency, so users should simplify schemas, truncate large responses, and expect 2–10 s per call on consumer hardware. For offline use, stick to filesystem, database, and local code servers, while cloud‑service servers require API credentials. MCPHost is the simplest CLI for local MCP integration, but other MCP clients can also be used.
Key changes
- Ollama lacks MCP protocol; uses OpenAI‑compatible /api/chat with tools param.
- MCPHost Go CLI bridges MCP servers to Ollama.
- Install MCPHost via go install github.com/mark3labs/mcphost@latest.
- Config JSON lists MCP servers (e.g., filesystem) and sets ollama-url.
- Run mcphost --config mcp-config.json --model ollama:qwen2.5:14b --ollama-url http://localhost:11434.
- Supported models for tool calling: Qwen2.5, Llama 3.3, Mistral Nemo, Gemma 3.
- Limitations: tool‑calling reliability, context length, latency; simplify schemas and truncate large responses.
- Offline‑friendly servers: filesystem, database, local code; cloud services need credentials.