Skip to content

About

Run a fleet of AI agents: MCP bridge (any stdio MCP server over REST) + Discord gateway routing + heartbeat fleet monitor. Plain HTTP, no VPN required.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

59 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agent Gateway
npm: @leverframe/mcp-bridge License: MIT Node.js 18+

Infrastructure for running a fleet of AI agents: consume MCP tools over plain REST. Fleet gateway + heartbeat included.

Any stdio MCP server over plain REST — no install, no config to try it:

npx @leverframe/mcp-bridge        # serving /health on :5555
curl http://localhost:5555/health

Two components:

  1. MCP Bridge — lets agent platforms that only expose tools (MCP servers) also consume external MCP tools (Linear, GitHub, anything with a stdio server) through a plain HTTP API. Run it anywhere: localhost, a VPS, a container.
  2. Agent Gateway — plugin-based gateway that routes platform messages (Discord today; Slack/Telegram/API planned) to a fleet of HTTP-addressable agents, plus a heartbeat monitor that watches fleet health and alerts when agents degrade.

No VPN required — every component binds wherever you point it and talks plain HTTP.


MCP Bridge

Agent platforms like OpenClaw are MCP servers (they expose tools) but not MCP clients (they can't consume tools). The bridge wraps any stdio MCP server and exposes its tools as ordinary REST endpoints:

HTTP POST /linear/search_issues ──► stdio JSON-RPC ──► Linear MCP server

Status: reference implementation + full deployment docs. Ran in production from 2026-05-13; the previous host was retired — redeploy with the deployment guide (everything needed lives in these docs).

The runnable bridge package lives at mcp-bridge/ — npx @leverframe/mcp-bridge from anywhere and it's serving on :5555, or npm install && npm start inside the directory.

mcp-bridge demo: install, point servers.json at any stdio MCP server, call tools over REST

30-second taste

Once deployed on a host (default port 5555):

curl http://localhost:5555/health

curl -X POST http://localhost:5555/linear/search_issues \
  -H 'Content-Type: application/json' \
  -d '{"query": "test", "limit": 5}'

Agent Gateway

Components

Component Command What it does
Gateway npm start Discord bot listener, router, and message journal forwarding messages to agent HTTP adapters, with graceful shutdown/drain
Heartbeat monitor npm run heartbeat Polls every agent's /health every 30s; dashboard + JSON API on port 3001; Discord alerts on status/resource changes

Managed dots

One command turns a command line into a registered, health-checked, auto-restarting agent:

npm run dot -- spawn --name fran --cmd "node src/agent/AgentAdapter.js --port 3101 --name fran"
npm run dot -- ls
npm run dot -- logs fran -n 100 --follow
npm run dot -- kill fran
  • spawn allocates a free port (default range 3100–3199, DOT_PORT_MIN/DOT_PORT_MAX), gates on the agent's /health, and runs the process under supervision (exponential backoff restart, crash-loop breaker after >5 exits/60s).
  • State persists to data/dots.json; a gateway restart adopts surviving processes in place (zero downtime) or respawns them.
  • Dots appear on the heartbeat dashboard and alert through the same webhook as the rest of the fleet.
  • To route Discord mentions to a dot, add it to agents.json (spawn output prints the line) — routing registration is deliberately manual for now.

Requires the gateway process running (DOT_GATEWAY_URL defaults to http://127.0.0.1:3000).

Quick Start

npm install
cp .env.example .env   # fill in DISCORD_BOT_TOKEN etc.

npm run heartbeat      # live immediately — dashboard at http://localhost:3001

The heartbeat dashboard renders right away and fills in as you add agents. To wire up a fleet, copy the examples and point them at any HTTP hosts — localhost, LAN IPs, containers, whatever your network looks like:

cp agents.example.json agents.json                 # gateway routing targets
cp heartbeat-agents.example.json heartbeat-agents.json   # heartbeat /health targets

Each entry is { "name", "host", "port" }. Alternatively set them inline via AGENTS_JSON / HEARTBEAT_AGENTS_JSON (the Docker-friendly path). The agent a message goes to when there's no @mention is DEFAULT_AGENT (defaults to the first configured agent).

Then the full gateway:

npm start              # Discord routing on port 3000 (DISCORD_TEST_MODE=1 echo by default; set 0 to route)
npm run dev            # gateway with node --watch

Agent adapters expose GET /health and POST /process (JSON body: platform, source, content). Deploy adapters fleet-wide with:

bash scripts/deploy-adapters.sh    # install/start adapters on all machines
bash scripts/deploy-heartbeat.sh   # deploy heartbeat service

Architecture

├── Heartbeat Collector (3001)
│   └── Pings all agents every 30s → Dashboard + Discord alerts
│
├── Gateway (3000)
│   └── Discord Plugin ──> Router ──> Agent Fleet (HTTP adapters)
│
└── Agent Fleet (anywhere HTTP can reach)
    ├── agent-a  (host:port from agents.json)
    ├── agent-b  (host:port from agents.json)
    └── ...

Heartbeat Monitoring

Heartbeat dashboard: per-agent status, RAM, CPU, latency

  • Dashboard at http://localhost:3001 (auto-refresh every 30s)
  • JSON API at http://localhost:3001/api/status
  • Per-agent metrics: status (ok / degraded / down), RAM (MB), CPU (%), latency (ms), plus 10-point histories
  • Thresholds — RAM: <350MB green, 350–450MB warn, >450MB crit; CPU: <60% / 60–80% / >80%; latency: <200ms / 200–500ms / >500ms
  • Alerts via Discord webhook (HEARTBEAT_WEBHOOK_URL)

Routing Format (gateway running)

  • @demo hello → routes to the demo agent (any configured agent name works)
  • hello → routes to DEFAULT_AGENT
  • @username Discord mentions resolve when the username matches an agent name

Docker

docker-compose up -d

The compose file runs the gateway with host networking, a 15s stop grace period (message drain), a persisted journal volume, and a /health healthcheck. Pass the fleet via AGENTS_JSON / HEARTBEAT_AGENTS_JSON environment variables.

Configuration

.env (see .env.example): GATEWAY_PORT, GATEWAY_HOST, DISCORD_BOT_TOKEN, DISCORD_CLIENT_ID, DISCORD_GUILD_ID, HEARTBEAT_PORT, HEARTBEAT_WEBHOOK_URL, AGENTS_JSON, HEARTBEAT_AGENTS_JSON, DEFAULT_AGENT.

Project Structure

agent-gateway/
├── src/
│   ├── index.js               # gateway entry point
│   ├── config.js              # ports + agent fleet loading (env/file)
│   ├── gateway/Gateway.js     # plugin orchestration, shutdown/drain
│   ├── gateway/journal.js     # message journal (persisted to ./data)
│   ├── plugins/DiscordPlugin.js
│   ├── router/Router.js       # message → agent routing
│   ├── agent/AgentClient.js   # HTTP client for agent adapters
│   ├── agent/AgentAdapter.js  # adapter deployed alongside agents
│   └── heartbeat/             # heartbeat server + dashboard
├── scripts/                   # deploy-adapters.sh, deploy-heartbeat.sh
├── public/dashboard.html
├── test/                      # node --test test/*.test.js
├── MCP-BRIDGE-*.md            # MCP bridge documentation set
└── docker-compose.yml, Dockerfile

Additional design docs in this repo: ARCHITECTURE.md, DEPLOY.md, RESTART-SAFEGUARDS.md, HEARTBEAT-ENHANCEMENTS.md, CLAUDE.md.

About

Run a fleet of AI agents: MCP bridge (any stdio MCP server over REST) + Discord gateway routing + heartbeat fleet monitor. Plain HTTP, no VPN required.

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages