A smart Agent-to-Server Bridge connecting AI agents to remote environments as an MCP server and REST API.
Project description
Gangway
A smart Agent-to-Server Bridge connecting AI agents (like Cursor and Claude Desktop) to remote environments (VPS, Kaggle, Colab) for full control, functioning as both an MCP server and a REST API.
Features
- Directory State Management: Maintains and tracks the active working directory (CWD) across execution contexts, resolving relative paths and enforcing sandbox directory checks (
allowed_root) to prevent path traversal. - Background Job Control: Execute long-running shell commands asynchronously. Captures logs (
stdoutandstderr) to disk. Supports recursive process tree termination (on Unix and Windows) and prevents PID recycling exploits. - Robust MCP Server: Provides standard
stdiotransport andSSE(Server-Sent Events) HTTP transport modes using Starlette and Uvicorn. - Bearer Token Authentication: Enforces token authentication case-insensitively in headers or query parameters for SSE transport.
- Zero-Dependency Core: Leverages the low-level
mcplibrary, standard libraries,starlette,uvicorn,psutil, andtomli.
Installation
Install from your local build or PyPI:
pip install gangway
Run with uvx (No Installation Required)
You can run Gangway as an MCP server instantly without installing it globally using uvx:
uvx gangway --transport stdio --token YOUR_SECRET_TOKEN --allowed-root /path/to/sandbox
Configuration
Gangway can be configured via Environment Variables, JSON/TOML configuration files, or CLI arguments (CLI arguments take the highest precedence).
Configuration Parameters
| CLI Argument | Environment Variable | Configuration Key | Default | Description |
|---|---|---|---|---|
--token |
GANGWAY_TOKEN |
token |
None |
Bearer token required for authentication. |
--allowed-root |
GANGWAY_ALLOWED_ROOT |
allowed_root |
None |
Limit directory interactions to this root path. |
--port |
GANGWAY_PORT |
port |
8000 |
Port to run the SSE web server on. |
--host |
GANGWAY_HOST |
host |
127.0.0.1 |
Host address to bind the SSE server to. |
--transport |
- | - | stdio |
Transport mode (stdio or sse). |
CLI Usage
To run the server using stdio transport:
# If installed globally:
gangway --transport stdio --token secret-token --allowed-root /path/to/sandbox
# Or run instantly with uvx:
uvx gangway --transport stdio --token secret-token --allowed-root /path/to/sandbox
To run the server using sse transport:
# If installed globally:
gangway --transport sse --host 127.0.0.1 --port 8000 --token secret-token --allowed-root /path/to/sandbox
# Or run instantly with uvx:
uvx gangway --transport sse --host 127.0.0.1 --port 8000 --token secret-token --allowed-root /path/to/sandbox
Using a configuration file:
# If installed globally:
gangway --config /path/to/config.toml --transport sse
# Or run instantly with uvx:
uvx gangway --config /path/to/config.toml --transport sse
Register in AI Clients (Claude Desktop / Cursor)
Claude Desktop
Add the following to your claude_desktop_config.json (usually located at %APPDATA%\Claude\claude_desktop_config.json on Windows or ~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"gangway": {
"command": "uvx",
"args": [
"gangway",
"--transport", "stdio",
"--token", "YOUR_SECRET_TOKEN",
"--allowed-root", "/path/to/sandbox"
]
}
}
}
Cursor / VSCode
- Open Cursor Settings -> Features -> MCP.
- Click + Add New MCP Server.
- Enter:
- Name:
gangway - Type:
command - Command:
uvx gangway --transport stdio --token YOUR_SECRET_TOKEN --allowed-root /path/to/sandbox
- Name:
Exposed MCP Tools
Gangway exposes 16 tools to connecting AI agents:
File Operations
list_directory: Lists directory contents, returning file size and modification time.glob_search: Performs recursive file searches using glob patterns.preview_file: Safely previews a file by returning the firstNlines and lastMlines, avoiding token pollution.project_overview: Scans files up to depth 3, lists the 10 most recently modified files, and readsREADME.md.upload_chunk: Uploads base64-encoded file chunks for remote storage.assemble_upload: Assembles uploaded file chunks into a single file.download_chunk: Downloads a chunk of a remote file.compress_archive: Compresses a target directory into a.zip,.tar.gz, or.tgzarchive.extract_archive: Extracts a.zipor.tar.gzarchive to a target directory.
Directory State
get_working_directory: Returns the current active working directory (CWD).change_working_directory: Changes the active working directory (validates against allowed root).
Background Jobs
start_background_job: Spawns a command asynchronously in the background.get_job_status: Gets metadata, exit code, and run status of a job.list_background_jobs: Lists all background jobs sorted chronologically.read_job_logs: Previews logs for a specific background job.kill_background_job: Recursively kills a background job's process tree.
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
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 gangway-0.1.2.tar.gz.
File metadata
- Download URL: gangway-0.1.2.tar.gz
- Upload date:
- Size: 115.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c510ffe017eb91ec539d18b7656ed02b530119cfaed9bf922f6dac14b0e77851
|
|
| MD5 |
341c5475086df580e4db2ad73004821e
|
|
| BLAKE2b-256 |
5c00ee9c0fc0ecc108c33d0379f14132fc880d7232c3c139ad964d678740e835
|
File details
Details for the file gangway-0.1.2-py3-none-any.whl.
File metadata
- Download URL: gangway-0.1.2-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01acf233c160187f52a96a8d2371733699bd8cfd3a8013d863affc2b0522fb50
|
|
| MD5 |
0bdde6a4935f071439188b28955fdc55
|
|
| BLAKE2b-256 |
fc2562d3631e64a320ae6bb641426cb5e56b3dff94bfddf9efab99a8b5a509a1
|