Skip to main content
Paste the mcpServers block you already have in Claude Code, Cursor, VS Code, Gemini CLI, Codex, or PraisonAI YAML, and give its tools to an agent. You don’t need to rewrite it as MCP(command=..., args=...).
Import parse_mcp_servers from praisonaiagents.mcp. The top-level praisonaiagents package does not export it.

Which config shapes are accepted?

parse_mcp_servers looks for the servers under mcpServers, servers, mcp_servers, or mcp.servers, in that order. If none of these keys holds a mapping, it treats the whole dict as {name: entry}. An entry can also be a plain command string, such as {"fs": "npx -y @modelcontextprotocol/server-filesystem /tmp"}.

Quick Start

1

Paste an editor config

2

Load every server at once

3

Expand ${VAR} from the environment

4

Codex-style bearer token

How It Works

parse_mcp_servers only changes the shape of the config. It leaves ${VAR} exactly as written. MCP.from_config builds the client, and it also accepts a raw editor entry, so you can skip parse_mcp_servers when you only have one server.

Field mapping

The fields name, description, trust, alwaysAllow, autoApprove, and startup_timeout_sec are dropped without a warning. Any other unknown field is dropped and a warning is logged.

Normalised entry

MCP.from_config parameters

Safety behaviour

A url never runs as a command. If the url is not http(s) or ws(s), MCP.from_config raises ValueError.
Legacy SSE URLs cannot send headers. If a URL ends in /sse and has an Authorization header, a ValueError is raised. Other headers are dropped and a warning is logged. To keep headers on an /sse path, set "type": "streamable-http".
  • Disabled servers ("disabled": true or "enabled": false) raise ValueError when you build them.
  • expand_env=True does not modify your original dict.
  • Leave expand_env off for entries that a loader has already interpolated, so nothing is expanded twice.
  • parse_mcp_servers does not check whether a server is trusted. If you read a project file that someone else wrote, filter it with drop_untrusted_mcp_servers from praisonaiagents.mcp.trust first.

Common Patterns

Best Practices

Write tokens as ${VAR} in your config and pass expand_env=True. That way the secret stays out of the config file.
Legacy SSE cannot send headers. Use a Streamable HTTP URL, or set "type": "streamable-http".
Pass name= so that errors and warnings tell you which server failed.

MCP

The base MCP client and its construction forms

MCP YAML Configuration

Declare MCP servers in YAML workflows