Skip to main content

Let your MCP-aware agent consult rival LLMs (OpenAI, Gemini, Anthropic, Grok) mid-conversation.

Project description

mcp-second-opinion

Let your MCP-aware agent consult rival LLMs mid-conversation. One simple MCP server, four providers — OpenAI, Google Gemini, Anthropic, xAI/Grok — unified behind two tools.

Install

pip install mcp-second-opinion

or with uv:

uv add mcp-second-opinion

Configure

Set at least one of these environment variables:

Variable Provider
OPENAI_API_KEY OpenAI
GEMINI_API_KEY Google Gemini
ANTHROPIC_API_KEY Anthropic
XAI_API_KEY xAI/Grok

Providers without a key set are gracefully disabled — they appear in panel responses with a friendly error field rather than crashing the server.

Optional:

Variable Default Purpose
MCP_SECOND_OPINION_PROFILE flagship flagship | balanced | cheap — controls which model each provider uses in ask_the_panel.
MCP_SECOND_OPINION_SELF_SKIP unset Provider key to omit from panel (openai, gemini, anthropic, grok). Useful when the host is itself one of the panelists.
MCP_SECOND_OPINION_TIMEOUT 30 Per-provider timeout in seconds.
MCP_SECOND_OPINION_MAX_TOKENS 2048 Cap on rival output length.

Register with your MCP client

Claude Desktop / Claude Code (mcp_settings.json or equivalent):

{
  "mcpServers": {
    "second-opinion": {
      "command": "mcp-second-opinion",
      "env": {
        "OPENAI_API_KEY": "sk-...",
        "GEMINI_API_KEY": "...",
        "ANTHROPIC_API_KEY": "...",
        "XAI_API_KEY": "..."
      }
    }
  }
}

Tools

ask_other_model(question, model, context?, system_prompt?)

Ask one specific rival.

question:      "is this regex correct? /^[a-z]+$/"
model:         "gpt-5" | "gemini-2.5-pro" | "claude-opus-4-7" | "grok-4" | ...
context:       optional — code snippets, prior reasoning, files
system_prompt: optional — persona/framing

Returns:

{
  "answer": "...",
  "model": "gpt-5",
  "latency_ms": 842,
  "tokens": {"input": 47, "output": 92},
  "cost_usd": 0.0014
}

ask_the_panel(question, context?, system_prompt?)

Fan out to every enabled provider in parallel.

question:      "what's wrong with this approach?"
context:       optional
system_prompt: optional — applied uniformly to all panelists

Returns:

{
  "responses": {
    "openai":    {"answer": "...", "model": "gpt-5", "latency_ms": 800, "cost_usd": 0.001, "error": null},
    "gemini":    {"answer": "...", "model": "gemini-2.5-pro", "latency_ms": 750, "cost_usd": 0.0008, "error": null},
    "anthropic": {"answer": null, "model": "claude-opus-4-7", "error": "skipped (self)"},
    "grok":      {"answer": null, "model": "grok-4", "error": "XAI_API_KEY not set"}
  },
  "total_cost_usd": 0.0018,
  "total_latency_ms": 800
}

How it works

The server is a thin layer over LiteLLM, which provides a unified OpenAI-shaped interface to all four providers. Cost calculation comes from LiteLLM's pricing table.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_second_opinion-0.1.0.tar.gz (222.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_second_opinion-0.1.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file mcp_second_opinion-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_second_opinion-0.1.0.tar.gz
  • Upload date:
  • Size: 222.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mcp_second_opinion-0.1.0.tar.gz
Algorithm Hash digest
SHA256 77fe62655bd752631d2fedffe9cc1d2944f7543c4eaa61e610a5dfc2c9a89c4f
MD5 afec53aa3000553079c83d46bf3807c0
BLAKE2b-256 0643a0aad2663d31657b9788dac79f748e9ee065e301a56e612d4b2109c62429

See more details on using hashes here.

File details

Details for the file mcp_second_opinion-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_second_opinion-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for mcp_second_opinion-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0cac42c840cd728f9b47256752c6149b90fd616b71ee32f9f8d450dfe249ab3
MD5 d24c7005e93c22fd24d59a71eb402642
BLAKE2b-256 40945cfcf371046f4361b51016256d7709f64d3ef202e0e9a0d4df4beacc3c37

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page