Use MCP with Any LLM
Pair any MCP connector or server with OpenAI, Anthropic, Google Gemini, Ollama, Groq, OpenRouter, Mistral, or xAI by changing one llm= string
Every PraisonAI MCP connector and server works identically with any supported LLM provider — switch between OpenAI, Anthropic, Google Gemini, local Ollama, Groq, OpenRouter, Mistral, or xAI by changing a single llm= string on Agent(...).
from praisonaiagents import Agent, MCP
agent = Agent(
name="Researcher",
instructions="Use the connected MCP tools to answer accurately.",
llm="anthropic/claude-sonnet-4-20250514", # swap to any provider below
tools=MCP("https://mcp.deepwiki.com/mcp"),
)
agent.start("Explain how MervinPraison/PraisonAI structures its multi-agent workflows")The user swaps only the llm= parameter; PraisonAI translates the MCP server’s tool schemas automatically for whichever model provider runs the agent.
graph LR
User["👤 User"] --> Agent["🤖 PraisonAI Agent"]
Agent --> LLM["🧠 Any LLM Provider<br/>OpenAI · Claude · Gemini · Ollama · Groq"]
Agent <--> MCP["🔌 Any MCP Connector<br/>Remote HTTP · Local STDIO"]
MCP --> Out["✅ Grounded Answer"]
classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
classDef agent fill:#8B0000,stroke:#7C90A0,color:#fff
classDef llm fill:#F59E0B,stroke:#7C90A0,color:#fff
classDef ok fill:#10B981,stroke:#7C90A0,color:#fff
class User input
class Agent agent
class LLM llm
class MCP,Out okQuick Start by Provider
- Install PraisonAI with LLM & MCP support
bash pip install "praisonai[mcp]" - Choose your LLM provider
OpenAI
bash export OPENAI_API_KEY="${OPENAI_API_KEY:?Set OPENAI_API_KEY in your shell}"python from praisonaiagents import Agent, MCP agent = Agent( instructions="Use connected MCP tools to help the user.", llm="openai/gpt-4o", tools=MCP("https://mcp.deepwiki.com/mcp"), ) agent.start("Summarize the architecture of MervinPraison/PraisonAI")Anthropic
bash export ANTHROPIC_API_KEY="${ANTHROPIC_API_KEY:?Set ANTHROPIC_API_KEY in your shell}"python from praisonaiagents import Agent, MCP agent = Agent( instructions="Use connected MCP tools to help the user.", llm="anthropic/claude-sonnet-4-20250514", tools=MCP("https://mcp.deepwiki.com/mcp"), ) agent.start("Summarize the architecture of MervinPraison/PraisonAI")Google Gemini
bash export GEMINI_API_KEY="${GEMINI_API_KEY:?Set GEMINI_API_KEY in your shell}"python from praisonaiagents import Agent, MCP agent = Agent( instructions="Use connected MCP tools to help the user.", llm="gemini/gemini-2.5-flash", tools=MCP("https://mcp.deepwiki.com/mcp"), ) agent.start("Summarize the architecture of MervinPraison/PraisonAI")Ollama (Local / Keyless)
If Ollama is running locally, PraisonAI works with no API key — see Keyless Local-First Run.
bash ollama pull llama3.2python import sys from praisonaiagents import Agent, MCP # Works with remote MCP servers OR local Python / Node.js MCP servers: agent = Agent( instructions="Use connected MCP tools to answer accurately.", llm="ollama/llama3.2", tools=MCP(command=sys.executable, args=["path/to/your/mcp_server.py"]), ) agent.start("Run my local Python MCP tool")Groq
bash export GROQ_API_KEY="${GROQ_API_KEY:?Set GROQ_API_KEY in your shell}"python from praisonaiagents import Agent, MCP agent = Agent( instructions="Use connected MCP tools to help the user.", llm="groq/llama-3.3-70b-versatile", tools=MCP("https://mcp.deepwiki.com/mcp"), ) agent.start("Summarize the architecture of MervinPraison/PraisonAI")OpenRouter
bash export OPENROUTER_API_KEY="${OPENROUTER_API_KEY:?Set OPENROUTER_API_KEY in your shell}"python from praisonaiagents import Agent, MCP agent = Agent( instructions="Use connected MCP tools to help the user.", llm="openrouter/openai/gpt-4o-mini", tools=MCP("https://mcp.deepwiki.com/mcp"), ) agent.start("Summarize the architecture of MervinPraison/PraisonAI")Mistral
bash export MISTRAL_API_KEY="${MISTRAL_API_KEY:?Set MISTRAL_API_KEY in your shell}"python from praisonaiagents import Agent, MCP agent = Agent( instructions="Use connected MCP tools to help the user.", llm="mistral/mistral-large-latest", tools=MCP("https://mcp.deepwiki.com/mcp"), ) agent.start("Summarize the architecture of MervinPraison/PraisonAI")xAI (Grok)
bash export XAI_API_KEY="${XAI_API_KEY:?Set XAI_API_KEY in your shell}"python from praisonaiagents import Agent, MCP agent = Agent( instructions="Use connected MCP tools to help the user.", llm="xai/grok-3-mini", tools=MCP("https://mcp.deepwiki.com/mcp"), ) agent.start("Summarize the architecture of MervinPraison/PraisonAI")
Provider Requirements at a Glance
| Provider | Model Prefix | Environment Variable | Local / Offline? |
|---|---|---|---|
| OpenAI | openai/... | OPENAI_API_KEY | No |
| Anthropic | anthropic/... | ANTHROPIC_API_KEY | No |
| Google Gemini | gemini/... | GEMINI_API_KEY | No |
| Ollama | ollama/... | None (local server) | Yes |
| Groq | groq/... | GROQ_API_KEY | No |
| OpenRouter | openrouter/... | OPENROUTER_API_KEY | No |
| Mistral | mistral/... | MISTRAL_API_KEY | No |
| xAI (Grok) | xai/... | XAI_API_KEY | No |
Best Practices
Use tool-calling capable models for MCP
Choose models with reliable function/tool calling (for example gpt-4o, claude-sonnet-4, gemini-2.5-flash, or ollama/llama3.2 / qwen2.5). Smaller base models without tool-calling support may ignore MCP tool schemas.
Keep your LLM API key out of MCP subprocess env
Pass your LLM key in your shell environment for Agent(...) — only pass service-specific tokens (like SLACK_BOT_TOKEN or DATABASE_URL) inside MCP(..., env={...}).
Run 100% locally with Ollama + local STDIO MCP
Pair llm="ollama/llama3.2" with local STDIO connectors like Filesystem Connector or PostgreSQL Connector so neither prompts nor tool data ever leave your machine.