Skip to main content

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:

  1. The command (npx, node, etc.) is available
  2. The MCP server package is installed
  3. Required environment variables are set

Tools not appearing

MCP tools are discovered when the agent starts. Make sure:

  1. Server is enabled in config
  2. Agent has been started after config change

Related Links

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

py_code_agent_mcp_gateway-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

py_code_agent_mcp_gateway-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for py_code_agent_mcp_gateway-0.1.0.tar.gz
Algorithm Hash digest
SHA256 da059166ef3167416ae306a3d9b1445d09783175583103afc40508f1129742da
MD5 23e9bbd5433ce4770029d189b5cc1e9c
BLAKE2b-256 44c4f726fe9884d28c790f9d16672b939672fd535053859899ab304b94eac4b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for py_code_agent_mcp_gateway-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88cfc436ad1582fac26f214de4b9846503a4447fe1fb5dc68c80a2060d99f6d2
MD5 0ae2fdf4375151f9bb16d3eb9d780b56
BLAKE2b-256 0ee664b9e41c6ffdfe31906595e7ce94e56d060ab102a4a9729b0d1ab44b6b5d

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