MCPLoader
MCPLoader is a small helper module that lets you define and consume multiple MCP servers (stdio, SSE, or Streamable HTTP) from a JSON configuration. It uses pydantic-ai MCP clients and validates configuration with Pydantic models.
Features
- HTTP (SSE / Streamable HTTP) and STDIO server types
- Configuration validation with Pydantic
- Multiple MCP servers from a single JSON file
- Simple Python API: pass a config path, get ready-to-use server clients
Installation
Use it as a module inside your own codebase. Required dependencies:
pip install mcploader
or
uv add mcploader
Quick start
from mcploader import MCPServerManager
# Provide your configuration file path (e.g., config/http.json or data/mcp/http.json)
manager = MCPServerManager("config/http.json")
servers = manager.servers # serialized list of MCPServer
from pydantic_ai import Agent
agent = Agent('openai:gpt-4o', toolsets=servers)
async def main():
async with agent:
await agent.run('Ask something here...')
import asyncio
if __name__ == '__main__':
asyncio.run(main())
Configuration
Configuration is a JSON object with a root key mcpServers. Each key under mcpServers is a server name; the value is its configuration.
General schema
{
"mcpServers": {
"<serverName>": { ... }
}
}
Each server can be one of two forms:
- STDIO:
StdioServerParameters - HTTP:
ServerParameters(contains atransportbody)
HTTP (SSE / Streamable HTTP) example
{
"mcpServers": {
"server1": {
"transport": {
"type": "streamable-http", // or "sse"
"url": "http://127.0.0.1:8000/mcp",
"headers": {
"Authorization": "Bearer your-token-here",
"Content-Type": "application/json",
"User-Agent": "Claude-Desktop/1.0",
"X-API-Version": "v1"
},
"timeout": 30000,
"readTimeout": 300000,
"maxRetries": 5
}
}
}
}
type is normalized to lowercase and must be one of:
ssestreamable-http
STDIO example
{
"mcpServers": {
"server1": {
"command": "deno",
"args": ["run", "-N", "-R=node_modules", "-W=node_modules", "--node-modules-dir=auto", "jsr:@pydantic/mcp-run-python", "stdio"],
"env": { "OPENAI_API_KEY": "..." },
"cwd": "/usr/path/to",
"timeout": 10,
"readTimeout": 300,
"maxRetries": 3
}
}
}
Fields and types (summary)
- HTTP (ServerParameters.transport: ServerBody)
- type:
"sse" | "streamable-http" - url: a valid URL
- headers:
dict[str, str](optional) - timeout: request timeout in ms (default 30000)
- readTimeout: read timeout in ms (default 300000)
- maxRetries: retry count (default 5)
- type:
- STDIO (StdioServerParameters)
- command: command to execute (e.g.,
deno,python) - args: command arguments (list)
- env: environment variables (key/value)
- cwd: working directory (optional)
- timeout: timeout in seconds (default 30)
- readTimeout: read timeout in seconds (default 300)
- maxRetries: retry count (default 1)
- command: command to execute (e.g.,
Note:
ServerParameters.server_typedefaults to"http",StdioServerParameters.server_typedefaults to"io". These are used internally to select the proper client.
Folder layout
This repository includes sample configurations under data/.
-
data/http.json: Streamable HTTP example -
data/sse.json: SSE example -
data/stdio.json: STDIO example -
Passing paths: Provide the absolute/relative path directly to
MCPServerManager, e.g.,MCPServerManager("data/mcp/http.json"). -
Schema: JSON files under
data/use the same schema; the root must havemcpServers, each key defining a server. -
Environment variants: You can create
data/mcp/prod/http.json,data/mcp/dev/http.json, etc., and select the appropriate file at runtime.
API surface
MCPServerManager(config_path: str): Reads the JSON config and validates it withServerConfig.MCPServerManager.servers -> list[MCPServer]: On first access, creates MCP clients (MCPServerSSE,MCPServerStreamableHTTP,MCPServerStdio) according to the config and caches them.
Feel free to reach me from contact@tomris.dev or my GitHub address.
Metadata
Release files for mcploader 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcploader-0.1.0.tar.gz | 4.7 kB | Without provenance | Details for mcploader-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcploader-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for mcploader-0.1.0-py3-none-any.whl |
Total release size: 10.0 kB
Release files / mcploader-0.1.0.tar.gz
| Download URL | mcploader-0.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5697427786c281092e49d6bce6a7a77295e62c52f427ae8ebdf46683ae01fe86
|
|
BLAKE2b-256 checksum How to use checksums |
1f31699cbbd1dc8133a56dfd8b66486a460147e45bda430b8b931d8e68dd4907
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Release files / mcploader-0.1.0-py3-none-any.whl
| Download URL | mcploader-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfc93d47aafa164c13a36a82beaa069715db2641968dca699b6c54861d620ea7
|
|
BLAKE2b-256 checksum How to use checksums |
d0a3927c9d3a7b252c7882599af5720c1d9935faa05d90fbe558fa79f86b7db7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.7
|
Security for mcploader 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.