Skip to main content
Glama

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
OPENCODE_HOSTNoOpenCode server bind address.127.0.0.1
OPENCODE_PORTNoOpenCode server port.4096
CEREBRAS_API_KEYYesCerebras API key.

Instructions

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

OpenCode MCP — AI Coding Agent

You have access to a fast coding agent through OpenCode. The model and provider are configured in the project's opencode.json — this MCP is model-agnostic. Use it to delegate code generation tasks while you focus on planning, reviewing, and orchestrating.

Architecture

  • YOU (Claude) = orchestrator + code reviewer. You plan, break down tasks, and review all code.

  • OpenCode = fast code generator. It has full repo access (read/write/edit/bash) and runs whatever model is configured.

  • NO CODE SHIPS WITHOUT YOUR REVIEW. Always check what OpenCode wrote before moving on.

Workflow

1. Create a session (do this once per task)

Call opencode_session with action "create". Save the session ID — you'll reuse it for all subsequent calls so the agent retains context.

2. Send a task

Call opencode_session with action "prompt", passing the session ID and a clear, specific instruction. Be explicit about:

  • Which files to create or modify (full paths)

  • What the code should do

  • Any constraints or patterns to follow

  • The project's language, framework, and conventions

3. Review the output

After the agent completes:

  • Call opencode_file with action "status" to see what files changed

  • Call opencode_message with action "list" to read what the agent did and why

  • Read the changed files yourself to review the code quality

4. Accept or reject

  • If the code is GOOD: move on to the next task (keep using the same session)

  • If the code is BAD: call opencode_session with action "revert" to undo changes, then call opencode_session with action "prompt" with feedback explaining what to fix. The agent retains session context so it knows what you're referring to.

5. Iterate

Repeat steps 2-4 until the task is complete. The agent remembers everything within the session.

Best Practices

  • ALWAYS create a session before prompting. Never prompt without a session ID.

  • REUSE sessions for related work. The agent builds context over time.

  • BE SPECIFIC in prompts. "Add auth" is bad. "Create JWT middleware in src/middleware/auth.ts that validates Bearer tokens from the Authorization header" is good.

  • REVIEW EVERY CHANGE. You are the quality gate. The agent is fast but not infallible.

  • USE REVERT freely. It's cheap and clean — better to revert and re-prompt than to manually fix bad code.

  • USE session_summarize to get a summary of what the agent has done so far in a long session.

  • USE session_abort if a prompt is taking too long or going in the wrong direction.

When to Use OpenCode vs. Doing It Yourself

USE OPENCODE FOR: Boilerplate, repetitive code, initial implementations, file creation, test writing, refactoring DO IT YOURSELF FOR: Small edits, config changes, architectural decisions, anything requiring deep judgment

Available Tools Reference

  • opencode_session: Core tool. 22 actions — create, get, list, status, children, update, delete, init, abort, share, unshare, summarize, revert, unrevert, prompt, promptAsync, command, shell, diff, fork, todo, permission. Supports dynamic model switching via model/provider params. Use 'agent' param to select which agent runs the task. Use 'permission' action to respond to tool permission requests (once/always/reject).

  • opencode_message: Read agent conversation history (list with optional limit, get specific message).

  • opencode_file: Review changes (status), read files (read), browse directories (list).

  • opencode_find: Search codebase — text (grep), files (by name), symbols (functions/classes).

  • opencode_project: Get project info (current, list), discover available agents (agents), commands (commands), and VCS info (vcs — git branch, status, etc.).

  • opencode_config: Manage configuration (get, providers, update).

  • opencode_auth: Set provider authentication credentials.

  • opencode_provider: List providers with models and connection status (list), get auth methods (auth), start OAuth flow (authorize), complete OAuth (callback).

  • opencode_tool: Discover available tools — list all tool IDs (ids), get tools with JSON schema for a provider/model (list).

  • opencode_mcp_server: Manage MCP servers within OpenCode — status (all statuses), add (register), connect, disconnect, auth_remove, auth_start, auth_callback, auth_authenticate.

  • opencode_pty: Manage terminal sessions — list, create (with command/args/cwd), get, update (resize/rename), remove.

  • opencode_instructions: Get the full workflow guide and tool reference on demand. Call when you need a refresher.

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_sessionA

