OpenCode
Connect OpenCode to the HASP MCP broker, check configuration and live transport, and verify protection in its running shell tools.
Config Example
hasp agent connect opencode installs the managed wrapper and a local MCP
entry for OpenCode 1.x. It uses OPENCODE_CONFIG when set, otherwise
$XDG_CONFIG_HOME/opencode/opencode.json or ~/.config/opencode/opencode.json.
{
"mcp": {
"hasp": {
"type": "local",
"command": ["/Users/alice/.hasp/bin/hasp-agent-opencode"],
"enabled": true
}
}
}
Replace the example path with your managed wrapper path from
hasp agent status opencode --json. Setup preserves other JSON settings.
If the selected file uses JSONC comments or trailing commas, automatic setup
stops without changing that file. Add the entry manually, or select a separate
JSON file with OPENCODE_CONFIG for both setup and OpenCode.
OpenCode merges configuration sources. Project or inline settings can override the global entry, so a saved file does not prove a live connection. See OpenCode configuration and local MCP servers.
Session Behavior
Start the whole client with hasp agent launch opencode -- opencode from the
bound repository. The launcher establishes daemon process identity and an
inherited agent-safe environment for the client's ordinary shell tools.
An MCP wrapper alone protects its own process tree; it cannot attest sibling
shell processes in an otherwise unprotected client.
The MCP transport retains project sessions across tool calls. A fresh
connection or expired session needs new project consent. Use grant_project
and grant_secret explicitly, with once, session, or window as appropriate.
No setup command grants plaintext access. The operator can grant one-time
plaintext access to a protected session with hasp session grant-plaintext.
Success Signal
hasp agent status opencode --jsonreports current configuration and wrapper.- OpenCode's HASP
hasp_statustool reportsconnection=connectedfor that MCP transport. OpenCode may prefix the tool name with the server name. - Run
hasp agent status opencode --jsonthrough OpenCode's ordinary Bash tool. A launcher-protected client reportsdaemon_process_treeor a validateddaemon_session_environment. Runhasp secret show NAMEfor metadata; usehasp_runorhasp_injectfor delivery.
For long commands, start a recoverable job and retain its request_id.
Recover its progress with hasp_job_status if the client loses a response.
Failure Recovery
- Re-run
hasp agent connect opencodefor missing or outdated managed files. - Use
opencode mcp listand the client'shasp_statustool to check active configuration. Inspect project and inline overrides if the file is current but the client does not connect. - Restart through
hasp agent launch opencode -- opencodewhen the shell status does not observe a protected session. An environment guard alone cannot attach an operator's session grant. - Retry a denied HASP tool call using its reported
grant_fieldand an explicit duration. A consumed once grant requires fresh consent as its error explains.
Known Caveats
The adapter writes the OpenCode 1.x mcp.hasp schema. It rejects a configuration
using mcp.servers rather than silently converting another schema.
Read-only diagnostics inspect the selected file and current command; they do
not claim to inspect every client override, another process's permissions, or
an active plaintext grant. Local process and environment protection do not
provide strong isolation from a hostile process running as the same user.