opencode-samcp
Sub-Agent MCP — an MCP server that lets an AI agent (Devin, Codex, Claude Code, Cursor, …) spawn opencode sessions as sub-agents and hand them coding work.
The parent agent calls opencode_run with a prompt and a directory; opencode does the work headlessly (opencode run --format json --auto) and the result comes back as structured data: final message, tool-call summary, errors, token usage and cost. Sessions can be continued, forked, run in parallel in the background, inspected and deleted.
Requirements
Install / run
The server is Python; every option below needs uv and opencode on the machine.
| Method | Command |
|---|---|
| npx (no install) | npx -y opencode-samcp |
| npm (global) | npm i -g opencode-samcp then opencode-samcp |
| uvx from PyPI | uvx opencode-samcp |
| uvx from GitHub | uvx --from git+https://github.com/amirdaraby/opencode-samcp opencode-samcp |
| pip | pip install opencode-samcp then opencode-samcp |
The npm package is a thin launcher: it bundles the Python server and runs it through uvx.
If uv or opencode is missing, it exits with a clear "not installed on machine" error.
Configure your client
Devin
Settings → MCP Marketplace → Add Your Own (STDIO):
| Field | Value |
|---|---|
| Command | npx |
| Args | -y opencode-samcp |
Devin runs in its own VM, so opencode must be installed and logged in there (add it to the machine setup / snapshot).
Codex (~/.codex/config.toml)
[mcp_servers.opencode]
command = "npx"
args = ["-y", "opencode-samcp"]
Claude Code
claude mcp add opencode -- npx -y opencode-samcp
Generic JSON
{ "mcpServers": { "opencode": { "command": "npx", "args": ["-y", "opencode-samcp"] } } }
HTTP transport
For clients that only speak remote MCP:
opencode-samcp --transport streamable-http --host 127.0.0.1 --port 8765 # endpoint: /mcp
opencode-samcp --transport sse ... # endpoint: /sse
There is no authentication and the sub-agent can edit files and run commands — keep it on localhost or behind an authenticated tunnel/proxy.
Tools
| Tool | Purpose |
|---|---|
opencode_run |
Start a session (or continue session_id, optionally fork) in directory. Waits up to wait_seconds (default 600); 0 runs in the background. Supports model, agent, title, files, auto_approve. |
opencode_job |
Poll/wait on a background job by job_id. |
opencode_jobs |
List jobs started by this server. |
opencode_cancel |
Stop a running job (session is kept). |
opencode_sessions |
List opencode sessions for a project directory. |
opencode_transcript |
Condensed transcript of a session. |
opencode_delete_session |
Delete a session and its children. |
Parallel work: start several jobs with wait_seconds=0, each in its own git worktree so they don't clash, then poll with opencode_job.
Environment variables
| Var | Meaning |
|---|---|
OPENCODE_BIN |
Path to the opencode binary (default opencode) |
OPENCODE_MODEL |
Default provider/model when the caller doesn't pass one |
Security
auto_approve defaults to true (required for headless runs): the sub-agent can modify files and run shell commands in the given directory. Only expose this server to agents you trust, and point it at disposable checkouts/worktrees where possible.
Notes
- Job state is in-memory; it is lost when the server process restarts (opencode sessions themselves persist and can be resumed by
session_id).
Publishing (maintainers)
Releases are automated: pushing a vX.Y.Z tag runs .github/workflows/publish.yml, which publishes to PyPI and npm (both via trusted publishing, no tokens). Use the helper so versions and tag never drift apart:
scripts/release.sh 0.0.4
It bumps pyproject.toml, package.json and uv.lock, runs the tests, commits, pushes main, then tags and pushes v0.0.4.
Development
uv run --group dev pytest
MIT licensed.
Metadata
Release files for opencode-samcp 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| opencode_samcp-0.0.4.tar.gz | 84.2 kB | Without provenance | Details for opencode_samcp-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| opencode_samcp-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for opencode_samcp-0.0.4-py3-none-any.whl |
Total release size: 93.1 kB
Release files / opencode_samcp-0.0.4.tar.gz
| Download URL | opencode_samcp-0.0.4.tar.gz |
|---|---|
| Size | 84.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
22fac629c53934daf2270be5341e56fc318ce2d05ffc801f4aec390cbdc5fef3
|
|
BLAKE2b-256 checksum How to use checksums |
f0a6975797de164cec38fb1157b7289f0bfa7ac7820d893194ec1cda83ee7a25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / opencode_samcp-0.0.4-py3-none-any.whl
| Download URL | opencode_samcp-0.0.4-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a16faab7401787620b1dc7315e63811e9080257f02b34eb40a89d51030afbab3
|
|
BLAKE2b-256 checksum How to use checksums |
4aa6b8d877abd2e0e5d21cd9e73e5656cccdf3a70738312663ce80dabe2dae27
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for opencode-samcp 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.