Ollama MCP Server

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Provides complete integration with Ollama, allowing users to pull, push, list, create, copy, and run local LLM models. Includes model management, execution of models with customizable prompts, and an OpenAI-compatible chat completion API.

  • Offers an OpenAI-compatible chat completion API that serves as a drop-in replacement, enabling the use of local Ollama models with the familiar OpenAI chat interface and message structure.

Ollama MCP 服务器

🚀 Ollama 和模型上下文协议 (MCP) 之间的强大桥梁,可将 Ollama 的本地 LLM 功能无缝集成到由 MCP 驱动的应用程序中。

🌟 功能

完成 Ollama 集成

  • 完整的 API 覆盖:通过简洁的 MCP 界面访问所有必要的 Ollama 功能
  • OpenAI 兼容聊天:OpenAI 聊天完成 API 的直接替代品
  • Local LLM Power :在本地运行 AI 模型,并具有完全控制权和隐私

核心能力

  • 🔄模型管理
    • 从注册表中提取模型
    • 将模型推送到注册表
    • 列出可用模型
    • 从模型文件创建自定义模型
    • 复制和删除模型
  • 🤖模型执行
    • 使用可自定义的提示运行模型
    • 具有系统/用户/助理角色的聊天完成 API
    • 可配置参数(温度、超时)
    • 原始模式支持直接响应
  • 🛠服务器控制
    • 启动和管理 Ollama 服务器
    • 查看详细模型信息
    • 错误处理和超时管理

🚀 入门

先决条件

  • 您的系统上已安装Ollama
  • Node.js 和 npm/pnpm

安装

  1. 安装依赖项:
pnpm install
  1. 构建服务器:
pnpm run build

配置

将服务器添加到您的 MCP 配置:

对于 Claude 桌面:

MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%/Claude/claude_desktop_config.json

{ "mcpServers": { "ollama": { "command": "node", "args": ["/path/to/ollama-server/build/index.js"], "env": { "OLLAMA_HOST": "http://127.0.0.1:11434" // Optional: customize Ollama API endpoint } } } }

🛠 使用示例

拉取并运行模型

// Pull a model await mcp.use_mcp_tool({ server_name: "ollama", tool_name: "pull", arguments: { name: "llama2" } }); // Run the model await mcp.use_mcp_tool({ server_name: "ollama", tool_name: "run", arguments: { name: "llama2", prompt: "Explain quantum computing in simple terms" } });

聊天完成(兼容 OpenAI)

await mcp.use_mcp_tool({ server_name: "ollama", tool_name: "chat_completion", arguments: { model: "llama2", messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "What is the meaning of life?" } ], temperature: 0.7 } });

创建自定义模型

await mcp.use_mcp_tool({ server_name: "ollama", tool_name: "create", arguments: { name: "custom-model", modelfile: "./path/to/Modelfile" } });

🔧 高级配置

  • OLLAMA_HOST :配置自定义 Ollama API 端点(默认值: http ://127.0.0.1:11434 )
  • 模型执行的超时设置(默认值:60秒)
  • 温度控制响应随机性(0-2范围)

🤝 贡献

欢迎贡献!请随意:

  • 报告错误
  • 建议新功能
  • 提交拉取请求

📝 许可证

MIT 许可证 - 请随意在您自己的项目中使用!


用❤️为 MCP 生态系统打造

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

这座桥梁可将 Ollama 的本地 LLM 功能无缝集成到 MCP 驱动的应用程序中,让用户能够在本地管理和运行具有完整 API 覆盖的 AI 模型。

  1. 🌟 Features
    1. Complete Ollama Integration
    2. Core Capabilities
  2. 🚀 Getting Started
    1. Prerequisites
    2. Installation
    3. Configuration
  3. 🛠 Usage Examples
    1. Pull and Run a Model
    2. Chat Completion (OpenAI-compatible)
    3. Create Custom Model
  4. 🔧 Advanced Configuration
    1. 🤝 Contributing
      1. 📝 License
        ID: sxt5su901q