Adapter to expose MCPO, the MCP-to-OpenAPI proxy server, tools in Ollama-compatible format
Project description
🦙 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ollama_mcpo_adapter-0.1.1.tar.gz.
File metadata
- Download URL: ollama_mcpo_adapter-0.1.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f41cae0b562e8268eda1fe0eeb09fbc25bf959e0e613c48a4ae556a17523d461
|
|
| MD5 |
e9aa66e70125c000741894c24cb3aa73
|
|
| BLAKE2b-256 |
c85f86e9235a6c073ab35c8e613fc6593a3d0d56cce73fe09150839434ae75b9
|
Provenance
The following attestation bundles were made for ollama_mcpo_adapter-0.1.1.tar.gz:
Publisher:
python-publish.yml on tappi287/ollama-mcpo-adapter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ollama_mcpo_adapter-0.1.1.tar.gz -
Subject digest:
f41cae0b562e8268eda1fe0eeb09fbc25bf959e0e613c48a4ae556a17523d461 - Sigstore transparency entry: 195392675
- Sigstore integration time:
-
Permalink:
tappi287/ollama-mcpo-adapter@016b2487571da703e7dc31c36cf514ce889930ff -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/tappi287
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@016b2487571da703e7dc31c36cf514ce889930ff -
Trigger Event:
release
-
Statement type:
File details
Details for the file ollama_mcpo_adapter-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ollama_mcpo_adapter-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9dd5bb2075293c2ab81bc87a7e6ce1d4e2fcdd8fea2b2d2d5e8da5e79157c3da
|
|
| MD5 |
2e6b3cce9a2a640a1367493f113aa6e0
|
|
| BLAKE2b-256 |
d9d6b8645508d50ef667475ff6cfec86a9332c3a44a03bc13f8bd2c2ac332405
|
Provenance
The following attestation bundles were made for ollama_mcpo_adapter-0.1.1-py3-none-any.whl:
Publisher:
python-publish.yml on tappi287/ollama-mcpo-adapter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ollama_mcpo_adapter-0.1.1-py3-none-any.whl -
Subject digest:
9dd5bb2075293c2ab81bc87a7e6ce1d4e2fcdd8fea2b2d2d5e8da5e79157c3da - Sigstore transparency entry: 195392677
- Sigstore integration time:
-
Permalink:
tappi287/ollama-mcpo-adapter@016b2487571da703e7dc31c36cf514ce889930ff -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/tappi287
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@016b2487571da703e7dc31c36cf514ce889930ff -
Trigger Event:
release
-
Statement type: