staqlydocs

OpenCode

Add staqly to OpenCode so it can write posts and put them on the calendar.

Edit on GitHub

Connect OpenCode to staqly as an MCP server, and OpenCode can write posts, list collections and schedule or publish them, just from your prompts. OpenCode reads MCP servers from opencode.json in your project root.

Connect to Staqly Community Edition

Start staqly

Run staqly serve (or the Docker image). See the Quickstart.

Add staqly to opencode.json

Copy this file (it ships in integrations/opencode/) or merge the mcp block into your existing config. The config reads staqly's access token (printed at every start) from STAQLY_API_KEY, so the token stays out of the file. Set it in your shell profile:

export STAQLY_API_KEY=$(staqly serve token)   # Docker: $(docker exec staqly server token)
opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "servers": {
      "staqly": {
        "type": "remote",
        "url": "http://localhost:3333/mcp",
        "headers": {
          "Authorization": "Bearer {env:STAQLY_API_KEY}"
        },
        "codemode": false,
        "timeout": { "execution": 200000 }
      }
    }
  }
}

codemode: false makes OpenCode call staqly's tools directly instead of through its code mode (the model writing a script around one execute tool), which is how they are designed and tested. The timeout gives long tool calls room. This is the OpenCode 2 format (mcp.servers); OpenCode 1 uses "mcp": { "staqly": { "type": "remote", "url": "...", "enabled": true } } and has no code mode.

Check the connection

opencode mcp list        # → ✓ staqly  connected

Tip: staqly mcp config opencode prints this file for your current CLI profile.

STDIO (Docker only)

With Docker you can use STDIO instead. It runs mcp-stdio inside the staqly container, so it needs no token, and it does not work with staqly serve:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "servers": {
      "staqly": {
        "type": "local",
        "command": ["docker", "exec", "-i", "staqly", "mcp-stdio"],
        "codemode": false,
        "timeout": { "execution": 200000 }
      }
    }
  }
}

Connect to Staqly Cloud

OpenCode substitutes {env:STAQLY_API_KEY} from the environment, so the key is not written into the file:

opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "servers": {
      "staqly": {
        "type": "remote",
        "url": "https://app.staqly.ai/mcp",
        "headers": {
          "Authorization": "Bearer {env:STAQLY_API_KEY}"
        },
        "codemode": false,
        "timeout": { "execution": 200000 }
      }
    }
  }
}

Verified

With OpenCode 2.0.25, over HTTP and STDIO, including a real list_collections call via opencode run.

Next steps

On this page