mcp-server

v0.5.0
@stacksona/mcp-server Checked 2 days ago Published 2 months ago

MCP server for Stacksona Gate.

Version 0.5.0, backed by @stacksona/sdk@^0.5.0. The MCP server runs in a trusted host process and exposes governed tool *decisions*, not the Gate API key or raw signed-approval tokens, to the model. Inject STACKSONA_API_KEY only into the MCP host process from your secret manager. Never paste an actual key into agent prompts, messages, tool schemas, logging, checked-in configs, or model-readable filesystem paths. A trusted host launches stacksona-mcp-server with STACKSONA_GATE_URL=https://your-gate.example.com and the secret environment variable.

Summary extracted from the README.

@stacksona/mcp-server — private credentials, model-visible decisions

Version 0.5.0, backed by @stacksona/sdk@^0.5.0. The MCP server runs in a trusted host process and exposes governed tool decisions, not the Gate API key or raw signed-approval tokens, to the model.

npm install -g @stacksona/mcp-server@^0.5.0

Secure host configuration

Inject STACKSONA_API_KEY only into the MCP host process from your secret manager. Never paste an actual key into agent prompts, messages, tool schemas, logging, checked-in configs, or model-readable filesystem paths. A trusted host launches stacksona-mcp-server with STACKSONA_GATE_URL=https://your-gate.example.com and the secret environment variable. Immediately after constructing the private SDK client, MCP deletes process.env.STACKSONA_API_KEY and clears its module-scope copy. SDK request code reads the key only from a JavaScript private field to set the Bearer header.

This protects a model that can invoke only the published MCP tools. It cannot protect credentials from an untrusted agent with shell access to the same OS user/process, a debugger, process-memory inspection, inherited startup environment, or the secret manager itself. Use separate security principals/processes for that threat model.

Gate requires HTTPS outside local loopback. For an explicitly trusted local development server only, add STACKSONA_ALLOW_INSECURE_LOCALHOST=1; remote HTTP still fails.

What the model can and cannot do

Model-visible MCP tools are: stacksona_resolve_tools, stacksona_log_event, stacksona_request_decision, stacksona_request_decision_and_poll, stacksona_get_decision, stacksona_list_decisions, and stacksona_submit_revision.

By default, the host requires action_hash on requests and revisions: the model cannot choose a hashless V1 downgrade. Only if the host administrator explicitly sets STACKSONA_MCP_ALLOW_LEGACY_APPROVALS=1 will legacy requests be permitted. This policy cannot be changed through an MCP tool. A model-supplied 64-character hash alone does not prove execution binding: the trusted runtime must compute and check the complete immutable action identity at the actual privileged handler, preferably using @stacksona/sdk runGatedAction({ ..., action_hash }, callback, { verifyActionBinding }).

Raw approval_token, signature, API keys and Authorization fields are excluded from all model-visible MCP results. Model-callable validation is never advertised or executable, even if an old configuration still sets STACKSONA_MCP_ENABLE_MODEL_VALIDATION=1. Remove that setting. The trusted host must use the SDK directly to claim and validate a signed approval before its privileged handler executes the immutable action.

Gate delivers raw approval tokens only once. If a model-facing MCP tool polls an approved review, Gate may deliver the one-time token to this MCP process; MCP deliberately suppresses it from model results, so a separate host cannot retrieve it again through Gate polling. Do not race multiple pollers for the same signed review. For production V2 execution, use one trusted host that owns both polling and one-time validation, then performs the action behind its deterministic guard.

Wire contract

The Agent API URL and payload fields have not changed from Gate's merged V2 implementation: /api/agent/tasks/{taskID}/requests accepts action_hash, initial responses and /api/agent/decisions?thread_id=... echo it, and /api/agent/approvals/validate takes task_id, signature, request_payload, and V2 thread_id + action_hash. The signed token itself remains private to host code. A revised V2 proposal requires a new hash.

Full Gate reference: https://github.com/StacksonaGate/stacksona-gate/blob/main/docs/agent-api-openapi.yaml.

Credential boundary in this repository

The model-facing MCP server exposes neither the Gate API key nor raw one-time approval tokens or a token-validation tool. STACKSONA_MCP_ENABLE_MODEL_VALIDATION is intentionally ignored; remove it from old configurations. A trusted host must use @stacksona/sdk for signed approval consumption and exact executable action binding. A model-supplied action_hash alone does not authorize the execution of any side effect.