Skip to content

About

MCP server for OpenCode, built on the OpenCode .NET SDK

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

166 Commits

Folders and files

Repository files navigation

OpenCode MCP

NuGet GitHub Packages CI Linux Tests Windows Tests macOS Tests

Unofficial. This project is not affiliated with or endorsed by the opencode team.

opencode-mcp is an MCP server for OpenCode. An MCP client, such as a coding assistant or an editor, connects to it over the Model Context Protocol and uses its MCP tools. It is a thin adapter over the OpenCode .NET SDK, built to ship as a native executable that needs no installed .NET runtime.

The server's contract is to:

  • run over standard input and output by default, or as a loopback-only Streamable HTTP endpoint on request;
  • speak MCP revision 2026-07-28;
  • offer one MCP tool, bootstrap_ping, a connectivity probe that returns pong opencode-mcp <version> and checks only the connection between the MCP client and this server, not OpenCode or a model provider;
  • ship as a NuGet MCP tool package and as native executables for Windows, Linux, and macOS on x64 and Arm64.

Each release is published through three channels from one verified build: NuGet MCP tool packages on NuGet.org and on GitHub Packages, and native archives with install scripts on GitHub Releases. All three carry the same native payloads; NuGet.org adds its repository signature to the packages. See the roadmap for current availability.

Install

Pick the channel that fits the machine. Replace <version> with the exact release version (without a leading v); every command below pins it and never resolves "latest". The commands need a published version: before a release exists, its packages, archives and script URLs do not.

NuGet tool (needs the .NET 10 SDK)

Install the command once, then start it as opencode-mcp:

dotnet tool install -g OpenCodeDotNet.Mcp --version <version>
opencode-mcp --transport stdio

Or let an MCP client start it on demand through dnx, with nothing installed beforehand. -v minimal keeps acquisition messages off the protocol stream:

dotnet dnx -v minimal OpenCodeDotNet.Mcp@<version> --yes -- --transport stdio

The package set is one root package, OpenCodeDotNet.Mcp, and one native package per runtime (OpenCodeDotNet.Mcp.<rid>); the SDK selects the native package for the machine. The installed command runs the native executable directly; it does not need the .NET runtime to run.

To use GitHub Packages instead of NuGet.org, copy packaging/github-packages.nuget.config, which maps the OpenCodeDotNet.Mcp packages to https://nuget.pkg.github.com/opencode-dotnet/index.json. Add credentials for its opencode-dotnet source: your GitHub user name and a personal access token (classic) with read:packages. GitHub Packages requires them even for public packages. Then add --configfile <that file> to the dotnet tool install command, or to the dotnet dnx command before --yes and the -- separator.

Native archives (no .NET needed)

Each release has one archive per runtime, opencode-mcp-<version>-<rid>.zip for Windows and .tar.gz for Linux and macOS, and a SHA256SUMS file. Download the archive for the machine, compare its SHA-256 with SHA256SUMS, extract it and run opencode-mcp. The install scripts below do the same and also place the command.

Preview binaries are not signed with a publisher identity. The macOS command is ad hoc signed and not notarized. On macOS, a browser download usually carries the quarantine attribute, and tar can pass it to the extracted command. Gatekeeper then holds the command at its first launch and asks for confirmation. After you verify the archive and extract it, check the command with xattr -l ./opencode-mcp. If the output lists com.apple.quarantine, remove it before the first launch: xattr -d com.apple.quarantine ./opencode-mcp. On Windows, SmartScreen can warn about a downloaded archive.

Install scripts

The scripts are assets of each release. These pinned commands install that release, with no “latest” lookup:

curl -fsSL https://github.com/opencode-dotnet/opencode-mcp/releases/download/v<version>/install.sh | sh
curl -fsSL https://github.com/opencode-dotnet/opencode-mcp/releases/download/v<version>/install.sh |
    sh -s -- --add-to-path
irm https://github.com/opencode-dotnet/opencode-mcp/releases/download/v<version>/install.ps1 | iex

& ([scriptblock]::Create(
    (irm 'https://github.com/opencode-dotnet/opencode-mcp/releases/download/v<version>/install.ps1')
)) -AddToPath

Download/read/run is recommended when you want to inspect or independently verify the script: download install.sh or install.ps1 and SHA256SUMS from the same pinned release, read the script, and compare its SHA-256 with that file before running it. Checksums verify integrity, not publisher authenticity; a script executing through a pipe cannot authenticate itself.

