MCP Gateway plugin for Py Code Agent - connect MCP servers and expose their tools
Project description
py-code-agent-mcp-gateway
MCP Gateway plugin for Py Code Agent - connect MCP (Model Context Protocol) servers and expose their tools.
Features
- MCP Server Connection: Connect to MCP servers via stdio transport
- Tool Exposure: Automatically expose all MCP server tools as Py Code Agent tools
- Server Management: List and call tools across multiple MCP servers
- Dynamic Discovery: Auto-discover available tools on server initialization
Installation
# Install from PyPI
pip install py-code-agent-mcp-gateway
# Or install with extra dependencies
pip install py-code-agent-mcp-gateway[mcp]
Configuration
In your config.yaml:
plugins:
gateway:
mcp:
servers:
- name: filesystem
command: npx
args: ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"]
enabled: true
- name: brave-search
command: npx
args: ["-y", "@modelcontextprotocol/server-brave-search"]
env:
BRAVE_API_KEY: ${BRAVE_API_KEY}
enabled: true
- name: postgres
command: npx
args: ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:pass@host/db"]
enabled: true
Server Configuration Options
| Option | Type | Description |
|---|---|---|
name |
string | Server name (unique identifier) |
command |
string | Executable command (e.g., npx, node, python) |
args |
list | Command arguments |
env |
dict | Environment variables (supports ${ENV_VAR}) |
transport |
string | Transport type (stdio, http) - default: stdio |
url |
string | URL for HTTP transport |
headers |
dict | HTTP headers |
enabled |
bool | Enable/disable server |
Tools Provided
| Tool | Description |
|---|---|
mcp_list_servers |
List all connected MCP servers and their tools |
mcp_call_tool |
Call a specific MCP tool by server and tool name |
mcp_{server}_{tool} |
Auto-generated tools for each MCP server tool |
Usage
List Servers
> mcp_list_servers
Output:
## filesystem (3 tools)
- mcp_filesystem_read_directory: Read a directory
- mcp_filesystem_read_file: Read a file
- mcp_filesystem_write_file: Write to a file
## brave-search (1 tool)
- mcp_brave-search_search: Search the web
Call Tool Directly
> mcp_call_tool server_name=filesystem tool_name=read_file path="/path/to/file.txt"
Use Auto-generated Tool
> mcp_filesystem_read_file path="/path/to/file.txt"
MCP Servers
This plugin connects to MCP (Model Context Protocol) servers. Popular MCP servers:
@modelcontextprotocol/server-filesystem- File system operations@modelcontextprotocol/server-brave-search- Web search@modelcontextprotocol/server-postgres- PostgreSQL database@modelcontextprotocol/server-github- GitHub operations@modelcontextprotocol/server-slack- Slack integration
Requirements
- Python 3.9+
- Py Code Agent core
- MCP server packages (installed separately)
Troubleshooting
Server fails to initialize
Check that:
- The command (npx, node, etc.) is available
- The MCP server package is installed
- Required environment variables are set
Tools not appearing
MCP tools are discovered when the agent starts. Make sure:
- Server is enabled in config
- Agent has been started after config change
Related Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_code_agent_mcp_gateway-0.1.0.tar.gz.
File metadata
- Download URL: py_code_agent_mcp_gateway-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da059166ef3167416ae306a3d9b1445d09783175583103afc40508f1129742da
|
|
| MD5 |
23e9bbd5433ce4770029d189b5cc1e9c
|
|
| BLAKE2b-256 |
44c4f726fe9884d28c790f9d16672b939672fd535053859899ab304b94eac4b9
|
File details
Details for the file py_code_agent_mcp_gateway-0.1.0-py3-none-any.whl.
File metadata
- Download URL: py_code_agent_mcp_gateway-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88cfc436ad1582fac26f214de4b9846503a4447fe1fb5dc68c80a2060d99f6d2
|
|
| MD5 |
0ae2fdf4375151f9bb16d3eb9d780b56
|
|
| BLAKE2b-256 |
0ee664b9e41c6ffdfe31906595e7ce94e56d060ab102a4a9729b0d1ab44b6b5d
|