The Ollama MCP Server enables seamless integration between local Ollama LLM instances and MCP-compatible applications, providing features like task decomposition, result evaluation, and workflow management through a standardized protocol.
Before installing the Ollama MCP Server, ensure you have Ollama set up:
# Install Ollama (if not already installed)
curl -fsSL https://ollama.com/install.sh | sh
# Download recommended models
ollama pull llama3
ollama pull mistral
ollama pull qwen2
Install the Ollama MCP Server using pip:
pip install ollama-mcp-server
You can configure the server using environment variables:
OLLAMA_HOST
: The Ollama server address (default: http://localhost:11434)DEFAULT_MODEL
: The default model to use (default: llama3)LOG_LEVEL
: Log level (options: debug, info, warning, error, critical)The server supports various performance-related settings in config.py
:
# Performance-related settings
cache_size: int = 100 # Maximum number of entries to store in cache
max_connections: int = 10 # Maximum number of simultaneous connections
max_connections_per_host: int = 10 # Maximum connections per host
request_timeout: int = 60 # Request timeout in seconds
Edit the configuration file at: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Edit the configuration file at: %APPDATA%/Claude/claude_desktop_config.json
For the published server:
"mcpServers": {
"ollama-MCP-server": {
"command": "uvx",
"args": [
"ollama-mcp-server"
]
}
}
With model specification:
"mcpServers": {
"ollama-MCP-server": {
"command": "python",
"args": [
"-m",
"ollama_mcp_server"
],
"env": [
{"model": "llama3:latest"}
]
}
}
The Ollama MCP Server allows specifying models in several ways, with the following priority:
model
parameter)env
sectionOLLAMA_DEFAULT_MODEL
)llama3
)When the server starts, it checks if the configured model exists and logs a warning if it cannot be found.
To break down complex tasks into manageable subtasks:
result = await mcp.use_mcp_tool({
"server_name": "ollama-MCP-server",
"tool_name": "decompose-task",
"arguments": {
"task_id": "task://123",
"granularity": "medium",
"max_subtasks": 5
}
})
To evaluate results against specific criteria:
evaluation = await mcp.use_mcp_tool({
"server_name": "ollama-MCP-server",
"tool_name": "evaluate-result",
"arguments": {
"result_id": "result://456",
"criteria": {
"accuracy": 0.4,
"completeness": 0.3,
"clarity": 0.3
},
"detailed": true
}
})
You can directly run Ollama models using the run-model
tool. This allows you to:
Creates a new task in the system.
name
(string), description
(string)priority
(number), deadline
(string), tags
(array)Breaks down complex tasks into manageable subtasks.
task_id
(string), granularity
(string: "high"|"medium"|"low")max_subtasks
(number)Analyzes task results against specified criteria.
result_id
(string), criteria
(object)detailed
(boolean)Runs an Ollama model with specified parameters.
model
(string), prompt
(string)temperature
(number), max_tokens
(number)Since the MCP server runs via stdio, debugging can be challenging. For an optimal debugging experience, it's strongly recommended to use the MCP Inspector.
To start the MCP Inspector using npm:
npx @modelcontextprotocol/inspector
Upon startup, the Inspector will display a URL that you can access in your browser to begin debugging.
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "ollama-MCP-server" '{"command":"uvx","args":["ollama-mcp-server"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"ollama-MCP-server": {
"command": "uvx",
"args": [
"ollama-mcp-server"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"ollama-MCP-server": {
"command": "uvx",
"args": [
"ollama-mcp-server"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect