Skip to main content
Glama

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
INIT_CWDNoFallback working directory for sessions when no directory is provided via the tool or MCP roots.
OPENCODE_URLNoThe OpenCode v2 server URL, e.g. http://127.0.0.1:4096.
OPENCODE_PASSWORDNoThe OpenCode Basic-auth password (username is always 'opencode').
CLAUDE_PROJECT_DIRNoFallback working directory for sessions when no directory is provided via the tool or MCP roots.
OPENCODE_MCP_TOKENNoBearer token for the HTTP transport; if unset, a token is generated at ~/.config/opencode-mcp/http-token.
OPENCODE_MCP_DIRECTORYNoFallback working directory for sessions when no directory is provided via the tool or MCP roots.
OPENCODE_MCP_ALLOWED_ROOTSNoAllowed roots for path access, blocking path escapes (symlink-safe).

Instructions

Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.

This server drives a local OpenCode v2 instance. Start with opencode_status; if it is not configured, call opencode_configure with the server address and password. Sessions are created in the client's workspace by default. Use opencode_task for one-shot delegated work and opencode_session_* for persistent conversations.

Capabilities

Features and capabilities supported by this server

Protocol revision2025-11-25

CapabilityDetails
tools
{
  "listChanged": true
}

Tools

Functions exposed to the LLM to take actions

NameDescription
opencode_statusA

Report whether this MCP bridge is configured and connected to an OpenCode v2 server. Works even when nothing is configured, so it is the first tool to call when something looks wrong.

opencode_configureA

Set or repair the OpenCode v2 server address and password from inside the chat. The values are validated against GET /api/info before they are applied; nothing changes on failure. The password is never echoed back, is kept in memory by default, and is only written to disk when persist=true. Prefer configuring OPENCODE_URL and OPENCODE_PASSWORD in the MCP client settings when possible.

opencode_workspaceA

Report which directory sessions will use, where that choice came from (argument, MCP roots, env, config, cwd), or persist a new default. Use this before creating a session when you are unsure about the working directory.

opencode_session_createA

Create a new OpenCode session in a directory. Defaults to the client's current workspace. Use agent='build' for implementation work, 'plan' for planning, and 'general'/'explore' for subagents. Pass parentSessionID to create a child (subagent) session.

opencode_session_promptA

Send a message to a session and return the final answer. By default only a summary is returned: tool calls, intermediate steps and reasoning stay inside OpenCode, so the caller's context is not polluted. Set verbosity='full' only when you explicitly need the transcript. Attach files with files (path or data: URI). Set wait=false for fire-and-forget.

opencode_session_historyA

Audit a session. Default detail='summary' returns only what a caller usually needs: the user prompt, the assistant's answers, token totals and a count of tools used — no tool arguments or outputs. detail='tools' adds one line per step (name and status; targets only with includeTargets=true). detail='full' is disabled for security unless the bridge was started with --allow-full-history. The full transcript is never sent by default.

opencode_modelA

List models, read the default, and assign models at four levels: session (immediate API switch), project (opencode.json in the workspace), global (~/.config/opencode/opencode.json), agent (agents..model). Session assignment wins for that conversation; project/global change the default for new sessions. Config edits preserve JSONC comments and are verified against model/default.

opencode_permissionB

Headless runs block when OpenCode asks for permission. Use action=list to see pending requests and action=reply to approve or reject them. action=policy reports the bridge profile, or applies its ruleset to a session (approximate: OpenCode evaluates rules in order, so profiles are best-effort).

opencode_taskA

One-shot delegation: create a session, send a prompt, wait for the run, and return ONLY the final summary. Tool calls, intermediate steps and reasoning stay inside OpenCode, so the caller's context stays clean. Use background=true to get an immediate 'working' acknowledgement and collect the summary later with opencode_job. Set verbosity='full' only when a transcript is explicitly needed.

opencode_jobB

Track tasks started with background=true. Returns only the final summary once the job is done — intermediate tool calls and thinking never leave OpenCode.

opencode_session_listA

List sessions, newest first. Filter by directory, search text, archive state, or parent session.

opencode_session_getB

Fetch one session's metadata: title, agent, model, cost, tokens, timestamps and outcome.

opencode_session_moveC

Change the working directory of an existing session.

opencode_session_deleteC

Delete a session and its messages.

opencode_session_interruptA

Stop the current run in a session. The session stays usable afterwards.

opencode_session_compactB

Summarize older turns to free context. Returns the compaction inbox item and token totals before/after when the service reports them.

opencode_agentA

List available agents (primary and subagent), switch the agent of a session, or delegate a one-shot task to a subagent. Delegation creates a real child session and returns its transcript.

opencode_file_attachA

Upload a file into a session. Provide path (server-side file) or data (base64 bytes). When text is supplied the file is sent immediately as a prompt and the answer is returned; otherwise the attachment descriptor and stored path are returned for a later prompt.

opencode_mcpA

Inspect and manage the MCP servers that OpenCode itself uses (not this bridge). Actions: list (servers + connection status), resources (tool/resource catalog), add (local or remote), remove, connect, disconnect. Server enablement is global per OpenCode project; per-session tool filtering is done with session permissions.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

A3.5/5.0

Scored across 19 tools

Disambiguation4/5

Most tools map to a clear resource+action (session_create, session_list, session_get, session_delete, session_move), but the delegation surface overlaps: opencode_task, opencode_agent (delegation), opencode_job, and opencode_session_create with parentSessionID all describe ways to hand work to OpenCode. The descriptions do clarify the differences (one-shot vs tracked job vs child session), so an agent can pick correctly, but it takes careful reading.

Naming Consistency4/5

Every tool carries the opencode_ prefix and the session-scoped tools consistently use resource_action form (session_create, session_prompt, session_history). The remaining tools are single-noun or verb-noun (opencode_model, opencode_config? no — opencode_configure, opencode_file_attach, opencode_status), a minor deviation from the verb_noun ideal but still readable and predictable.

Tool Count4/5

19 tools is on the heavy side but each covers a distinct capability: session lifecycle, prompts/history, models/agents, permissions, MCP management, config, and jobs. Nothing feels obviously redundant, though the delegation tools (task, job, agent) add a few entries that could arguably be consolidated.

Completeness4/5

Coverage is strong across the domain: full session lifecycle (create/list/get/move/delete/interrupt/compact), prompting and history, model/agent assignment, permissions, workspace/config/status, and file attachment. Minor gaps exist (no explicit session rename/update metadata, no revert/undo, no file listing), but these are small and workaroundable.

Maintenance

ActivityNo data
ResponsivenessOutdated data