MControlProgram sits between AI agents and the things you don't want them to hold directly: SSH keys, API tokens, internal networks. Agents connect to MControlProgram over the standard Model Context Protocol (Streamable HTTP) and get tools; MControlProgram's plugins own the credentials, make the real connections, and enforce policy.
It is meant to be used in conjunction with an AI agent that is itself segmented by containerized security controls, such as Docker Sandbox, so the gateway is the agent's only path to credentials and the outside world.
Access is meant to be granted per task, not permanently. From the web UI you can switch individual SSH hosts, browser hosts and profiles, and plugin instances on or off, and change web/browser URL rules (allow or block a domain, URL or regex) at any time, with no agent restart and no change inside the sandbox. Enable only what the current job needs (one host, one browser profile, one site), then turn it off again afterwards. Risky tool calls can additionally be held for human approval, so the agent's exposure at any moment is limited to what you have deliberately opened up.
SSH — hosts agents may use, with per-server toggles, global command rules (allow, ask or deny by default, plus blocked / ask / allowed programs, commands, patterns and written files; parsed with a real shell grammar, so pipes, sudo, sh -c and $( ) are all checked) and a filterable command log.
Web — HTTP and page fetching with server-side credential injection, global URL access rules (allow, ask or deny by default; blocked / ask / allowed domains, URLs and regex) and a request log with one-click Block domain / Block URL.
BrowserPaw — isolated Chromium profiles on SSH, native or manual hosts, each with its own logins and bridge. Agents get browser tools and never see SSH access or the bridge token.
Every BrowserPaw browser runs from its own dedicated Chromium user-data directory, so profiles are completely separate from each other (cookies, logins, history and extensions are never shared) and from the main user's everyday browser on that computer. An agent working in one profile cannot see another profile's sessions, or yours.
BrowserPaw has its own URL access rules (allow, ask or deny by default), pushed to every profile (fail closed if a browser is out of sync), and a per-agent log of everything the browser loads or is refused, with one-click Allow / Block per domain or URL.
┌──────────────────────────────┐
│ AI agent (sandboxed) │
│ Claude Code, Cursor, … │
└───────────────┬──────────────┘
│ MCP/HTTP + auth
▼
┌──────────────────────────────┐ ┌──────────────────┐
│ MCP server :7801 │ ask ▶│ Admin UI :7700 │
│ tokens / OAuth, logging │◀ ok │ approvals, logs │
│ allow / ask / deny rules │ └──────────────────┘
└───────────────┬──────────────┘
┌───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬─┐
▼ ▼ ▼ ▼ ▼
┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐ ┌────────────┐
│ ssh │ │ web │ │ mcp │ │ browserpaw │ │ git │ │docker sbx │
└──────┬─────┘ └──────┬─────┘ └──────┬─────┘ └──────┬─────┘ └──────┬─────┘ └──────┬─────┘
▼ ▼ ▼ ▼ ▼ ▼
SSH hosts APIs / sites upstream MCP Chromium git hosts sbx microVMs
servers profiles (ssh / native)
- Multiple MCP servers, each on its own port with its own plugins, auth mode, and log level.
- Standard MCP auth: static bearer tokens and/or full OAuth 2.1 (discovery, dynamic client registration, PKCE, refresh, revocation) with an admin consent page. Works with Claude Code, Claude Desktop, Cursor and any spec-compliant client.
- Plugins define a plugin-wide config (shared inventory such as SSH hosts or web credentials,
edited from the Plugins page with plugin-provided actions and wizards) plus a per-instance config
(what each MCP server exposes and how). Built-in:
ssh(exec, persistent shells, SFTP, per-host and global command allow/deny, command log),web(HTTP requests, page-to-text, global and per-instance URL allow/deny, private-network blocking, server-side credential injection, isolated cookie jars, request log),mcp(proxy other MCP servers with per-tool allow/ask/deny),acp(proxy local ACP agents such as devin, with allow/ask/deny per tool-call kind),browserpaw(agent-driven Chromium profiles on SSH, native or manual hosts, with a managed URL policy and per-agent request log),git(agents push and submit patches from clones on a git host to any git server, and open PRs on GitHub/GitLab/Gitea/Forgejo; they can also drive the host's clone: pull, switch, merge / rebase, stash, resolve conflicts, commit and push; allow/ask/deny per repo and per tool) andsandbox(Docker Sandboxes viasbxover SSH or on this machine: create, exec, files, ports, network policy). - Secrets encrypted at rest (AES-256-GCM, key in
MCONTROLPROGRAM_MASTER_KEYordata/master.key); the UI never returns a stored secret. - First-run setup: no default credentials. The first visit to the admin UI asks you to create
the admin account (or set
MCONTROLPROGRAM_ADMIN_USER/MCONTROLPROGRAM_ADMIN_PASSWORDfor unattended installs). - Logging per server:
off,connections,tools,full(args + results). Persisted to SQLite, searchable and live-tailed in the UI.
npm install
npm run build:web # one-time; builds the admin UI into web/dist
npm run dev
# open http://127.0.0.1:7700 and complete the one-time setup page (create the admin account)Production: npm run build && npm start (serves dist/main.js; set env from .env.example).
docker compose up -d --buildAdmin UI on http://localhost:7700. All state (SQLite DB, master.key, drop-in plugins) lives in the
mcontrolprogram-data volume mounted at /data. Add a ports: line in docker-compose.yml for each MCP
server port you create, and bind the server to 0.0.0.0 in its settings.
- Plugins → SSH → Configure → Add host (guided): name, address, user, then choose key or
password auth. For keys, MControlProgram can generate the pair (the private key never leaves the server)
and either install the public key for you with a one-time password (like
ssh-copy-id) or show the exactauthorized_keysline and where it goes. "Test connection" confirms it works. Per-host command allow/deny regexes and SFTP root live here too. - Servers → New server: name
ops, port7801, authbearer(oroauth/both), log leveltools. - Server → Plugins tab → Add plugin → ssh: tick the hosts from the inventory this server should expose (empty = all), pick shell isolation. Save. The instance starts immediately.
- Access tab → New token: copy the token (shown once).
- In the agent:
or with OAuth (
claude mcp add --transport http ops http://127.0.0.1:7801/mcp --header "Authorization: Bearer gdn_…"auth_mode: oauth), justclaude mcp add --transport http ops http://127.0.0.1:7801/mcp; the client will discover the authorization server, register itself, and open the consent page where you log in as the MControlProgram admin and approve it. - The agent now sees
ssh_list_hosts,ssh_exec,ssh_shell_send, … and never the key. Every tool call is self-contained: shells are addressed byhost+nameand open on demand, so calls don't depend on order.
Tools are named <instance name>_<tool>, so two ssh instances named prod and staging on one
server give prod_exec and staging_exec.
Every MCP server also serves a plain HTTP API on the same port, for agents that can make HTTP requests but cannot add an MCP server. It uses the same tokens (bearer or OAuth), exposes the same tools, and applies the same allow / ask / deny rules, approvals and logging.
GET /api: what the API is and how to authenticate (no auth needed). Give an agent this URL and it can find the rest.GET /api/openapi.json: an OpenAPI 3.1 spec with onePOST /api/tools/<name>per tool, its JSON Schema and annotations, and the server instructions.POST /api/tools/<name>: the body is the arguments object, the response is the MCP tool result (content,isError).GET /api/tools,GET /api/resources[/<name>].
curl -s -X POST http://127.0.0.1:7801/api/tools/ssh_exec -H "Authorization: Bearer gdn_…" \
-H 'Content-Type: application/json' -d '{"host":"web01","command":"uptime"}'Calls waiting for approval keep the request open for up to approvalWaitSec. Per-agent state (shells,
cookie jars) is kept per token and released after stateIdleSec without calls.
The built-in mcp plugin connects to other MCP servers and re-exposes their tools, so one
MControlProgram endpoint can front many upstreams with a single login, one log, and the approval gate.
Configure upstreams on the Plugins page: Streamable HTTP (none / bearer / custom header / OAuth
2.1 with dynamic registration) or stdio (command, args, env). Secrets such as tokens and env
values are stored encrypted and never leave MControlProgram; the agent sees only the tools. An instance
picks which upstreams to expose, optionally flattens names, and can hide individual tools.
The plugin page lists every upstream tool with an allow / ask / deny switch, a default policy
(new installs: ask by default), pending asks (Enable tool / Disable tool set the switch), and a
log of every proxied call. Upstream input schemas and annotations pass through unchanged, so
"approve tools that are not read-only" works on proxied tools too. For OAuth upstreams, run Authorize (OAuth) in the plugin
config and open the link; set MCONTROLPROGRAM_PUBLIC_URL if the authorization server must redirect to a
public address.
The acp plugin (needs mcp) runs local Agent Client Protocol agents
(devin and other agents that speak ACP on stdio) so ACP clients, such as a Hermes plugin in a
sandbox, can drive them over the MCP server's own port. Each agent is a command, arguments, an
environment (API keys stay in MControlProgram) and a working directory. The agent runs in that
directory, and every session is pinned to it whatever cwd the client sends.
The client posts the JSON-RPC messages it would send over stdio, using the server's bearer token:
POST <server url>/plugins/<instance>/<agent> initialize → response header Acp-Connection: <id>
POST … with Acp-Connection: <id> a request → NDJSON: agent notifications (session/update …), then its response
a notification (session/cancel) → 202
DELETE … with Acp-Connection: <id> stop the agent process
GET … with Acp-Connection: <id> NDJSON: what the agent sends while no request is open
Some agents keep talking after a request returns (some answer session/prompt first and stream
their reply afterwards). Those messages go to an open request's stream, else to the connection's GET
listener, else they are buffered for the next one. The GET stream also carries a
_mcontrolprogram/heartbeat notification every 2 s, so a client waiting for something can re-check.
MControlProgram stands between the two:
- It answers every
session/request_permissionitself, from per-agent rules on the ACP tool-call kinds (read,edit,delete,move,search,execute,fetch,think,switch_mode,other; the read-only policy allowsread/search/fetch/think). Asks go to the Approvals page, and every decision is in the plugin's call log. It only ever picksallow_onceorreject_once, so the agent never caches a grant past the rules. An ask still open after approval wait is rejected for that tool call. Once you approve it, the agent's identical retry goes through. - A permission request's tool call is often only a reference (some agents send just its
toolCallId); its kind, title and input come from thetool_callthe agent announced on the stream before it, so the rules seeexecute, notother. - Each ask is announced on the prompt stream as a
_mcontrolprogram/approvalnotification (status: pending, withsummary,reason,channelandwaitSec; thenapprovedorrejected), so a client can show that the agent is waiting. Approval wait (per agent, 0 = the global setting) is how long the tool call waits; the agent's turn pauses meanwhile. - With Client approvals on, the ask is also put to the client's user, the ACP way: the stream
carries the agent's
session/request_permission(with anmcp-…id and only its allow-once / reject-once options), and the client POSTs the JSON-RPC response on the same connection (→ 202). Whichever answers first, the client or the Approvals page, decides; the decision is logged as<principal> via client. If the page decides first the client gets$/cancel_request. - It hides the client's file system and terminal capabilities and the agent's auth methods, unless the
agent has Client files and terminal on: then the client's
fs/terminalcapabilities reach the agent, and itsfs/*andterminal/*requests are relayed to the client on the prompt stream (withmcp-…ids, answered by POSTing the response, like permission prompts). An agent that uses them reads, writes and runs commands on the client's machine instead of its own. Tools it still runs itself (e.g. grep, glob) need deny rules in the agent's own config. Permission requests still go through the rules. Session results carry the pinned directory as_meta["mcontrolprogram/cwd"], so the client can map the agent's paths under it to its own. - It replaces the client's MCP server list with this MControlProgram server, using the client's token (or with none). Clients cannot switch a session to a mode listed under Blocked modes.
Permission requests are advisory: the agent decides what to ask about. Block the modes in which it
stops asking (for example bypassPermissions). Treat the working directory as everything the agent can
change, and run it as a user with access to nothing else.
Every rule in MControlProgram is allow, ask or deny (shown as block in the rule lists):
- Tool rules (server → Plugins → Tool rules): a default for the instance (allow; ask for tools
without
readOnlyHint; ask for everything) plus per-tool allow/ask/deny. Deny refuses the tool. - Plugin rules: SSH command rules, Web and BrowserPaw URL rules each take block / ask / allow rules and an allow, ask or deny default. Block beats ask, ask beats allow.
An ask queues the call on the Approvals page (every ask) and on the plugin's own page (its asks),
with the caller, what it wants (web01: systemctl restart nginx, GET https://…), and why it asked.
Each ask offers Allow once, Add allow rule…, Add block rule… and Deny once; the rule
buttons open the plugin's rule editor prefilled from the request, save the rule, then decide the call.
The agent is never left hanging: the call blocks for approval wait seconds (default 30), then returns an error telling it to wait and call again with the same arguments. Identical retries attach to the same request rather than creating duplicates. After max attempts (default 3) the error tells the agent to pause and ask the user. An approval is consumed by exactly one execution; a denial sticks for the request's lifetime (default 1 day). All three knobs live in Settings.
Settings → Approval channel picks where else an ask can be answered (the Approvals page always works):
- MControlProgram only (default).
- MCP client prompt: if the agent's MCP client supports form elicitation, the gate asks the client's user directly
(Hermes shows it as its normal approval prompt) and the call waits up to client prompt wait seconds (default 240,
under Hermes' 300 s tool timeout). Accept = allow once, decline = deny once, no answer = stays pending. Recorded as
decided_by = "<principal> via client". The client answers for itself, so use this only when the client process runs outside the agent's sandbox. - API keys: external apps answer through
/api/v1with an API key that has theapprovalspermission, e.g. Control Tower for Hermes Desktop. Create keys under Settings → API keys (shown once, revocable, permissions editable). Endpoints, allAuthorization: Bearer mcpk_…, CORS open since no cookie is involved:GET /api/v1/me,GET /api/v1/approvals({pending, recent}),POST /api/v1/approvals/:id/approved|denied.
Asks from plugin HTTP bridges (BrowserPaw) have no MCP session to prompt, so they never use the client channel.
BrowserPaw can only ask about URLs agents pass to browser tools: the browser can't pause a page load, so in the browser ask rules act as allow rules and ask by default acts as allow.
A plugin is an ES module that adds tools to an MCP server. It runs in-process and is trusted code. Full reference: docs/PLUGINS.md; a working copy of the example below lives in examples/echo-plugin.
1. Create the plugin at data/plugins/echo/index.js (with Docker, data/ is the /data volume):
// Minimal external MControlProgram plugin. Copy this directory to data/plugins/echo (or point
// MCONTROLPROGRAM_PLUGIN_DIRS at its parent) and click "Reload plugins" in the UI.
import { z } from 'zod';
export default {
id: 'echo',
name: 'Echo',
version: '0.1.0',
description: 'Example plugin: echoes input, demonstrates config, secrets, status and actions.',
configSchema: {
type: 'object',
properties: {
prefix: { type: 'string', title: 'Prefix', default: '> ' },
apiKey: { type: 'string', title: 'Example secret', 'x-secret': true, description: 'Encrypted at rest, never shown to agents' },
uppercase: { type: 'boolean', title: 'Uppercase output', default: false },
},
},
defaultConfig: { prefix: '> ', uppercase: false },
create(ctx) {
let calls = 0;
return {
start() { ctx.log.info('echo plugin started'); },
stop() { ctx.log.info('echo plugin stopped'); },
// MControlProgram-wide defaults are available via ctx.global() (e.g. ctx.global().stateIdleSec for your own reaper)
status: () => ({ calls, hasApiKey: !!ctx.config.apiKey, stateIdleSec: ctx.global().stateIdleSec }),
actions: { reset: { title: 'Reset counter', async run() { calls = 0; return { calls }; } } },
tools: [
{
name: 'say',
description: 'Echo a message back.',
inputSchema: { message: z.string() },
annotations: { readOnlyHint: true },
async handler({ message }, call) {
calls++;
call.log.debug('say called', { message });
const out = ctx.config.prefix + message;
return { content: [{ type: 'text', text: ctx.config.uppercase ? out.toUpperCase() : out }] };
},
},
],
};
},
};2. Load it. Click Plugins → Reload plugins. Plugins are discovered from, in order:
built-ins (src/plugins), data/plugins/<dir>/ (a package.json with main, or index.js),
directories in MCONTROLPROGRAM_PLUGIN_DIRS (colon separated), and npm package names listed under
Plugins → npm packages.
3. Use it. On a server's Plugins tab choose Add plugin → echo, fill in the config and
save. The instance starts immediately and connected agents get a tools/list_changed.
Things worth knowing before you write a real one:
- Make every tool call self-contained. Agents retry, parallelise and reconnect, so do not require
"open, then use the handle" sequences. Address state by stable names, open on demand, make close
idempotent, and scope state to
call.principalso agents cannot touch each other's state. - Shared inventory. Put credentials or host lists in
globalConfigSchema(edited once on the Plugins page); instances pick from them with"x-options-from".globalActionsadd buttons or wizards that run server-side. - Clean up. Reap idle state from a timer started in
start()and cleared instop(), and drop per-session state inonSessionClosed. Usectx.global()for the gateway-wide idle timeouts. - Errors. Throwing from a handler becomes an
isErrorresult and is logged. - Approvals. Set
readOnlyHinton tools that change nothing; the gateway's tool rules handle the rest. For finer asks (one command, one URL), give your rules anaskaction and callawait call.ask({ feature, summary, reason, subject }): it resolves with who approved, or throws a message for the agent. Refuse whencall.askis missing. See docs/PLUGINS.md.
src/core config, sqlite, crypto, logger, secrets, plugin API + loader, store
src/mcp runtime (one Express app + MCP sessions per server), OAuth provider, manager
src/plugins built-in ssh, web, mcp, browserpaw, git and sandbox plugins
src/admin REST API for the UI
web/ Vite + React admin UI
test/ node:test unit tests (npm test); npm run test:ssh runs live ssh tests against a throwaway sshd
- Bind MCP servers to
127.0.0.1unless you terminate TLS in front of MControlProgram; setpublic_url(https) on the server so OAuth metadata advertises the right issuer. - Bearer tokens and OAuth tokens are stored hashed. The master key file is
0600; back it up with the database or stored secrets are unrecoverable. - SSH shells are isolated per principal by default (
shellScope: principal): agents using different tokens/OAuth clients cannot see or touch each other's shells, and an agent that reconnects with the same token resumes its own.sessionties shells to the MCP session;sharedmakes them common. Two agents sharing one token are one principal, so give each agent its own token. - Cleanup is automatic and independent of agent behaviour, driven by two MControlProgram-wide defaults in
Settings: agent state idle timeout (default 2 days; shells, cookie jars) and connection idle
timeout (default 1 hour; the SSH socket closes but shells survive until the state timeout and the
socket reopens on the next call). Each plugin instance may override either with its own value;
0means inherit. Session-scoped state also dies when the MCP session ends. - The
webplugin keeps a cookie jar per scope (cookieScope, defaultprincipal), so logged-in browsing works but agents never see cookie values, cannot inject their own, and cannot reach each other's jars. Jars idle longer than the global state timeout (or the instance'scookieIdleSec) are discarded;cookies: falsemakes every request stateless. webblocks private/loopback targets by default; the sshdenyCommandslist is checked onexecand on everyshell_send(setraw: trueonly for keystrokes).



