返回市场
大语言模型桥梁MCP

大语言模型桥梁MCP

作者:sjquant6 星标更新:2025-07-23

项目介绍

LLM Bridge MCP

smithery 徽章

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

<a href="https://glama.ai/mcp/servers/@sjquant/llm-bridge-mcp"> <img width="380" height="200" src="https://gips1.baidu.com/it/u=1761773930,2827461902&fm=3081&app=3_081&f=PNG?w=760&h=400" alt="LLM Bridge MCP 服务器" /> </a>

功能

  • 统一接口连接多个LLM提供商:
    • OpenAI(GPT模型)
    • Anthropic(Claude模型)
    • Google(Gemini模型)
    • DeepSeek
    • ...
  • 使用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安装

要通过Smithery自动安装llm-bridge-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. 安装uv(如果尚未安装):
# 在macOS上
brew install uv

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

# 在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一起使用

在您的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" 错误

当系统无法在PATH中找到uvx可执行文件时会出现此错误。解决方法:

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

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

# 在macOS/Linux上
which uvx

# 在Windows上
where.exe uvx

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

"mcpServers": {
  "llm-bridge": {
    "command": "/full/path/to/uvx",  // 替换为您实际的路径
    "args": [
      "llm-bridge-mcp"
    ],
    "env": {
      // ... 您的环境变量
    }
  }
}

许可证

本项目根据MIT许可证发布 - 查看LICENSE文件获取详情。