Ollama MCP Server

Ollama MCP Server

site icon
2025.02.13 44
TypeScriptLLM 模型集成本地模型服务开发效率
Ollama MCP Server 是一个基于 Model Context Protocol (MCP) 的服务,旨在实现 Ollama 的本地 LLM 模型与 MCP 兼容应用程序(如 Claude Desktop)之间的无缝集成。该服务提供了模型管理、聊天交互、端口管理等功能,适用于需要本地 LLM 模型集成的开发场景。
View on GitHub

Overview

基本能力

产品定位

Ollama MCP Server 是一个用于集成 Ollama 本地 LLM 模型与 MCP 兼容应用程序的中间服务。

核心功能

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

适用场景

  • 开发需要本地 LLM 模型集成的应用程序
  • 在 MCP 兼容应用(如 Claude Desktop)中使用 Ollama 模型
  • 快速测试和部署本地 LLM 模型

工具列表

  • ollama-mcp: 主服务工具,用于启动和管理 MCP 服务
  • npx @rawveg/ollama-mcp: 通过 npm 运行的工具

常见问题解答

  • 默认端口为 3456,可通过 PORT 环境变量修改
  • 需要确保 Ollama 已安装并在本地运行
  • 安装时可通过 Smithery 或手动 npm 安装

使用教程

使用依赖

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

安装教程

通过 Smithery 安装

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

手动全局安装

npm install -g @rawveg/ollama-mcp

在其他 MCP 应用中安装

在应用的 MCP 设置文件中添加以下配置:

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

调试方式

启动服务

ollama-mcp

指定端口启动

PORT=3457 ollama-mcp

环境变量

  • PORT: 服务端口(默认: 3456)
  • OLLAMA_API: Ollama API 端点(默认: http://localhost:11434)

API 端点

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

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。