Skip to main content

A lightweight remote command execution bridge client with MCP integration

Project description

Castrel Bridge Proxy

CI License: MIT Python Version

A lightweight remote command execution bridge client that connects to a server via WebSocket to receive and execute commands, with MCP (Model Context Protocol) integration.

✨ Features

  • Secure Pairing: Pair with server using verification codes
  • Persistent Configuration: Configuration saved in ~/.castrel/config.yaml
  • Unique Identifier: Generate stable client ID based on machine characteristics
  • WebSocket Connection: Real-time bidirectional communication
  • Command Execution: Execute shell commands with whitelist security
  • Document Operations: Read, write, and edit files remotely
  • Auto Reconnect: Automatically reconnect when connection is lost
  • Timeout Control: Command execution timeout protection
  • MCP Integration: Connect to local MCP services and sync tools information

📦 Installation

Via pip

pip install castrel-proxy

From source

git clone https://github.com/castrel-ai/castrel-bridge-proxy.git
cd castrel-bridge-proxy
pip install -e .

🚀 Quick Start

1. Pair with Server

castrel-proxy pair <verification_code> <server_url>

Example:

castrel-proxy pair eyJ0cyI6MTczNTA4ODQwMCwid2lkIjoiZGVmYXVsdCIsInJhbmQiOiIxMjM0NTYifQ https://server.example.com

2. Start Bridge Service

# Run in background (default)
castrel-proxy start

# Run in foreground
castrel-proxy start --foreground

# Press Ctrl+C to stop (foreground mode only)

3. Stop Bridge Service

# Stop background daemon
castrel-proxy stop

4. Check Status

castrel-proxy status

5. View Logs

# View last 50 lines (default)
castrel-proxy logs

# View last 100 lines
castrel-proxy logs -n 100

# Follow logs in real-time
castrel-proxy logs -f

📖 Documentation

🔧 Configuration

Bridge Configuration (~/.castrel/config.yaml)

Pairing information is saved automatically:

server_url: "https://server.example.com"
verification_code: "ABC123"
client_id: "a1b2c3d4e5f6"
workspace_id: "default"
paired_at: "2025-12-22T10:30:00Z"

MCP Configuration (~/.castrel/mcp.json)

Configure MCP services (optional):

{
  "mcpServers": {
    "filesystem": {
      "transport": "stdio",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"],
      "env": {}
    }
  }
}

See examples/mcp.json.example for more examples.

Command Whitelist (~/.castrel/whitelist.conf)

Configure allowed commands for security:

# Add commands one per line
ls
cat
git
python
# etc.

🏗️ Architecture

┌─────────────────────────────────────────────────┐
│           Bridge Client (Local)                 │
│                                                 │
│  ┌──────────────────────────────────────────┐  │
│  │         CLI Commands                     │  │
│  └──────────────────────────────────────────┘  │
│                    │                            │
│      ┌─────────────┼─────────────┐              │
│      │             │             │              │
│  ┌───▼────┐  ┌────▼─────┐  ┌───▼─────┐        │
│  │ Core   │  │   MCP    │  │ Network │        │
│  │ Config │  │  Manager │  │ Client  │        │
│  └────────┘  └──────────┘  └──────────┘        │
│                    │             │              │
│              ┌─────▼─────┐       │              │
│              │   MCP     │       │              │
│              │  Servers  │       │              │
│              └───────────┘  ┌────▼─────┐       │
│                             │ Command  │       │
│                             │ Executor │       │
│                             └──────────┘       │
└─────────────────────────────────────────────────┘
                              │
                              │ WebSocket
                              ▼
┌─────────────────────────────────────────────────┐
│            Bridge Server (Remote)               │
│  /api/v1/bridge/ws?client_id=xxx&code=yyy       │
└─────────────────────────────────────────────────┘

🛠️ Development

Setup Development Environment

# Clone repository
git clone https://github.com/castrel-ai/castrel-bridge-proxy.git
cd castrel-bridge-proxy

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -e ".[dev]"

Run Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=castrel_proxy

# Run specific test file
pytest tests/test_core.py

Code Quality

# Format code
black src/

# Lint code
flake8 src/

# Type checking
mypy src/

🤝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🔒 Security

For security concerns, please see SECURITY.md or contact security@example.com.

📮 Contact

🙏 Acknowledgments

  • Built with Typer for CLI
  • Uses aiohttp for async WebSocket communication
  • Integrates with MCP for tool protocols

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

castrel_proxy-0.1.0.tar.gz (32.4 kB view details)

Uploaded Source

Built Distribution

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

castrel_proxy-0.1.0-py3-none-any.whl (38.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: castrel_proxy-0.1.0.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for castrel_proxy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 adb62df98c4d88f3a95a86c574f967863d3b4ecb62728a6edbd7c9a16a4d64ac
MD5 ef6ef1d204efbd3d74518e01cd2b9455
BLAKE2b-256 d95252b1a649d69dbe18e0271eb7fa123c7d02a74d66c264bba4789d2bd5fb6f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: castrel_proxy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for castrel_proxy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f382927828815e7c07c6ed48b95b19c2ee1e48156f13e325c16b6a2ba41f47ad
MD5 631155b45959a60cc9271fcb65f360ff
BLAKE2b-256 582377e11b457fdc6071c80958977275f75115fd90e36e896c1ab93d25f75880

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