Files
Omar McAdam 49dfdca24e feat(opencode-plugin): OpenWork models and MCP in OpenCode 2 (#5838)
* feat(den): let the OpenCode plugin sign in as its own device client

Behind opencodePlugin (cloud and self-hosted, off). Den accepts the
openwork-opencode-plugin device client only while the flag is on; the
/device page names it "OpenWork - OpenCode Plugin" and, for that client
only, returns the browser to a loopback return_to after Approve or Deny.
The redirect carries the outcome only; the client still gets its session
by polling Den.

* feat(opencode-plugin): OpenWork Cloud models and MCP in OpenCode 2

New opencode-openwork package: an OpenCode 2 plugin that registers the
openwork integration (opencode auth login openwork, browser or code
device sign-in) and, on every start, injects the member's AI Gateway
providers with their gateway key and the openwork-cloud and
openwork-direct-* MCP servers from Den. Adds a docs page and a
tag-driven npm publish workflow (opencode-openwork-v*).

* test(evals): OpenCode signs in to OpenWork and returns from the browser

* fix(opencode-plugin): keep tokens on HTTPS and pin the device return page

The plugin only sends the Den session, device token or MCP token over
HTTPS, or plain HTTP to a Den on this machine, and trims base URLs
without a backtracking pattern. Den web returns the browser only to
http://127.0.0.1:<port>/openwork/callback for the plugin's client, so a
crafted link cannot aim it at other local services.

* fix(opencode-plugin): never publish another account's cached inventory

On start the plugin used the cached gateway key and MCP token without
checking they belong to the signed-in account. After an account switch
while OpenCode was closed, it could publish the previous account's
credentials until the first refresh. The cache is now used only when it
was fetched for the active connection.
2026-10-09 11:39:24 -07:00

57 lines
1.3 KiB
Plaintext

---
title: "Connect OpenCode"
sidebarTitle: "OpenCode"
description: "Add OpenWork MCP to OpenCode: add a remote MCP entry for https://api.openworklabs.com/mcp/agent to your OpenCode config, then run opencode mcp auth openwork."
---
Give OpenCode your organization's OpenWork skills, plugins, and connections. OpenCode is the verified client.
<Tip>
On OpenCode 2, the [OpenWork plugin](/model-context-protocol/opencode-plugin) also brings your AI Gateway models, with one sign-in.
</Tip>
<Steps>
<Step title="Add the server to opencode.json">
```json
{
"mcp": {
"openwork": {
"type": "remote",
"enabled": true,
"url": "https://api.openworklabs.com/mcp/agent",
"oauth": {}
}
}
}
```
</Step>
<Step title="Sign in">
```sh
opencode mcp auth openwork
```
Sign in to OpenWork in the browser and pick your organization.
</Step>
<Step title="Try it">
Ask: "Which OpenWork organization am I connected to?"
</Step>
</Steps>
<AccordionGroup>
<Accordion title="Switch organizations">
```sh
opencode mcp logout openwork
opencode mcp auth openwork
```
</Accordion>
<Accordion title="OpenCode on a remote machine or SSH host">
Follow [Connect OpenWork MCP from a remote machine](/cloud/run-in-the-cloud/connect-openwork-mcp-remote-machine).
</Accordion>
</AccordionGroup>