Token导航 LogoToken导航TokenDH.com
Ollama Mcpo Adapter logo
开发工具stdio官方级别未说明来源级核验

Ollama Mcpo Adapter

MCP Server

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

工具数

0

提示词数

0

GitHub Stars

4

资源数

0
API集成Python开发工具

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

tappi287

提供方

tappi287

最后核验

2026/5/18 04:56

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install ollama-mcpo-adapter

详细介绍

🦙 ollama-mcpo适配器

将MCPO、MCP暴露给OpenAPI代理服务器,作为Ollama兼容功能的工具 使用简单的Python适配器和可选的运行时服务。

______________________________________________________________________

✨ 特性

  • 🔌 连接到a MCPO 例子
  • ⚙️ 通过编程方式启动您自己的MCPO服务器 MCPOService
  • 🔁 列表 MCP工具 通过OpenAPI作为Ollama兼容工具函数公开

______________________________________________________________________

🚀 快速启动

1.安装

pip install ollama-mcpo-adapter

与现有MCPO实例一起使用

假设MCPO的运行方式如下:

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

您可以使用适配器获得Ollama ToolCall格式的所有可用函数:

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()

您可以省略配置路径。但是,使用提供的配置发现MCP服务器名称更可靠。 否则,将从自动生成的OpenAPI文档中读取服务器名称 MCPO 未来可能会发生变化。

______________________________________________________________________

使用本地MCPO服务

您可以使用此扩展启动MCPO服务:

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()

然后使用适配器获取所有可用工具:

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

把这个发给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,
)

最后调用工具:

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

______________________________________________________________________

环境

  • MS Windows npx路径,您可以在配置解析器中用npx的路径覆盖npx

例子: WIN_NODEJS_NPX_PATH=C:\Program Files\nodejs\npx.cmd

______________________________________________________________________

🧪 运行测试

pytest

______________________________________________________________________

📂 项目结构

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

______________________________________________________________________

📜 许可证

MIT。看 许可证.

目录标签

目录标签

API集成Python开发工具developer-toolsopenapimcp-servermcpo-to-ollamaopenapi-to-ollama-toolsMCPO适配器本地部署Ollama工具集成OpenAPI代理Python工具

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP