Get the FREE Ultimate OpenClaw Setup Guide →

ollama o-adapter

Adapter to expose MCPO, the MCP-to-OpenAPI proxy server, tools in Ollama-compatible format

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio tappi287-ollama-mcpo-adapter uvx mcp-server-time --local-timezone=Europe/Berlin

How to use

ollama-mcpo-adapter exposes MCP-to-OpenAPI based MCP tools to Ollama as compatible functions. It connects to an MCPO instance and discovers the available MCP tools via MCPO's OpenAPI documentation, then presents them as Ollama tool calls that can be invoked from your prompts. You can either run MCPO yourself and point the adapter at it, or run MCPO as a service managed by the adapter, which will launch MCPO as a subprocess and handle lifecycle. The adapter provides two main workflows: discovering tools from a running MCPO API (via /docs and OpenAPI) and invoking those tools through Ollama ToolCall integration. You can also run an integrated MCPO service by supplying a custom MCP config, which makes it straightforward to manage the MCPO server lifecycle from Python.

To use it with an existing MCPO instance, start MCPO (for example via uvx mcpo --port 5090 --config /path/to/mcp_config.json), then create an OllamaMCPOAdapter pointing at that host and port. Call list_tools_ollama() to fetch the tools exposed by MCPO in Ollama’s format. When you submit prompts to Ollama, the adapter will convert tool calls into MCPO API calls, and return tool results back to Ollama. If you prefer an integrated workflow, you can run MCPO in a managed service via MCPOService, provide a JSON mcp_config, and then continue using list_tools_ollama() and the standard Ollama flow to execute tools.

How to install

Prerequisites:

  • Python 3.8+ and pip
  • Optional: a running MCPO instance

Installation steps:

  1. Install the adapter from PyPI: python -m pip install ollama-mcpo-adapter

  2. Verify installation: python -c "from ollama_mcpo_adapter import OllamaMCPOAdapter; print('OK')"

  3. (Optional) Start MCPO service via the adapter:

    Example of a JSON config for MCPOService (see mcp_config field for structure)

    python - <<'PY' from ollama_mcpo_adapter import MCPOService mcp_config = { "mcpServers": { "time": {"command": "uvx", "args": ["mcp-server-time", "--local-timezone=Europe/Berlin"]} } } mcpo = MCPOService("127.0.0.1", 4090, config=mcp_config) mcpo.start(wait=True)

... use adapter to query tools ...

mcpo.stop() PY

  1. Example usage in Python (discover tools): from ollama_mcpo_adapter import OllamaMCPOAdapter adapter = OllamaMCPOAdapter(host="127.0.0.1", port=5090, config_path="/path/to/mcp_config.json") tools = adapter.list_tools_ollama()

  2. If you already have MCPO running, simply install the adapter and query tools via list_tools_ollama().

Additional notes

Tips:

  • If you run MCPO with a custom port or config, ensure the port and path are correctly specified in the adapter or MCPO invocation.
  • The adapter discovers tools via MCPO/OpenAPI, so availability may depend on MCPO’s OpenAPI docs. Providing a stable config file helps maintain consistent tool discovery.
  • On Windows, you may need to configure a Windows-npx path if you’re using the MCPO CLI pipeline; for the Python adapter workflow this is typically not required unless you integrate CLI steps.
  • The included example config uses a time-related MCP server to illustrate the structure; replace with your actual MCP servers as needed.
  • If you encounter issues with tool discovery, check MCPO’s /docs and OpenAPI spec to confirm endpoint paths and tool names.
  • To stop a managed MCPO service started by the adapter, call mcpo.stop() or terminate the process as appropriate.

Related MCP Servers

Sponsor this space

Reach thousands of developers