Skip to content
kmem

Connect OpenCode

OpenCode reads kmem from its global configuration file. You add kmem once, and every project can then use it.

The Connect screen marks OpenCode Not yet tested with kmem. The steps on this page come from the OpenCode documentation.

Create a connection

  1. In kmem, select Connect. The MCP tab opens.
  2. Select OpenCode in the list of clients.
  3. Fill in the New connection form, for example with the name "OpenCode on Maya's laptop".
  4. Select Create connection.

Create a connection explains each field. Copy the token now. kmem shows it only one time.

Merge the configuration

OpenCode keeps its global configuration in the file ~/.config/opencode/opencode.json.

  1. Under Configuration for OpenCode, select Copy configuration.
  2. Open ~/.config/opencode/opencode.json in a text editor. If the file does not exist, create it.
  3. Merge the kmem configuration into the file:
  4. If the file is empty or new, paste the whole configuration.
  5. If the file already has an mcp section, add only the kmem entry inside it. Keep your other MCP servers.
  6. Keep the other settings of the file as they are.
  7. Save the file.

The configuration looks like this:

{
  "mcp": {
    "kmem": {
      "type": "remote",
      "url": "https://acme.kmem.app/mcp",
      "oauth": false,
      "headers": {
        "Authorization": "Bearer YOUR_TOKEN"
      }
    }
  }
}

Replace acme with your org's subdomain and YOUR_TOKEN with the token of your connection. The Connect screen fills in both for you.

Do not put kmem in a project file of OpenCode. A team can commit a project file to a shared repository, and the file would then show your token.

Start OpenCode again and check

  1. Start OpenCode again. OpenCode reads the configuration when it starts.
  2. Check that kmem is connected.
  3. Send the check prompt:
Use kmem to list the docs I can access. If there are none, say so.
  1. In kmem, select Check connection. The three checks must show Complete.

If kmem is not connected, check these points:

  • The file is valid JSON.
  • The url ends with /mcp.
  • The token belongs to an active connection.

Why the configuration turns off OAuth

OpenCode can try to sign in to a remote MCP server with OAuth. kmem offers OAuth sign-in too, but this configuration uses a token. The line "oauth": false tells OpenCode to use only the Authorization header. Without it, OpenCode can try a sign-in that you do not need.

Keep the line in the configuration.

Next steps