PO

patruff/ollama-mcp-bridge

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

984 stars 113 forks 质量 66 趋势 0MIT

连接 Ollama 与 MCP 服务器,使本地大型语言模型能够使用模型上下文协议工具

概览

一种TypeScript实现,通过Ollama将本地LLM连接到模型上下文协议(MCP)服务器。该桥接使开源模型能够使用与Claude相同的工具和功能,从而实现强大的本地AI助手。 该项目将本地大型语言模型与MCP服务器连接起来,MCP服务器提供多种功能,如:- 文件系统操作 - Brave网页搜索 - GitHub交互 - Google Drive与Gmail集成 - 内存/存储 - 带Flux生成图像 桥接连接LLM的输出与MCP的JSON-RPC协议,使任何兼容Ollama的模型都能像Claude一样使用这些工具。 - :使用 Qwen 2.5 7B(qwen2.

概述(AI 翻译)

一种TypeScript实现,通过Ollama将本地LLM连接到模型上下文协议(MCP)服务器。该桥接使开源模型能够使用与Claude相同的工具和功能,从而实现强大的本地AI助手。

概述

该项目将本地大型语言模型与MCP服务器连接起来,MCP服务器提供多种功能,如:

  • 文件系统操作
  • 勇敢的网络搜索
  • GitHub 互动
  • Google Drive 与 Gmail 集成
  • 内存/存储
  • 带通量的图像生成

桥接连接LLM的输出与MCP的JSON-RPC协议,使任何兼容Ollama的模型都能像Claude一样使用这些工具。

当前配置

  • LLM:通过Ollama 使用 Qwen 2.5 7B(qwen2.5-coder:7b-instruct)
  • MCP:
  • 文件系统操作(@modelcontextprotocol/server-filesystem)
  • 勇敢搜索(@modelcontextprotocol/server-brave-search)
  • GitHub (@modelcontextprotocol/server-github)
  • 内存(@modelcontextprotocol/server-memory)
  • 通量图像生成(@patruff/server-flux)
  • Gmail 和 Drive(@patruff/server-gmail-drive)

建筑

  • Bridge:管理工具注册和执行的核心组件

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP-LLM Bridge

A TypeScript implementation that connects local LLMs (via Ollama) to Model Context Protocol (MCP) servers. This bridge allows open-source models to use the same tools and capabilities as Claude, enabling powerful local AI assistants.

Overview

This project bridges local Large Language Models with MCP servers that provide various capabilities like:

  • Filesystem operations
  • Brave web search
  • GitHub interactions
  • Google Drive & Gmail integration
  • Memory/storage
  • Image generation with Flux

The bridge translates between the LLM’s outputs and the MCP’s JSON-RPC protocol, allowing any Ollama-compatible model to use these tools just like Claude does.

Current Setup

  • LLM: Using Qwen 2.5 7B (qwen2.5-coder:7b-instruct) through Ollama
  • MCPs:
    • Filesystem operations (@modelcontextprotocol/server-filesystem)
    • Brave Search (@modelcontextprotocol/server-brave-search)
    • GitHub (@modelcontextprotocol/server-github)
    • Memory (@modelcontextprotocol/server-memory)
    • Flux image generation (@patruff/server-flux)
    • Gmail & Drive (@patruff/server-gmail-drive)

Architecture

  • Bridge: Core component that manages tool registration and execution
  • LLM Client: Handles Ollama interactions and formats tool calls
  • MCP Client: Manages MCP server connections and JSON-RPC communication
  • Tool Router: Routes requests to appropriate MCP based on tool type

Key Features

  • Multi-MCP support with dynamic tool routing
  • Structured output validation for tool calls
  • Automatic tool detection from user prompts
  • Robust process management for Ollama
  • Detailed logging and error handling

Setup

  1. Install Ollama and required model:
ollama pull qwen2.5-coder:7b-instruct
  1. Install MCP servers:
npm install -g @modelcontextprotocol/server-filesystem
npm install -g @modelcontextprotocol/server-brave-search
npm install -g @modelcontextprotocol/server-github
npm install -g @modelcontextprotocol/server-memory
npm install -g @patruff/server-flux
npm install -g @patruff/server-gmail-drive
  1. Configure credentials:
    • Set BRAVE_API_KEY for Brave Search
    • Set GITHUB_PERSONAL_ACCESS_TOKEN for GitHub
    • Set REPLICATE_API_TOKEN for Flux
    • Run Gmail/Drive MCP auth: node path/to/gmail-drive/index.js auth
    • For example node C:\Users\patru\AppData\Roaming\npm\node_modules@patruff\server-gmail-drive\dist\index.js auth

Configuration

The bridge is configured through bridge_config.json:

  • MCP server definitions
  • LLM settings (model, temperature, etc.)
  • Tool permissions and paths

Example:

{
  "mcpServers": {
    "filesystem": {
      "command": "node",
      "args": ["path/to/server-filesystem/dist/index.js"],
      "allowedDirectory": "workspace/path"
    },
    // ... other MCP configurations
  },
  "llm": {
    "model": "qwen2.5-coder:7b-instruct",
    "baseUrl": "http://localhost:11434"
  }
}

Usage

  1. Start the bridge:
npm run start
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "filesystem": { "command": "node", "args": ["path/to/server-filesystem/dist/index.js"], "allowedDirectory": "workspace/path" }, // ... other MCP configurations }, "llm": { "model": "qwen2.5-coder:7b-instruct", "baseUrl": "http://localhost:11434" } }