LLM桥接服务

MCP LLM Bridge是一个连接Model Context Protocol (MCP)服务器与OpenAI兼容的LLM(如Ollama)的桥接服务,支持快速配置和本地模型集成。

  • by virajsharma2000
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 virajsharma2000/simple-mcp-ollama-bridge

使用说明

MCP LLM桥

连接模型上下文协议(MCP)服务器和Ollama等OpenAI兼容LLM的桥梁 点击此处阅读更多关于Anthropic的MCP:

快速开始

# Install
curl -LsSf https://astral.sh/uv/install.sh | sh
git clone https://github.com/bartolli/mcp-llm-bridge.git
cd mcp-llm-bridge
uv venv
source .venv/bin/activate
uv pip install -e .


Note: reactivate the environment if needed to use the keys in `.env`: `source .venv/bin/activate`

Then configure the bridge in [src/mcp_llm_bridge/main.py](src/mcp_llm_bridge/main.py)

```python
 mcp_server_params=StdioServerParameters(
            command="uv",
            # CHANGE THIS = it needs to be an absolute directory! add the mcp fetch server at the directory (clone from https://github.com/modelcontextprotocol/servers/)
            args=["--directory", "~/llms/mcp/mc-server-fetch/servers/src/fetch", "run", "mcp-server-fetch"],
            env=None
        ),
        # llm_config=LLMConfig(
        #     api_key=os.getenv("OPENAI_API_KEY"),
        #     model=os.getenv("OPENAI_MODEL", "gpt-4o"),
        #     base_url=None
        # ),
        llm_config=LLMConfig(
            api_key="ollama",  # Can be any string for local testing
            model="llama3.2",
            base_url="http://localhost:11434/v1"  # Point to your local model's endpoint
        ),
)

附加端点支持

该网桥还与实现OpenAI API规范的任何端点一起工作:

没有

llm_config=LLMConfig(
    api_key="not-needed",
    model="mistral-nemo:12b-instruct-2407-q8_0",
    base_url="http://localhost:11434/v1"
)

许可证

麻省理工学院

贡献

PR欢迎。