curl -fsSL 'https://github.com/opencode-dotnet/opencode-mcp/releases/download/v<version>/install.sh' -o install.sh
# Read install.sh and verify its SHA-256 before this step.
sh ./install.sh --version '<version>'
Invoke-WebRequest 'https://github.com/opencode-dotnet/opencode-mcp/releases/download/v<version>/install.ps1' -OutFile install.ps1
# Read install.ps1 and verify its SHA-256 before this step.
Unblock-File ./install.ps1
& ./install.ps1 -Version '<version>'

irm | iex executes script text without the execution-policy check. A downloaded unsigned install.ps1 needs Unblock-File (or -ExecutionPolicy Bypass for that one PowerShell process) to run; do not change the machine-wide execution policy.

Unix defaults to a command link in ${XDG_BIN_HOME:-~/.local/bin} and payload/records in ${XDG_DATA_HOME:-~/.local/share}/opencode-mcp. Windows defaults to %LOCALAPPDATA%\Programs\opencode-mcp\current for the complete payload and command. No PATH change occurs without --add-to-path / -AddToPath. The scripts verify the complete native archive before extraction, need no .NET runtime, configure no MCP client and start no daemon.

To upgrade, rerun a downloaded script with the new explicit version and the same directories. To uninstall, use those same directories (omit directory options if you used the defaults):

sh ./install.sh --version '<version>' --install-dir '<install-dir>' --data-dir '<data-dir>'
sh ./install.sh --uninstall --install-dir '<install-dir>' --data-dir '<data-dir>'
& ./install.ps1 -Version '<version>' -InstallDir '<install-dir>'
& ./install.ps1 -Uninstall -InstallDir '<install-dir>'

On Windows, -InstallDir is the parent of current, not current itself. Upgrades preserve an owned PATH entry without repeating -AddToPath; PATH changes apply to future sessions, not the current terminal. Uninstall removes only owned state and refuses changed files or ambiguous PATH ownership. See the install-script contract for supported hosts, prerequisites, options, layout and diagnostics.

Run from source

From the repository root, build Release. Run every build and test command with an owned ASPIRE_HOME under your temp folder, and keep it until the tests finish: without it, the AppHost SDK installs the Aspire bundle into the shared %USERPROFILE%/.aspire directory. Set ASPIRE_HOME to an owned directory named opencode-mcp-aspire-home under your system temp folder before the first build.

dotnet build OpenCode.Mcp.slnx --configuration Release

Standard input and output

Launch the built assembly directly, not through dotnet run, so build output cannot enter the protocol stream:

dotnet ./src/OpenCode.Mcp/bin/Release/net10.0/OpenCode.Mcp.dll --transport stdio

Configure a local MCP client's command as dotnet and its arguments as the absolute path to that OpenCode.Mcp.dll, followed by --transport and stdio. Standard input and output belong to the client; diagnostic logs go to standard error. Omitting --transport also selects stdio. Standard output contains protocol messages only: no banner, log line, or prompt. When the client closes standard input, the stdio session ends, the host shuts down, and the process exits with code 0. No extra shutdown request is required.

The client must support MCP revision 2026-07-28: discover with server/discover, list tools, then call bootstrap_ping with no arguments. Its result is exactly pong opencode-mcp <version>, where <version> is the product assembly's informational version without source metadata. This verifies connectivity only; it does not contact OpenCode or a model provider.

Local Streamable HTTP

dotnet ./src/OpenCode.Mcp/bin/Release/net10.0/OpenCode.Mcp.dll --transport http --urls http://127.0.0.1:0 --environment Development

Port 0 requests an available port. Read the actual address from the Now listening on: lifetime log on standard error and append /mcp for the client's Streamable HTTP endpoint. The endpoint is stateless and uses the same protocol and tool as stdio. /health and /alive are available only in Development; without that environment they return 404. Ctrl+C stops the host.

HTTP is loopback-only, without authentication or a CORS policy. Host and Origin checks apply to every request; a missing Origin is allowed. Do not expose the endpoint through a public proxy or tunnel. See local HTTP exposure for accepted listening addresses and headers, defaults, and refusal responses.

