AI模型交互代理

一个集成Model Context Protocol(MCP)服务器和Ollama的AI模型交互代理,支持通过统一接口与多种工具进行交互。

  • by ausboss
  • TypeScript
  • 本地部署
  • 30 星标
  • 更新于
在 GitHub 查看 ausboss/mcp-ollama-agent

使用说明

带有Ollama集成的TypeScript MCP代理

该项目展示了 模型上下文协议(MCP) 服务器和 没有,允许AI模型通过统一的界面与各种工具进行交互。

✨ 特性

  • 支持多个MCP服务器(uvx和npx都经过测试)
  • 内置对文件系统操作和web研究的支持
  • 通过以下方式轻松配置 mcp-config.json 类似于 claude_desktop_config.json
  • 交互式聊天界面与Ollama集成,应支持任何工具
  • 独立演示模式,用于测试没有LLM的web和文件系统工具

🚀 入门指南

  1. 先决条件:

    • Node.js(版本18或更高)

    • Ollama已安装并正在运行

    • 全局安装要使用的MCP工具:

      # For filesystem operations
      npm install -g @modelcontextprotocol/server-filesystem
      
      # For web research
      npm install -g @mzxrai/mcp-webresearch
      
  2. 克隆并安装:

    git clone https://github.com/ausboss/mcp-ollama-agent.git
    cd mcp-ollama-agent
    npm install
    
    
  3. 在中配置您的工具和工具支持的Olama模型 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. 运行演示以测试没有LLM的文件系统和webresearch工具:

    npx tsx ./src/demo.ts
    
  5. 或者启动与Ollama的聊天界面:

    npm start
    

⚙️ 配置

  • MCP服务器: 将任何兼容MCP的服务器添加到 mcpServers 章节
  • 没有 : 配置主机和型号(必须支持函数调用)
  • 支持Python(uvx)和Node.js(npx)MCP服务器

💡 示例用法

这个例子使用了这个模型 qwen2.5:最新

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.

系统提示

一些本地模型可能需要工具选择方面的帮助。在中自定义系统提示 ChatManager.ts 以提高工具的使用率。

🤝 贡献

欢迎投稿!请随时提交问题或拉取请求。