Skip to main content
Glama
llm-fallback-mcp

llm-fallback-mcp

by KhushalB25

llm-fallback-mcp

MCP server that completes prompts with automatic provider fallback across OpenAI, Anthropic Claude, and Google Gemini. Built for production: rate-limit aware, retries on transient failures, transparent attempt log.

MIT License Node ≥ 18 MCP

Why

LLM APIs go down. They rate-limit you. One provider has an outage, the others usually don't. Production LLM apps need fallback. This server gives you the pattern as a single MCP tool.

  • Try OpenAI → Anthropic → Gemini in order (configurable)

  • Each provider retries once on 429 / 5xx / network errors with backoff

  • Return first success with a full per-provider attempt log

  • Skip providers without keys automatically

  • Zero SDK dependencies — calls each provider's REST API directly

Related MCP server: OpenAI-Compatible MCP Gateway

Install

npm install -g llm-fallback-mcp

Or npx:

npx llm-fallback-mcp

Use with Claude Desktop

Add to claude_desktop_config.json (Windows: %APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "llm-fallback": {
      "command": "npx",
      "args": ["-y", "llm-fallback-mcp"],
      "env": {
        "OPENAI_API_KEY": "sk-...",
        "ANTHROPIC_API_KEY": "sk-ant-...",
        "GEMINI_API_KEY": "..."
      }
    }
  }
}

Only set keys for providers you want active. Missing keys = provider skipped.

Tools

complete

Arg

Type

Required

Default

prompt

string

yes

—

chain

string[]

no

["openai", "anthropic", "gemini"]

model_overrides

object

no

—

temperature

number

no

0.5

max_tokens

number

no

1024

health_check

Returns which providers are configured.

Example response

{
  "text": "...",
  "provider_used": "anthropic",
  "model_used": "claude-haiku-4-5-20251001",
  "attempts": [
    { "provider": "openai", "ok": false, "status": 429, "durationMs": 412 },
    { "provider": "anthropic", "ok": true, "durationMs": 1133 }
  ]
}

Local development

git clone https://github.com/KhushalB25/llm-fallback-mcp.git
cd llm-fallback-mcp
npm install
npm run build
OPENAI_API_KEY=sk-... npm start

Author

Khushal Bhandari · GitHub

License

MIT

Available Tools

2 tools
completeA

Complete a prompt with automatic provider fallback. Tries OpenAI -> Anthropic Claude -> Google Gemini in order. Each provider gets one retry on rate limit / 5xx / network errors with backoff. Returns the response, the provider that succeeded, and a full per-provider attempt log. Requires at least one of OPENAI_API_KEY, ANTHROPIC_API_KEY, or GEMINI_API_KEY in the environment.

Inputs: prompt (required), chain, max_tokens, temperature, +1 more.

health_checkA

Return which providers are configured (have their API keys set in the environment) and their default models. Use this to confirm setup before calling 'complete'.

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.7/5.0

    Scored across 2 tools

    Disambiguation5/5

    The two tools have clearly distinct purposes: 'complete' executes the fallback completion logic, while 'health_check' verifies configuration. There is no ambiguity.

    Naming Consistency5/5

    Both tool names use a consistent verb or verb_noun pattern ('complete', 'health_check') with snake_case, making them predictable and readable.

    Tool Count5/5

    With only 2 tools, the server is tightly scoped to its core functionality: configuration check and completion execution. This count is ideal for the domain.

    Completeness5/5

    The tool surface covers all necessary operations for the fallback completion domain: confirming setup and performing the completion. No obvious gaps.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      An MCP server that functions as an intelligent gateway for multiple LLM backends including OpenAI, Claude, and Ollama. It supports automatic provider fallback, streaming responses via Server-Sent Events, and real-time monitoring for robust AI integration.
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Exposes multiple LLM providers (AWS Bedrock, OpenAI, Google Gemini, local Ollama) as MCP tools with automatic routing by task type and Prometheus metrics, enabling any MCP-compatible client to generate text, route prompts, and list providers.
      -
    • F
      license
      A
      quality
      D
      maintenance
      Unified MCP server for querying multiple LLM providers (Gemini, OpenAI, Anthropic, etc.) with advanced routing, cost optimization, and fallback resilience.
      2
      -