Integrations
Provides Bash command execution tools for Linux environments, allowing execution of shell commands through the MCP interface.
Offers Bash command execution capabilities for macOS, enabling shell command execution through the MCP interface.
Supports integration with Node.js-based MCP servers like Playwright MCP through the stdio connection type.
MCP Gateway
English | 简体中文
License
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for more details.
Project Overview
MCP Gateway is an application built with Python. It acts as a central gateway that connects to and aggregates capabilities from multiple backend MCP servers (whether they communicate via Stdio or SSE protocols). Ultimately, it exposes these aggregated capabilities to upstream MCP clients through a unified SSE endpoint (/sse
).
Core Advantages:
- Simplified Client Configuration: MCP clients only need to connect to the single address of the MCP Gateway to access the functionalities of all backend services, eliminating the need to configure each backend server individually.
- Capability Aggregation & Orchestration: Aggregates MCP tools with diverse capabilities from various sources, providing a foundation for building more powerful, customized agents focused on specific task domains.
Project File Structure
Built-in MCP Servers
This project comes with four backend MCP Server tools that can be used directly and enabled in config.json
without additional configuration:
- Bash Command Execution Tool (
bash_server.py
): Executes Bash commands in Linux, macOS, or WSL environments. - Windows CMD Command Execution Tool (
cmd_server.py
): Executes CMD commands in Windows environments. - Windows PowerShell Command Execution Tool (
powershell_server.py
): Executes PowerShell commands in Windows environments. - Windows WMI Query Tool (
wmi_server.py
): Executes WMI queries in Windows environments.
If you encounter the following error in a Linux environment:
CopyPlease uninstall the
wmi
module:uv remove wmi
Installation and Setup
This project is written in Python. Using uv
for environment and dependency management is recommended.
- Clone RepositoryCopy
- Create and Activate Virtual EnvironmentCopy
- Install DependenciesCopy
After completing these steps, the project is ready to run.
Quick Start
Get Project Help
You can use the -h
or --help
argument to view all available startup options:
The output will be similar to this:
Start the Project
Use uv run python main.py
to start the server. You can specify the host
, port
, and log-level
:
After starting, you will see a Rich beautified console output similar to the image below, showing the server status, connection information, and loaded tools:
MCP Client Connection
After starting MCP Gateway, you can use any MCP-compatible client (such as Cline, Cursor, Claude Desktop, or a custom client) to connect to the SSE endpoint provided by the Gateway.
The default address is http://<Server_IP_Address>:9000/sse
(if using the default port).
Example (Using ChatWise Connect):
- Select
SSE
connection type. - Enter the Gateway's SSE URL (e.g.,
http://127.0.0.1:9000/sse
). - Click
Connect
.
After a successful connection, you can see all backend MCP tools aggregated through the Gateway in the client:
Logs
Runtime logs are automatically saved in the logs
folder in the project root directory. Log filenames include timestamps and log levels, making it easy to trace issues.
Configuration File (config.json
)
The core configuration file config.json
is located in the project root directory. It defines the backend MCP servers that MCP Gateway needs to connect to and manage.
Each entry represents a backend server. The key is the unique name you assign to that backend server (this name will be used as the prefix for its capabilities), and the value is an object containing the server's configuration.
Two types of backend server connections are supported:
stdio
: Communicates with a locally started MCP server process via standard input/output (stdin/stdout).sse
: Communicates with a remote or locally running MCP server via the Server-Sent Events (SSE) protocol.
Stdio Type Configuration
Suitable for local MCP server processes whose lifecycle needs to be managed by the Gateway.
Configuration Fields:
type
(required): Must be"stdio"
.command
(required): The executable command used to start the server process (e.g.,python
,uv
,node
, or the absolute path to a script/executable).args
(required): A list of arguments (List of strings) passed to thecommand
.env
(optional): A dictionary of environment variables (Dict[str, str]) to set for the child process. If omitted, the child process inherits the Gateway's environment.
Example:
How it Works: When MCP Gateway starts, it uses the specified command
and args
(along with optional env
) to launch a child process. The Gateway communicates with the backend MCP server through this child process's standard input and output. When the Gateway shuts down, it attempts to terminate these child processes.
SSE Type Configuration
Suitable for connecting to already running MCP servers (local or remote), or cases where the Gateway needs to start a local SSE server process before connecting.
Configuration Fields:
type
(required): Must be"sse"
.url
(required): The SSE endpoint URL of the backend MCP server (full HTTP/HTTPS address).command
(optional): If specified, the Gateway will run this command at startup to launch the local SSE server.args
(optional, only whencommand
is specified): A list of arguments passed to thecommand
.env
(optional, only whencommand
is specified): Environment variables to set for the locally launched child process.
Example 1: Connecting to an already running remote SSE server
Example 2: Gateway starts a local SSE server and connects
How it Works:
- Only
url
provided: The Gateway directly attempts to connect to the specifiedurl
. url
,command
,args
provided: The Gateway first usescommand
andargs
to start a local process (expecting this process to listen on the address and port corresponding tourl
). It then waits for a short period (LOCAL_SSE_STARTUP_DELAY
defined inclient_manager.py
) before attempting to connect to theurl
. When the Gateway shuts down, it attempts to terminate this local process.
Configuration Addition Examples
Here are examples of how to add third-party MCP servers to config.json
.
Stdio Example: Playwright MCP
Suppose you want to integrate Playwright's MCP server (@playwright/mcp
).
- Understand Startup Method: Playwright MCP is typically started using
npx @playwright/mcp@latest
. This is a Node.js package executed vianpx
. - Configure
config.json
:Here,Copycommand
isnpx
, andargs
contains the Playwright MCP package name and version. - Restart Gateway: Save
config.json
and restart MCP Gateway.
After starting, you should see tools named playwright/...
(e.g., playwright/browse
) in the console logs and your client.
SSE Example: ENScan_GO (Local Start)
Suppose you want to integrate ENScan_GO, a Go program that can be started with ./enscan --mcp
and provides an SSE service at http://localhost:8080
.
- Get Executable File: Download the ENScan_GO executable (e.g.,
enscan-v1.2.1-windows-amd64.exe
) and place it in an accessible location (e.g., theservers/
directory or in your system PATH). - Configure
config.json
:Here, we specifyCopytype
assse
, provide theurl
it listens on, and usecommand
andargs
to tell the Gateway how to start this local SSE server. - Restart Gateway: Save
config.json
and restart MCP Gateway.
The Gateway will first start the ENScan_GO process, then connect to http://127.0.0.1:8080/sse
. After starting, you should see tools named enscan/...
.
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
MCP-Gateway