An invalid transport selector writes a diagnostic naming stdio and http to standard error and exits with code 2 before creating a host. Values are case-sensitive; use the separate-token --transport http spelling, not --transport=http. Other startup failures are not selector refusals.

Build and run a local native executable

You can build a local native payload from source with the repository-selected .NET SDK. Keep the owned ASPIRE_HOME from the source-build instructions. On Windows x64, install Visual Studio or Build Tools with Desktop development with C++, MSVC x64 tools and a Windows SDK first. The tool checks the standard Installer vswhere.exe, component, SDK libraries, linker and export inspector; it adds the Installer folder only to its publish child's PATH, not your machine settings. It installs no prerequisite.

From the repository root on Windows x64:

dotnet run tools/native.cs -- verify --rid win-x64
dotnet run tools/native.cs -- stage --rid win-x64 --publish-directory artifacts/native/win-x64/publish

Use the lowercase tools/native.cs spelling. verify publishes and tests the native product; stage tests the normalized payload and its extracted ZIP. Both must exit zero. Receipts, logs, symbols and the payload inventory are build evidence outside the runtime payload. The archive is artifacts/native/win-x64/opencode-mcp-win-x64.zip; extract all its files together, including license, notices and metadata. Launch the extracted opencode-mcp.exe directly with --transport stdio, or with --transport http --urls http://127.0.0.1:0 --environment Development for HTTP.

For a local MCP client, set the command to the absolute extracted opencode-mcp.exe path and the arguments to --transport, stdio. Native execution needs no installed .NET runtime; building and verification still need the SDK. The transports, protocol and HTTP restrictions are the same as above. A source-built Windows payload is not six-platform support or an official release.

Developing

Building the repository needs the .NET SDK version that global.json selects.

For orchestrated HTTP development, use the repository's pinned Aspire local tool from the root. Give its bundle, CLI state and dashboard data an owned directory before the first build: set ASPIRE_HOME as above and ASPIRE_DASHBOARD_DATA_DIRECTORY to its dashboard subdirectory.

dotnet tool restore
dotnet tool run aspire start --apphost src/OpenCode.Mcp.AppHost/OpenCode.Mcp.AppHost.csproj --isolated --format Json --non-interactive
dotnet tool run aspire wait mcp --apphost src/OpenCode.Mcp.AppHost/OpenCode.Mcp.AppHost.csproj --status healthy --timeout 120 --non-interactive
dotnet tool run aspire describe mcp --apphost src/OpenCode.Mcp.AppHost/OpenCode.Mcp.AppHost.csproj --format Json --non-interactive

Use the discovered http authority plus /mcp; no port is fixed. This starts only the MCP product, not OpenCode or a model provider. Stop the run you started when finished:

dotnet tool run aspire stop --apphost src/OpenCode.Mcp.AppHost/OpenCode.Mcp.AppHost.csproj --non-interactive

Do not start this exact AppHost path over somebody else's run. The local tool pins the CLI paired with the AppHost SDK rather than using a global Aspire installation. --isolated isolates ports, not the machine profile: hosting still uses the real .aspire/cli/bch and .aspire/dev-certs paths and can use the developer-certificate store. The full state boundary is documented in hosting and packaging. Keep dashboard stores and login URLs private.

Before a pull request opens, run the local check that docs/engineering/quality-gates.md describes; it has the exact commands. A Native AOT publish on Windows has extra machine prerequisites, listed in docs/architecture/hosting-and-packaging.md.

Contributors and coding agents start at AGENTS.md, which routes each kind of work to its canon; GLOSSARY.md defines the terms this repository uses.

See Contributing for issues, review and pull requests. CI must check managed Release builds and all test modules on Windows, Linux and macOS; these checks do not prove native or package support. Quality gates own the CI contract, and the roadmap records hosted verification and protection status.

Status

Category Platform Status
Build Windows, Linux, macOS CI
Tests Linux Linux Tests
Tests Windows Windows Tests
Tests macOS macOS Tests
Package NuGet.org GitHub Packages
OpenCodeDotNet.Mcp NuGet GitHub Packages

License

Licensed under MIT, see LICENSE for the full text. Content derived from the OpenCode .NET SDK repository carries its own notice in THIRD-PARTY-NOTICES.md.

About

MCP server for OpenCode, built on the OpenCode .NET SDK

Resources

Code of conduct

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages