Home›Guides›Ollama MCP: what Ollama does and doesn’t do, and a short Python bridge to MCP servers, tested (v0.40.18)

Setup · Guide

Ollama MCP: what Ollama does and doesn’t do, and a short Python bridge to MCP servers, tested (v0.40.18)

Ollama doesn’t speak MCP on its own: version 0.40.18 has no MCP client or server, only tool calling. To use an MCP server with Ollama, you need a client in the middle that lists the server’s tools, passes them to /api/chat as tools and runs the calls the model asks for. Here’s one in 42 lines of Python.

Measured and written by Local AI ScopePublished Figures measured by Local AI Scope

Ollama doesn’t speak MCP on its own: version 0.40.18 has no MCP client or server, only tool calling. To use an MCP server with Ollama, you need a client in the middle that lists the server’s tools, passes them to /api/chat as tools and runs the calls the model asks for. Here’s one in 42 lines of Python.

We tried it on 26 November 2026 with Ollama 0.40.18, the latest stable release that day: the official Linux binary (checksum verified), no GPU, the small qwen3:0.6b and qwen3:1.7b, and three real MCP servers: time, filesystem and fetch. Every output on this page is copied from our terminal (with the prompt and paths shortened), including the times the model let us down.

OllamaOllamaRuntime sheet

Does Ollama support MCP? What the v0.40.18 code says

We went to the source before writing a line. In the Go code of Ollama 0.40.18, the word MCP only appears in the ollama launch integrations, which we cover further down. There’s nothing in the server: no setting to point Ollama at an MCP server, no endpoint that speaks the protocol, and no tool that Ollama runs by itself. The only MCP server in the official documentation is an example for Ollama’s web search, and that one calls ollama.com with an API key, so it isn’t local.

That’s not a gap, it’s the design. MCP (Model Context Protocol) is a way for a program, the client, to discover and call tools exposed by another program, the server. Ollama sits one level below: it runs the model and, if the model supports tools, returns the tool_calls it wants. If tool_calls sounds new, our Ollama tool calling guide covers the whole loop step by step. Here we add the piece that connects that loop to any MCP server. If what your model needs is your own documents rather than tools, that’s a RAG, and we built one in our Ollama RAG guide.

The bridge: MCP tools in, Ollama tool_calls out

We installed the official MCP SDK for Python (mcp 2.3.0) and the reference time server (mcp-server-time) with pip, and pulled the model:

pip install mcp mcp-server-time
ollama pull qwen3:0.6b

The bridge starts the MCP server as a subprocess, asks it for its tools, turns each one into the format of the tools field of the Ollama API and runs the loop: if the model asks for a tool, the bridge calls it on the MCP server and returns the result with the tool role. This is the exact file we ran:

# ollama_mcp.py: connect an Ollama model to any stdio MCP server
import asyncio, json, os, sys, urllib.request
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

OLLAMA = os.environ.get("OLLAMA_URL", "http://127.0.0.1:11434") + "/api/chat"
MODEL = os.environ.get("MODEL", "qwen3:0.6b")

def chat(messages, tools):
    body = json.dumps({"model": MODEL, "messages": messages, "tools": tools,
                       "stream": False, "think": False,
                       "options": {"temperature": 0}}).encode()
    req = urllib.request.Request(OLLAMA, body, {"Content-Type": "application/json"})
    return json.load(urllib.request.urlopen(req))["message"]

async def main(question, command, *args):
    server = StdioServerParameters(command=command, args=list(args))
    async with stdio_client(server) as (read, write):
        async with ClientSession(read, write) as mcp:
            await mcp.initialize()
            listed = await mcp.list_tools()
            tools = [{"type": "function",
                      "function": {"name": t.name, "description": t.description,
                                   "parameters": t.input_schema}} for t in listed.tools]
            print("MCP tools:", [t.name for t in listed.tools], file=sys.stderr)
            messages = [{"role": "user", "content": question}]
            for _ in range(5):
                msg = chat(messages, tools)
                messages.append(msg)
                if not msg.get("tool_calls"):
                    print(msg["content"])
                    return
                for call in msg["tool_calls"]:
                    fn = call["function"]
                    print("->", fn["name"], json.dumps(fn["arguments"]), file=sys.stderr)
                    result = await mcp.call_tool(fn["name"], fn["arguments"])
                    text = "".join(c.text for c in result.content if c.type == "text")
                    print("<-", text[:300], file=sys.stderr)
                    messages.append({"role": "tool", "tool_name": fn["name"],
                                     "content": text})

asyncio.run(main(*sys.argv[1:]))

Three details that matter. The MCP tool schema goes straight into parameters, because both sides use JSON Schema. "think": false is there because qwen3 thinks by default, and in our tool calling tests (Ollama 0.40.16) it skipped the call 4 times out of 5 with thinking on. And the loop stops after 5 rounds, so a confused model can't keep calling tools forever.

A first MCP server: the time in Tokyo

We ran the bridge with the time server and asked something a model can't know without a clock:

Terminal with Ollama 0.40.18: the bridge passes the 3 tools of the MCP time server to qwen3:0.6b, which calls get_current_time for Asia/Tokyo and answers with the real time
The model asks for get_current_time, the MCP server answers, the model writes the time Output of our test, Ollama 0.40.18, 26 Nov 2026

The output reads like a little play in three acts. The server offered 3 tools, the model picked get_current_time with the right time zone, the bridge ran it and the model wrote the answer with the server's real time. With a question that needed a conversion ("It is 9:00 in Madrid. What time is it in New York?"), it picked convert_time and answered 3:00 AM, which is correct. On our machine (AMD Ryzen 7 7730U, CPU only), the whole run with the model already loaded took 3.2 seconds, measured once.

