AM

ausboss/mcp-ollama-agent

开发工具

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

30 stars 13 forks 质量 54 趋势 0

这是一个 TypeScript 示例,展示了 Ollama 与模型上下文协议(MCP)服务器的集成。

概览

该项目展示了模型上下文协议(MCP)服务器与 Ollama 之间的集成,使 AI 模型能够通过统一界面与各种工具交互。 - 支持多台 MCP 服务器(包括经过 UVX 和 NPX 测试)- 内置支持文件系统操作和网页研究 - 通过 mcp-config.json 进行易于配置,类似于 claude_desktop_config.json - 交互式聊天界面,支持 Ollama 集成,支持任何工具 - 独立演示模式,用于测试无需大型语言模型的网页和文件系统工具 - Node.js(版本18及以上)- Ollama 已安装并运行 - 全局安装你想使用的 MCP 工具: - 将任何兼容MCP的服务器添加到mcpServers部分- 配置主机和型号(必须支持函数调用)- 支持Python(uvx)和Node.js(npx)MCP服务器 本示例使用了qwen2.5:latest 部分本地模型可能需要工具选择帮助。在 ChatManager 中自定义系统提示。

概述(AI 翻译)

该项目展示了模型上下文协议(MCP)服务器与 Ollama 之间的集成,使 AI 模型能够通过统一界面与各种工具交互。

✨ 特色

  • 支持多台MCP服务器(包括UVX和NPX测试)
  • 内置文件系统操作和网页研究支持
  • 通过mcp-config.json进行简易配置,类似于claude_desktop_config.json
  • 带有 Ollama 集成的交互式聊天界面,应支持任何工具
  • 独立演示模式,用于测试无LLM的网页和文件系统工具

🚀 开始

  1. 先修条件:
  • Node.js(版本18或更高)
  • 安装并运行的 Ollama
  • 全局安装您想使用的MCP工具:
  1. 克隆并安装:

  2. 在mcp-config.json: 配置你的工具和支持工具的Ollama模型

  3. 运行演示以测试没有LLM的文件系统和网络研究工具:

  4. 或者用Ollama开始聊天界面:

⚙️ 配置

  • MCP 服务器: 将任何兼容 MCP 的服务器添加到 mcpServers 部分
  • Ollama: 配置主机和模型(必须支持函数调用)
  • 支持Python(UVX)和Node。

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

README

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

TypeScript MCP Agent with Ollama Integration

This project demonstrates integration between Model Context Protocol (MCP) servers and Ollama, allowing AI models to interact with various tools through a unified interface.

✨ Features

  • Supports multiple MCP servers (both uvx and npx tested)
  • Built-in support for file system operations and web research
  • Easy configuration through mcp-config.json similar to claude_desktop_config.json
  • Interactive chat interface with Ollama integration that should support any tools
  • Standalone demo mode for testing web and filesystem tools without an LLM

🚀 Getting Started

  1. Prerequisites:

    • Node.js (version 18 or higher)

    • Ollama installed and running

    • Install the MCP tools globally that you want to use:

      # For filesystem operations
      npm install -g @modelcontextprotocol/server-filesystem
      
      # For web research
      npm install -g @mzxrai/mcp-webresearch
      
  2. Clone and install:

    git clone https://github.com/ausboss/mcp-ollama-agent.git
    cd mcp-ollama-agent
    npm install
    
    
  3. Configure your tools and tool supported Ollama model in mcp-config.json:

    {
      "mcpServers": {
        "filesystem": {
          "command": "npx",
          "args": ["@modelcontextprotocol/server-filesystem", "./"]
        },
        "webresearch": {
          "command": "npx",
          "args": ["-y", "@mzxrai/mcp-webresearch"]
        }
      },
      "ollama": {
        "host": "http://localhost:11434",
        "model": "qwen2.5:latest"
      }
    }
    
  4. Run the demo to test filesystem and webresearch tools without an LLM:

    npx tsx ./src/demo.ts
    
  5. Or start the chat interface with Ollama:

    npm start
    

⚙️ Configuration

  • MCP Servers: Add any MCP-compatible server to the mcpServers section
  • Ollama: Configure host and model (must support function calling)
  • Supports both Python (uvx) and Node.js (npx) MCP servers

💡 Example Usage

This example used this model qwen2.5:latest

Chat started. Type "exit" to end the conversation.
You: can you use your list directory tool to see whats in test-directory then use your read file tool to read it to me?
Model is using tools to help answer...
Using tool: list_directory
With arguments: { path: 'test-directory' }
Tool result: [ { type: 'text', text: '[FILE] test.txt' } ]
Assistant:
Model is using tools to help answer...
Using tool: read_file
With arguments: { path: 'test-directory/test.txt' }
Tool result: [ { type: 'text', text: 'rosebud' } ]
Assistant: The content of the file `test.txt` in the `test-directory` is:
rosebud
You: thanks
Assistant: You're welcome! If you have any other requests or need further assistance, feel free to ask.

System Prompts

在 GitHub 查看完整 README

安装

npx @modelcontextprotocol/server-filesystem ./
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "filesystem": { "command": "npx", "args": ["@modelcontextprotocol/server-filesystem", "./"] }, "webresearch": { "command": "npx", "args": ["-y", "@mzxrai/mcp-webresearch"] } }, "ollama": { "host": "http://localhost:11434", "model": "qwen2.5:latest" } }