Skip to main content
Glama

Ollama MCP 服务器

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

🌟 功能

完成 Ollama 集成

  • 完整的 API 覆盖:通过简洁的 MCP 界面访问所有必要的 Ollama 功能

  • OpenAI 兼容聊天:OpenAI 聊天完成 API 的直接替代品

  • Local LLM Power :在本地运行 AI 模型,并具有完全控制权和隐私

核心能力

  • 🔄模型管理

    • 从注册表中提取模型

    • 将模型推送到注册表

    • 列出可用模型

    • 从模型文件创建自定义模型

    • 复制和删除模型

  • 🤖模型执行

    • 使用可自定义的提示运行模型

    • 具有系统/用户/助理角色的聊天完成 API

    • 可配置参数(温度、超时)

    • 原始模式支持直接响应

  • 🛠服务器控制

    • 启动和管理 Ollama 服务器

    • 查看详细模型信息

    • 错误处理和超时管理

Related MCP server: Ollama MCP Server

🚀 入门

先决条件

  • 您的系统上已安装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 生态系统打造

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/NightTrek/Ollama-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server