Manage OpenCode coding agent sessions. START HERE: use action 'create' to get a session ID, then 'prompt' to send coding tasks. The agent has full file access (read/write/edit/bash). Use 'model' and 'provider' params on prompt/shell/command to switch models on the fly. Actions: create, get, list, status (overall status), children, update, delete, init, abort, share, unshare, summarize, revert (undo changes, pass messageId), unrevert, prompt (send task), promptAsync (send task, return immediately), command (run agent command), shell (run shell command), diff (get code diff, optional messageId), fork (fork session at a message), todo (get session todo list), permission (respond to tool permission requests — once/always/reject). Always reuse session IDs for related work.

opencode_messageA

Read the conversation history from an OpenCode session. Use 'list' AFTER a prompt completes to see what the agent did — its reasoning, tool calls, and code changes. Use 'get' for a specific message. Essential for reviewing the agent's work before accepting changes.

opencode_fileA

Check what files the OpenCode agent changed. Use 'status' AFTER a prompt to see which files were created/modified (like git status). Use 'read' to inspect specific file contents. Use 'list' to browse directories. This is your primary review tool — always check status after the agent writes code.

opencode_findA

Search the codebase through OpenCode. Use 'text' to grep file contents, 'files' to find files by name, 'symbols' to find code symbols (functions, classes, etc). Useful for understanding the codebase before sending tasks to the agent.

opencode_projectA

Get project info and available agents/commands. Actions: current (current project), list (all projects), agents (list available agents — use to know what agent names to pass to prompt/shell), commands (list available slash commands for session command action), vcs (git/VCS info — branch, status, etc.)

opencode_configB

Manage OpenCode configuration. Actions: get (full config), providers (list providers and default models), update (modify config)

opencode_authC

Set provider authentication. Action: set (configure API key for a provider)

opencode_ptyB

Manage terminal (PTY) sessions. Actions: list (all PTY sessions), create (new terminal with command/args/cwd), get (session by ID), update (resize or rename), remove (close session). Skip 'connect' — it's a WebSocket upgrade.

opencode_toolA

Discover available tools in OpenCode. Actions: ids (list all tool IDs), list (get tools with JSON schema for a specific provider/model).

opencode_providerB

Manage AI providers. Actions: list (all providers with models and connection status), auth (get auth methods per provider), authorize (start OAuth flow), callback (complete OAuth flow with authorization code).

opencode_mcp_serverB

Manage MCP servers within OpenCode. Actions: status (all server statuses), add (register new server), connect (connect to server), disconnect (disconnect from server), auth_remove (remove auth), auth_start (start auth flow), auth_callback (complete auth with code), auth_authenticate (authenticate with server).

opencode_instructionsA

Get the full OpenCode MCP workflow guide and tool reference. Call this when you need a refresher on how to use the OpenCode tools, the recommended workflow, or best practices. No parameters needed.

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

TDQS

A3.6/5.0

Scored across 12 tools

Disambiguation3/5

Top-level names are largely resource-specific, but opencode_session bundles prompt/command/shell/diff/todo/permission, overlapping with opencode_message, opencode_file, opencode_pty, and opencode_project. Provider/auth/config actions also have related purposes, so descriptions help but some selection ambiguity remains.

Naming Consistency5/5

All tools follow the same opencode_<resource> snake_case pattern, with actions consistently expressed as parameters inside each tool. There is no mixing of camelCase, verb styles, or arbitrary prefixes.

Tool Count5/5

12 tools is within a well-scoped range and each maps to a distinct OpenCode domain such as sessions, messages, files, search, projects, config, auth, PTY, providers, MCP servers, and instructions. The only heaviness comes from opencode_session's action surface, not the tool count itself.

Completeness5/5

The surface covers the full workflow: session lifecycle and prompting, history review, file inspection, codebase search, project/agent discovery, config and auth, terminal sessions, providers, and MCP server management. There are no obvious missing lifecycle operations for the stated purpose.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues