Model Context Protocol Server with Llama and GitHub Integration

Model Context Protocol Server with Llama and GitHub Integration

site icon
2025.04.05 0
PythonAI 增强GitHub 集成开发效率
mcp-llama-github-integration 是一个基于 Model Context Protocol (MCP) 的服务,集成了本地运行的 Llama 模型和 GitHub 仓库文件列表功能。该服务通过 FastAPI 实现,旨在为 AI 应用提供来自本地 LLM 和 GitHub 仓库的相关信息增强。
View on GitHub

Overview

基本能力

产品定位

mcp-llama-github-integration 是一个集成本地 Llama 模型和 GitHub 仓库文件列表功能的 MCP 服务器,旨在为 AI 应用提供上下文增强。

核心功能

  1. MCP 服务器
  2. 实现 Model Context Protocol
  3. 将查询转发到本地 Llama 模型
  4. 从 GitHub 仓库列出文件
  5. Python 客户端
  6. 提供与 MCP 服务器交互的示例应用

适用场景

  1. AI 应用需要结合本地 LLM 和 GitHub 仓库信息的场景
  2. 开发者在开发过程中需要快速获取 GitHub 仓库文件列表的场景
  3. 需要增强 AI 应用上下文的场景

工具列表

  1. Ollama:用于运行本地 Llama 模型
  2. Git:用于克隆仓库和访问 GitHub API
  3. Python 客户端:用于与 MCP 服务器交互

常见问题解答

  1. Connection Refused Error:确保 Llama 模型在 http://localhost:11434/ 运行,并检查 Ollama 是否正确安装和运行。
  2. GitHub API Errors:检查仓库 URL 是否正确,GitHub API 对未认证请求有速率限制。
  3. GitHub Repository Not Found:确保仓库存在且为公开仓库,私有仓库需要认证(当前版本未实现)。

使用教程

使用依赖

  1. Python 3.7 或更高版本
  2. 运行在 http://localhost:11434/ 的 Llama 模型服务器(如 Ollama)
  3. 用于 GitHub API 访问的互联网连接
  4. 已安装 Git
  5. GitHub 账户

安装教程

  1. 克隆仓库: bash git clone https://github.com/YourUsername/mcp-llama-integration.git cd mcp-llama-integration
  2. 安装依赖: bash pip install -r requirements.txt
  3. 设置 Llama 模型: bash ollama pull llama3.2
  4. 验证模型运行: bash curl http://localhost:11434/api/tags

调试方式

  1. 启动服务器: bash python llama_mcp_server.py
  2. 验证服务器运行: bash curl http://localhost:8000/health
  3. 使用客户端应用: bash python llama_client_app.py
  4. 输入查询或 GitHub 仓库 URL 进行测试。

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。