NewJobs: scheduled actions created from chat, personal or shared.Learn more
Guides

OpenCode

Use Memtro from OpenCode, and OpenCode as Memtro's agent engine.

Open Memtro

There are three ways to put OpenCode and Memtro together. Pick the one that matches what you want.

1. Memtro's tools inside OpenCode (MCP)

Give your OpenCode sessions Memtro's memory and your connected systems as tools.

  1. Create an API key on Dashboard → API keys.
  2. Add Memtro as a remote MCP server in opencode.json (project or global):
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "memtro": {
      "type": "remote",
      "url": "https://platform.memtro.com/api/mcp",
      "enabled": true,
      "headers": { "Authorization": "Bearer sk-memtro-..." }
    }
  }
}
  1. Start OpenCode. The tools appear as memtro_memtro_search, memtro_hubspot_search, and so on (OpenCode prefixes MCP tools with the server name; OpenCode v2 may expose them through its code-mode execute tool instead).

Try: "Use memtro to find who owns the billing migration and when it launches." or "Look up Help Scout ticket 2450 through memtro and check the customer in HubSpot."

2. Memtro as a model provider in OpenCode

Route OpenCode's own model calls through Memtro, so every session gets memory injected and facts extracted. OpenCode supports custom OpenAI-compatible providers:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "memtro": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Memtro",
      "options": {
        "baseURL": "https://platform.memtro.com/v1",
        "apiKey": "sk-memtro-..."
      },
      "models": {
        "auto": { "name": "Memtro auto (routed)" },
        "memtro": { "name": "Memtro default model" },
        "anthropic/claude-opus-5": { "name": "Claude Opus 5 via Memtro" }
      }
    }
  },
  "model": "memtro/auto"
}

OpenCode's own tools (files, bash) keep working because OpenCode executes them; Memtro only sees the conversation and adds its memory. Memtro's server tools are not used in this mode unless you also add the MCP server from section 1.

3. OpenCode as Memtro's agent engine

Make Memtro run its agent mode through OpenCode. This happens on the Memtro server, sandboxed in Docker, and works with any provider key you have added (Anthropic, OpenAI, Google, OpenAI-compatible).

  • Per request: "memtro": {"mode": "agent", "engine": "opencode"}.
  • As a default: Dashboard → Routing → Agent mode → Harness: OpenCode.

Each request runs opencode run --format json in a throw-away container with every built-in tool disabled and Memtro's tools attached over MCP with a short-lived token for that user. Progress streams back as reasoning_content. If the operator has not built the OpenCode image, Memtro falls back to the native engine and says so in memtro.engine_note.

Troubleshooting

  • 401 from the MCP server: the header must be exactly Authorization: Bearer sk-memtro-…; keys are shown once when created.
  • No connector tools: connect the system on Dashboard → Connections first; MCP only exposes connections you (or your organisation) have.
  • Tools missing in OpenCode v2: look for the execute code-mode tool; MCP tools are callable from there.