Ollama MCP Server
Bridges Ollama's capabilities with MCP-compatible clients, enabling web search and content fetching to provide real-time information and reduce hallucinations.
README
Ollama MCP Server
A production-grade Model Context Protocol (MCP) server that bridges Ollama's capabilities with MCP-compatible clients (like Cline, Codex, Goose). This server specifically provides web search and content fetching capabilities through the Ollama API, enabling AI models to access real-time information and reduce hallucinations.
✨ Features
- ✅ Web Search: Search the internet for current information using
ollama_web_search. - ✅ Content Fetching: specific URL content retrieval using
ollama_web_fetch. - ✅ Flexible Configuration: Supports both Ollama Cloud (default) and Local Ollama endpoints.
- ✅ Type-Safe: Built with
pydanticfor robust input validation. - ✅ Async I/O: High-performance, non-blocking operations using
httpx. - ✅ Easy Integration: Seamlessly works with any MCP-compliant client.
🚀 Quick Start
Prerequisites
- Python 3.8 or higher
- An Ollama API key (get it from ollama.com/account)
Installation
-
Clone the repository:
git clone https://github.com/adrianpuiu/ollama-mcp-server.git cd ollama-mcp-server -
Install dependencies:
pip install -r requirements.txt
Configuration
You must set the OLLAMA_API_KEY environment variable for the server to authenticate.
# Linux/macOS
export OLLAMA_API_KEY="your_actual_api_key_here"
# Windows (Command Prompt)
set OLLAMA_API_KEY=your_actual_api_key_here
# Windows (PowerShell)
$env:OLLAMA_API_KEY="your_actual_api_key_here"
🛠️ Usage
1. As a Standalone Server
You can run the server directly. It uses stdio for communication, so it will wait for input.
python ollama_mcp.py
2. Integration with Gemini CLI
To add this server to your Gemini CLI configuration:
gemini mcp add ollama_mcp python /absolute/path/to/ollama_mcp.py \
-e OLLAMA_API_KEY=your_key_here \
-s user
3. Integration with Cline / Codex
Add the following to your MCP configuration file (e.g., ~/.cline/config.json or ~/.codex/config.toml):
JSON (Cline):
{
"mcpServers": {
"ollama_mcp": {
"command": "python",
"args": ["/absolute/path/to/ollama_mcp.py"],
"env": {
"OLLAMA_API_KEY": "your_actual_api_key_here"
}
}
}
}
⚠️ Important Note on Web Search
The Web Search (ollama_web_search) and Web Fetch (ollama_web_fetch) tools typically require the Ollama Cloud API.
- Default Behavior: The server defaults to
https://ollama.com/api. - Local Ollama: If you are running Ollama locally (
http://localhost:11434), note that the standard local installation does not usually include the web search endpoints (/api/web_search). - Recommendation: Use the cloud endpoint for search features, even if you use a local instance for model inference.
If you encounter a 404 Not Found error when searching, ensure you are using the cloud endpoint:
export OLLAMA_API_BASE_URL="https://ollama.com/api"
🧪 Testing
The project includes a comprehensive test suite.
# Run all tests
python test_ollama_mcp.py
Manual Test with Python:
import asyncio
import os
from ollama_mcp import ollama_web_search, WebSearchInput
# Ensure API Key is set
os.environ["OLLAMA_API_KEY"] = "your_key_here"
async def main():
params = WebSearchInput(query="latest AI news", max_results=3)
result = await ollama_web_search(params)
print(result)
if __name__ == "__main__":
asyncio.run(main())
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.