mcpField
πŸ¦™
πŸ¦™ ollama-mcpo-adapter

πŸ¦™ ollama-mcpo-adapter

Local
github.com/tappi287AI & Agents4Updated 81w ago

About πŸ¦™ ollama-mcpo-adapter

ollama-mcpo-adapter is a Python adapter that makes tools exposed by MCPO available in Ollama-compatible function format. It can connect to an existing MCPO instance or start one through its optional service component.

Key features

  1. 01Connect to an MCPO instance
  2. 02List tools in Ollama function format
  3. 03Launch MCPO through MCPOService
  4. 04Dispatch tool calls from Ollama responses

Use cases

  1. 01Provide MCPO tools to an Ollama chat request
  2. 02Discover functions from an existing MCPO instance
  3. 03Start a local MCPO service from MCP configuration

MCP support

It connects to MCPO, which exposes MCP tools through OpenAPI, and converts their descriptions to Ollama-compatible functions. Its optional service component can launch MCPO using an MCP configuration.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json Β· Universal config
{
"mcpServers": {
"ollama-mcpo-adapter": {
"command": "uvx",
"args": [
"mcpo"
]
}
}
}
Run commanduvx mcpo

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
pypimcpo

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

πŸ¦™ ollama-mcpo-adapter

Expose MCPO, the MCP-to-OpenAPI proxy server, tools as Ollama-compatible functions using a simple Python adapter and optional runtime service.


✨ Features

  • πŸ”Œ Connect to a MCPO instance
  • βš™οΈ Launch your own MCPO server programmatically via MCPOService
  • πŸ” List MCP tools exposed via OpenAPI as Ollama-compatible tool functions

πŸš€ Quickstart

1. Install
pip install ollama-mcpo-adapter
Usage with Existing MCPO Instance

Assuming you have MCPO running like this:

uvx mcpo --port 5090 --config /path/to/mcp_config.json

You can get all available functions in Ollama ToolCall format with the adapter:

from ollama_mcpo_adapter import OllamaMCPOAdapter

adapter = OllamaMCPOAdapter(host="localhost", port=5090, config_path="/path/to/mcp_config.json")
# Gets tool descriptions from MCPO FastAPI /docs
tools = adapter.list_tools_ollama()

You can omit the config path. But discovery of MCP server names is more reliable with a provided config. Otherwise, the server names will be read from the automatically generated OpenAPI docs MCPO provides which might change in the future.


Usage with Local MCPO Service

You can start a MCPO service with this extension:

from ollama_mcpo_adapter import MCPOService

# Provide your mcp config as JSON file or dictionary
mcp_config = {
    "mcpServers": {
        "time": {"command": "uvx", "args": ["mcp-server-time", "--local-timezone=Europe/Berlin"]}
    }
}
mcpo = MCPOService("127.0.0.1", 4090, config=mcp_config,
                   # -OR- from an existing mcp_config file 
                   config_path="path/to/mcp_config.json")
# MCPOSService class handles MCPO server start-up and shutdown and in a subprocess
mcpo.start(wait=True)
...
mcpo.stop()

Then get all available tools with the adapter:

from ollama_mcpo_adapter import OllamaMCPOAdapter
adapter = OllamaMCPOAdapter("127.0.0.1", 4090)
tools = adapter.list_tools_ollama()

Send this to Ollama:

from ollama import Client
# Send a prompt to Ollama using discovered tools
client = Client(host="http://127.0.0.1:11434")
response = client.chat(
    model="qwen2.5-coder:14b-instruct-q4_K_M",
    messages=[{"role": "user", "content": "Write a file..."}],
    tools=tools,
)

And finally call the tools:

# Handle any tool calls
if response.message.tool_calls:
    adapter.call_tools_from_response(response.message.tool_calls)

Env
  • MS Windows npx path, you can overwrite npx with a path to npx in the config parser

    example: WIN_NODEJS_NPX_PATH=C:\Program Files\nodejs\npx.cmd


πŸ§ͺ Running Tests
pytest

πŸ“‚ Project Structure
ollama_mcpo_adapter/
β”œβ”€β”€ adapter.py        # Tool discovery + Ollama integration
β”œβ”€β”€ service.py        # Optional: launch MCPO programmatically
β”œβ”€β”€ service_runner.py # MCPO subprocess control
β”œβ”€β”€ config_parser.py  # MCP config parsing helpers
β”œβ”€β”€ dispatcher.py     # Dispatch tool calls

πŸ“œ License

MIT. See LICENSE.

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.