Skip to content

Conversation

@lenstr
Copy link
Contributor

@lenstr lenstr commented Jan 9, 2026

Summary

Fixes the OAuth tool calling that broke after PR #10's oc_ prefix was blocked by Anthropic.

This is a port of the solution from pi-coding-agent which encountered and fixed the same issue.

Changes

  1. Changed prefix from oc_ to mcp_ - This is what pi-coding-agent uses for Anthropic OAuth.

  2. Added prefix to tool_use blocks in messages - PR fix: claude oauth by renaming tools on in/out #10 only prefixed tool definitions, but not tool calls in conversation history. This caused issues when the model tried to continue conversations with previous tool calls.

Testing locally

  1. Clone and checkout this branch:
git clone https://github.com/lenstr/opencode-anthropic-auth.git
cd opencode-anthropic-auth
git checkout fix/mcp-tool-prefix
  1. Add to your opencode.json:
{
  "plugin": [
    "file://<path-to>/opencode-anthropic-auth/index.mjs"
  ]
}
  1. Run with default plugins disabled:
OPENCODE_DISABLE_DEFAULT_PLUGINS=true opencode

Reference

- Change TOOL_PREFIX from 'oc_' to 'mcp_'
- Add prefix to tool_use blocks in messages, not just tool definitions
- Update stream transform regex to strip mcp_ prefix from responses
@lenstr lenstr changed the title fix: use mcp_ prefix for tools (matches Claude Code) fix: use mcp_ prefix for tools (port from pi-coding-agent) Jan 9, 2026
@DavidNorena
Copy link

DavidNorena commented Jan 9, 2026

Question guys, im just getting used to use opencode

could i temporarily clone this and test it locally like this ?

opencode.json
{
  "plugin": [
    "/home/myuser/.local/share/opencode-anthropic-auth"
  ],
  "$schema": "https://opencode.ai/config.json"
}

so far is not working for me

@lenstr
Copy link
Contributor Author

lenstr commented Jan 9, 2026

Use file:// URL pointing to the index.mjs file:

{
  "plugin": [
    "file://<path-to>/opencode-anthropic-auth/index.mjs"
  ]
}

@devxoul
Copy link

devxoul commented Jan 9, 2026

You such a genius. I can confirm this works.

@DavidNorena
Copy link

should i select use api keys or claude pro sub when i connect, so far is not working for me

{
  "plugin": [
    "file:///home/myuser/.local/share/opencode-anthropic-auth/index.mjs"
  ],
  "$schema": "https://opencode.ai/config.json"
}

@lenstr
Copy link
Contributor Author

lenstr commented Jan 9, 2026

Ah yes, you should run it like this:

OPENCODE_DISABLE_DEFAULT_PLUGINS=true opencode

@DavidNorena
Copy link

confirm !! it works ! thanks so much !

@rekram1-node rekram1-node merged commit 70233ba into anomalyco:master Jan 9, 2026
devxoul added a commit to devxoul/opencode-anythropic-auth that referenced this pull request Jan 9, 2026
@kent-3 kent-3 mentioned this pull request Jan 9, 2026
@Profpatsch
Copy link

We’re so back!

@ai-vampire
Copy link

hi @lenstr , thanks for this solution but im getting this error: "ish: Job 1, 'OPENCODE_DISABLE_DEFAULT_PLUGIN...' terminated by signal SIGABRT (Abort)"
when i starting opencode with this command: "OPENCODE_DISABLE_DEFAULT_PLUGINS=true opencode"

@lenstr
Copy link
Contributor Author

lenstr commented Jan 9, 2026

This should be fixed in the latest opencode version. Try updating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants