多模型LLM桥接器

LLM Bridge MCP是一个标准化接口服务,允许AI代理通过Message Control Protocol (MCP)无缝访问多种大型语言模型,支持在应用中灵活切换或组合使用不同提供商的模型。

  • by sjquant
  • Python
  • 本地部署
  • 6 星标
  • 更新于
在 GitHub 查看 sjquant/llm-bridge-mcp

使用说明

LLM桥梁MCP

LLM Bridge MCP允许AI代理通过标准化接口与多个大型语言模型进行交互。它利用消息控制协议(MCP)提供对不同LLM提供商的无缝访问,使在模型之间切换或在同一应用程序中使用多个模型变得容易。

特性

  • 与多个LLM提供商的统一接口:
    • OpenAI(GPT模型)
    • 拟人(克劳德模型)
    • 谷歌(双子座车型)
    • 深度求索
    • ...
  • 使用Pydantic AI构建,用于类型安全和验证
  • 支持自定义参数,如温度和最大令牌
  • 提供使用情况跟踪和指标

工具

服务器实现了以下工具:

run_llm(
    prompt: str,
    model_name: KnownModelName = "openai:gpt-4o-mini",
    temperature: float = 0.7,
    max_tokens: int = 8192,
    system_prompt: str = "",
) -> LLMResponse
  • prompt:发送给LLM的文本提示
  • model_name:要使用的特定模型(默认值:“openai:gpt-4o-mini”)
  • temperature:控制随机性(0.0到1.0)
  • max_tokens:要生成的最大令牌数
  • system_prompt:用于指导模型行为的可选系统提示

安装

通过Smithery安装

通过以下方式自动安装Claude Desktop的llm桥mcp 史密瑟里:

npx -y @smithery/cli install @sjquant/llm-bridge-mcp --client claude

手动安装

  1. 克隆存储库:
git clone https://github.com/yourusername/llm-bridge-mcp.git
cd llm-bridge-mcp
  1. 安装 紫外线 (如果尚未安装):
# On macOS
brew install uv

# On Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# On Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"

配置

创建一个 .env 根目录中带有API密钥的文件:

OPENAI_API_KEY=your_openai_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key
GOOGLE_API_KEY=your_google_api_key
DEEPSEEK_API_KEY=your_deepseek_api_key

用法

与克劳德桌面或光标一起使用

将服务器条目添加到Claude Desktop配置文件中,或 .cursor/mcp.json:

"mcpServers": {
  "llm-bridge": {
    "command": "uvx",
    "args": [
      "llm-bridge-mcp"
    ],
    "env": {
      "OPENAI_API_KEY": "your_openai_api_key",
      "ANTHROPIC_API_KEY": "your_anthropic_api_key",
      "GOOGLE_API_KEY": "your_google_api_key",
      "DEEPSEEK_API_KEY": "your_deepseek_api_key"
    }
  }
}

故障排除

常见问题

1.“spawn uvx ENOENT”错误

当系统找不到 uvx 可在PATH中执行。要解决此问题,请执行以下操作:

解决方案:使用uvx的完整路径

查找uvx可执行文件的完整路径:

# On macOS/Linux
which uvx

# On Windows
where.exe uvx

然后更新MCP服务器配置以使用完整路径:

"mcpServers": {
  "llm-bridge": {
    "command": "/full/path/to/uvx",  // Replace with your actual path
    "args": [
      "llm-bridge-mcp"
    ],
    "env": {
      // ... your environment variables
    }
  }
}

许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。