Multi-Provider LLM MCP Server

Multi-Provider LLM MCP Server

Unified MCP server for querying multiple LLM providers (Gemini, OpenAI, Anthropic, etc.) with advanced routing, cost optimization, and fallback resilience.

Category
访问服务器

README

Multi-Provider LLM MCP Server

An official Model Context Protocol (MCP) server that exposes a unified, secure routing interface to query multiple Large Language Model (LLM) providers. Built on top of TypeScript, it dynamically integrates with Google Gemini, OpenAI, Anthropic Claude, Cohere, Groq, Mistral AI, and OpenRouter using a modular Strategy Pattern.

This server enables agentic IDE clients (such as Claude Desktop, Cursor, Windsurf, or GitHub Copilot) to switch models dynamically based on task requirements, evaluate model outputs, and optimize API costs.


1. Why This Server? (Key Use Cases)

This MCP server goes beyond basic completions. It empowers your AI assistants with the following advanced capabilities:

🌟 Cross-Model Consensus Code Auditing (Multi-Model Voting)

Security and logic flaws can easily be missed by a single LLM. By invoking the query_llm tool across multiple providers (e.g. OpenAI, Anthropic, Gemini) on the same code snippet, your IDE agent can compare outputs:

  • How it works: The agent sends the same prompt to GPT-4o, Claude 3.5 Sonnet, and Gemini 2.5. If two out of three models flag a potential SQL injection or logic bug, the agent warns you before deploying.

🌟 LLM-as-a-Judge (Automated Quality Evaluation)

Build automated feedback loops inside your workspace:

  • How it works: Model A (OpenAI) writes a function. Model B (Anthropic) generates unit test cases. Model C (Gemini) evaluates both the implementation and test coverage, grading the overall solution and suggesting improvements.

🌟 Fallback Resilience & High-Availability Routing

API rate limits, service-specific outages, or server lag can interrupt automated coding workflows:

  • How it works: If an API call to OpenAI fails or hits a rate limit, the routing service can dynamically catch the error and retry the query with Anthropic or Gemini, keeping your developer loop uninterrupted.

🌟 Cost-Optimized Context Compression (Token Optimization)

LLM costs scale with context size. Sending large files directly to high-reasoning models like Claude 3.5 Sonnet can quickly become expensive:

  • How it works: Send massive logs or document dumps to a fast, cost-efficient model (such as Groq/Llama-3 or Gemini Flash) first. Instruct it to compress the information into a concise summary, and then send that summary to Claude for final refactoring.

🌟 Privacy Redaction & PII Pre-Filtering

When working with sensitive projects, sending raw user data or company secrets directly to closed-source proprietary APIs poses security risks:

  • How it works: Route raw user messages to a local or open-source model (via Groq/Mistral) to redact secrets, keys, or PII (personally identifiable information) before forwarding the sanitized input to external proprietary models.

🌟 Synthetic Dialogue Simulation (Agent-User Mocking)

Testing interactive chatbot features requires realistic dialogues:

  • How it works: Prompt one model (e.g. Mistral) to act as a difficult customer and another (e.g. GPT-4o-mini) to act as the support representative. You can simulate multi-turn chats automatically to test error handling, response times, and chat flows.

2. Architecture & Design Patterns

The server is designed using the Strategy Pattern and a Central Registry to ensure clean separation of concerns and effortless extensibility:

src/
  ├── index.ts              # Transport Bootstrapper
  ├── server.ts             # MCP Tool Definition & Schema Validation
  └── services/
        ├── types.ts        # Common contracts and LLMProvider interface
        ├── llm.ts          # Central Provider Registry
        └── providers/      # Individual Provider Clients (Strategies)
              ├── gemini.ts
              ├── openai.ts
              ├── anthropic.ts
              ├── cohere.ts
              ├── groq.ts
              ├── mistral.ts
              └── openrouter.ts

Every provider implements the LLMProvider contract:

export interface LLMProvider {
  name: string;
  defaultModel: string;
  envKey: string;
  query(params: QueryLLMParams): Promise<QueryLLMResult>;
}

Adding New Providers

To support a new provider, you do not need to modify the server routing logic:

  1. Create a new provider file under src/services/providers/your_provider.ts implementing LLMProvider.
  2. Register it in src/services/llm.ts.

3. Tool Interface

The server registers two primary tools with your MCP client:

1. query_llm

Query any supported LLM provider with a prompt.

  • provider (Required): "gemini" | "openai" | "anthropic" | "cohere" | "groq" | "mistral" | "openrouter".
  • prompt (Required): The input message.
  • apiKey (Optional): API Token. Falls back to environment variables if omitted.
  • model (Optional): Specific model name. Defaults to a sensible model if omitted.
  • systemPrompt (Optional): Guiding system context.
  • temperature (Optional): Controls randomness (0.0 to 2.0).
  • maxTokens (Optional): Max tokens to generate.
  • responseFormat (Optional): "text" (raw completion), "json_object" (strictly JSON), or "detailed" (returns markdown reporting execution time, provider metadata, and token usage).
  • chatHistory (Optional): Array of previous message history objects [{ role: "user" | "assistant", content: "..." }].

2. list_providers

Lists status of all LLM providers, including default models, required environment keys, and if keys are set.


4. Installation & Configurations

Detailed templates for setting up this server in popular IDEs and clients are located in the [sample_mcp_configs](file:///c:/Users/abhi9/Documents/Work/AI%20Projects/llm_mcp/sample_mcp_configs) directory:

  • [Claude Desktop Configuration](file:///c:/Users/abhi9/Documents/Work/AI%20Projects/llm_mcp/sample_mcp_configs/claude_desktop_config.json)
  • [Cursor settings UI Guide](file:///c:/Users/abhi9/Documents/Work/AI%20Projects/llm_mcp/sample_mcp_configs/cursor_settings.json)
  • [Windsurf IDE Configuration](file:///c:/Users/abhi9/Documents/Work/AI%20Projects/llm_mcp/sample_mcp_configs/windsurf_config.json)
  • [GitHub Copilot Configuration](file:///c:/Users/abhi9/Documents/Work/AI%20Projects/llm_mcp/sample_mcp_configs/copilot_config.json)
  • [Configuration Setup Guide](file:///c:/Users/abhi9/Documents/Work/AI%20Projects/llm_mcp/sample_mcp_configs/README.md)

Publishing to NPM

To publish this package publicly under your scope, run:

npm publish --access public

Once published, users can configure their MCP client command to npx with args ["-y", "@abhishek-kumar-00019/llm-mcp-server"].

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选