Opens on YouTube (no cookies) only when you press play.

Almost 22 minutes, published in April 2026. Its chapters go from installing Ollama and choosing a model (Qwen 3.5, according to its description) to connecting an online service through MCP and then running it from code with LangChain. It goes further than our bridge, so watch it once you have the basics working.

The filesystem MCP server: 16 tools and one folder

The reference filesystem server (@modelcontextprotocol/server-filesystem 2.4.0, installed with npm) is more interesting because it touches your disk. It only works inside the folders you pass on the command line. We created a sandbox folder with two text files and asked the model to list it and read one.

The 0.6B model listed the folder fine, then called get_file_info instead of reading the file, and answered with the size and the dates instead of the content. With qwen3:1.7b, same question, it chained two calls (list_directory and read_text_file) and quoted the shopping list word for word, in 11.6 seconds for the whole run (one run, measured):

Terminal with Ollama 0.40.18: qwen3:1.7b calls list_directory and read_text_file on the MCP filesystem server and quotes the file content
Two calls in a row with qwen3:1.7b: list the folder, then read the file Output of our test, Ollama 0.40.18, 26 Nov 2026

And when we asked it to read /etc/hostname, outside the sandbox, the server refused:

Terminal with Ollama 0.40.18: the MCP filesystem server answers Access denied, path outside allowed directories, for /etc/hostname
Outside the folder you passed, the filesystem server says no Output of our test, Ollama 0.40.18, 26 Nov 2026

What MCP tools cost: tokens in every request

The bridge sends every tool definition with every request, so the size of the MCP server shows up in the prompt. We measured the same question with and without the server's tools (prompt_eval_count, Ollama 0.40.18, qwen3, 26 November 2026):

MCP server Tools Prompt tokens without tools With the server's tools Extra
fetch 1 28 413 +385
time 3 24 594 +570
filesystem 16 46 2,868 +2,822

Measured: same count with qwen3:0.6b and qwen3:1.7b. Official Linux binary, CPU only.

When the model answers without calling the tool

This is the failure that doesn't show up as an error. We asked the 0.6B model to fetch ollama.com with the fetch server and describe it in one sentence. It didn't call fetch. It answered straight away, sure of itself, that the page "offers a platform for training large language models", which isn't what the page says. With qwen3:1.7b, the same question did call fetch, read the page and summed it up from what was there:

Terminal with Ollama 0.40.18: qwen3:0.6b answers without calling the MCP fetch tool, qwen3:1.7b calls fetch on ollama.com and sums up the page
No -> line with 0.6B: the answer came from memory. With 1.7B, the call is there Output of our test, Ollama 0.40.18, 26 Nov 2026

What worked for us was a bigger model, qwen3:1.7b, with the same question. When you test a bridge, look at the -> lines: if there's no call, the answer came from the model's memory, however confident it sounds.

"does not support tools", "Connection closed" and the other errors we hit

These are the messages we got on Ollama 0.40.18, copied as they came out:

Terminal with Ollama 0.40.18: does not support tools (HTTP 400), model not found (HTTP 404), FileNotFoundError, MCPError Connection closed and Connection refused
Five errors, five causes: model, download, command, MCP server and Ollama Output of our test, Ollama 0.40.18, 26 Nov 2026
  • does not support tools (HTTP 400): the model doesn't declare the tools capability. gemma3:270m does this. Check with ollama show <model>: if tools isn't under Capabilities, MCP won't work with that model through this route. Open WebUI hits the same error on the first message with a model like that, because it sends its built-in tools by default, as we saw in our Open WebUI with Ollama guide.
  • model 'qwen3:4b' not found (HTTP 404): the model isn't downloaded. ollama pull it first.
  • FileNotFoundError: the bridge can't find the MCP server's command. Use the full path or activate the environment where you installed it.
  • MCPError: Connection closed: the MCP server started and died before answering. Run the server's command alone to see why.
  • Connection refused: Ollama isn't running at that address. ollama serve, or check OLLAMA_URL.
  • 'Tool' object has no attribute 'inputSchema'. Did you mean: 'input_schema'?: we got this one ourselves on the first try. In mcp 2.3.0 the field is called input_schema, and code that reads inputSchema stops right there.

On models: in our tests qwen3:0.6b and qwen3:1.7b list completion, tools and thinking, and gemma3:270m only completion. Before you pick a model for MCP, check that tools is there.

ollama launch and MCP: what it actually changes

ollama launch opens other programs (coding assistants, chat apps) already pointed at your local Ollama. In v0.40.18 it lists 18 integrations:

Terminal with Ollama 0.40.18: ollama launch --help lists 18 supported integrations
ollama launch --help in v0.40.18: the integrations it can open Output of our test, Ollama 0.40.18, 26 Nov 2026

We read what each one does with MCP in the code, and there's very little. ollama launch doesn't add MCP servers to any of them. For Claude Code, it sets ENABLE_CLAUDEAI_MCP_SERVERS=false in the launched process, even if you had it set to true: going by its name, that switches off the MCP servers that come from a claude.ai account. For Claude Desktop (ollama launch claude-desktop, which shows up in the help examples), it allows outgoing connections to any host, because, as the code itself explains, Cowork needs them for the plugins and MCP servers the user configures; --restore undoes it. For Muse Code, the first launch starts from your own Muse settings, so your MCP servers carry over. Nowhere in that code does Ollama set up an MCP server: they're configured in the program you launch.

Three places this leads

  • Ollama tool calling: the loop the bridge uses, the tool role and why thinking models skip calls.
  • Ollama API: every endpoint, the address and port, and what goes out to the internet.
  • Open WebUI with Ollama: a chat window on top of the same models, with its own tool settings.

Our Ollama runtime page has the version we track and what it runs on.