O

Ollama MCP桥接器

@rawveg/ollama-mcp
0 Stars 436 次浏览 rawveg 更新于 2026-08-23

# 翻译 实现了Ollama的本地LLM模型与支持MCP协议的应用程序之间的无缝集成,支持模型管理和聊天互动。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "@rawveg/ollama-mcp": {
      "args": [
        "-y",
        "@rawveg/ollama-mcp"
      ],
      "command": "npx"
    }
  }
}

该服务需要配置环境变量:OLLAMA_API、PORT

服务介绍

Ollama MCP 服务器

smithery 徽章

一个用于 Ollama 的 MCP(模型上下文协议)服务器,可实现 Ollama 的本地 LLM 模型与像 Claude Desktop 这样的 MCP 兼容应用程序之间的无缝集成。

功能

  • 列出可用的 Ollama 模型
  • 从 Ollama 拉取新模型
  • 使用 Ollama 的聊天 API 与模型对话
  • 获取详细的模型信息
  • 自动端口管理
  • 环境变量配置

前提条件

  • Node.js (v16 或更高版本)
  • npm
  • 已安装并正在本地运行的 Ollama

安装

通过 Smithery 安装

要通过 Smithery 自动为 Claude Desktop 安装 Ollama MCP 服务器:

npx -y @smithery/cli install @rawveg/ollama-mcp --client claude

手动安装

通过 npm 全局安装:

npm install -g @rawveg/ollama-mcp

在其他 MCP 应用程序中安装

要在其他兼容 MCP 的应用程序(如 Cline 或 Claude Desktop)中安装 Ollama MCP 服务器,请将以下配置添加到您的应用程序的 MCP 设置文件中:

{
  "mcpServers": {
    "@rawveg/ollama-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@rawveg/ollama-mcp"
      ]
    }
  }
}

设置文件的位置因应用程序而异:

  • Claude Desktop: Claude 应用数据目录中的 claude_desktop_config.json
  • Cline: VS Code 全局存储中的 cline_mcp_settings.json

使用

启动服务器

只需运行:

ollama-mcp

服务器默认将在端口 3456 上启动。您可以使用 PORT 环境变量指定不同的端口:

PORT=3457 ollama-mcp

环境变量

  • PORT: 服务器端口(默认:3456)。在直接运行时和通过 Smithery 安装时都可以使用:
    # 直接运行时
    PORT=3457 ollama-mcp
    
    # 通过 Smithery 安装时
    PORT=3457 npx -y @smithery/cli install @rawveg/ollama-mcp --client claude
    
  • OLLAMA_API: Ollama API 终端(默认:http://localhost:11434)

API 接口

  • GET /models - 列出可用模型
  • POST /models/pull - 拉取新模型
  • POST /chat - 与模型对话
  • GET /models/:name - 获取模型详情

开发

  1. 克隆仓库:
git clone https://github.com/rawveg/ollama-mcp.git
cd ollama-mcp
  1. 安装依赖项:
npm install
  1. 构建项目:
npm run build
  1. 启动服务器:
npm start

贡献

欢迎贡献!请随时提交 Pull Request。

许可证

MIT

相关链接

相关 MCP 服务