@otto-assistant/opencode-cursor-oauth
v2.2.0
Published
OpenCode plugin that connects Cursor's API to OpenCode via OAuth, model discovery, and a local OpenAI-compatible proxy.
Maintainers
Readme
@otto-assistant/opencode-cursor-oauth
High-quality OpenCode provider plugin that brings Cursor models into OpenCode through OAuth, model discovery, and a local OpenAI-compatible proxy.
Designed for real-world agent usage: streaming, tool calls, long conversations, and robust continuation behavior.
Highlights
- OAuth login with automatic token refresh
- Cursor model discovery directly from API
- Native OpenCode variants for Cursor effort and thinking modes
- OpenAI-compatible
/v1/chat/completionsproxy for OpenCode runtime compatibility - Stable streaming with tool-calling continuation
- MCP-first tool execution flow for practical agent environments
- Conversation-state handling built for long and tool-heavy sessions
- Production-ready smoke test coverage
Why teams use it
- Native feel in OpenCode: Cursor models are exposed as a regular provider flow in OpenCode.
- Reliable tool loops: Tool call handoff and continuation are engineered for iterative agent workflows.
- Operationally practical: Focused on reducing common runtime failure modes around streaming, tool calls, and conversation state.
- Simple integration surface: Works with standard OpenCode plugin configuration and auth flow.
Installation
Option A: Install from npm (recommended)
npm install -g @otto-assistant/opencode-cursor-oauthThen add this to ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"@otto-assistant/opencode-cursor-oauth"
],
"provider": {
"cursor": {
"name": "Cursor"
}
}
}Option B: Install from repository source
git clone https://github.com/otto-assistant/opencode-cursor.git
cd opencode-cursor
bun install
bun run build
npm install -g .Use the same OpenCode config shown above.
Authentication
opencode auth login --provider cursorThis opens Cursor OAuth in your browser. Tokens are stored in ~/.local/share/opencode/auth.json and refreshed automatically.
Quick usage
- Start OpenCode.
- Select provider
cursor. - Choose a Cursor model family and, when available, an effort or thinking variant.
- Send prompts as usual; the plugin starts the local proxy on demand.
Architecture
OpenCode
-> /v1/chat/completions
-> Bun.serve proxy
-> Node HTTP/2 bridge (h2-bridge.mjs)
-> Cursor gRPC API (api2.cursor.sh)Model variant routing
Cursor's variant-aware catalog describes context, thinking, effort, and Fast as model parameters. The plugin maps structural choices to separate OpenCode model listings, for example Opus 4.8, Opus 4.8 Thinking, Opus 4.8 1M, and Opus 4.8 1M Thinking. Fast configurations returned by Cursor receive separate Fast listings. Each listing exposes only applicable none, low, medium, high, xhigh, and max effort variants.
OpenCode's selected listing and effort are resolved in the chat.headers hook. The local proxy consumes the encoded private selection and writes Cursor's server model, parameter values, and max-mode flag to RequestedModel, while retaining ModelDetails for protocol compatibility. Generic reasoningEffort options are removed before the OpenAI-compatible request is sent, so they cannot conflict with Cursor's parameterized selection.
AvailableModels.variants is the source of truth for account- and organization-specific availability; parameter definitions never create missing combinations. If variant-aware discovery is unavailable, the plugin conservatively groups the older flat catalog and leaves ambiguous standalone IDs unchanged. The cursor/default model remains variant-free and continues to use Cursor's server-side automatic routing.
Tool-call lifecycle
1) Model receives tool definitions via request context
2) Model emits tool call
3) Proxy maps tool call into OpenCode-compatible stream events
4) OpenCode executes tool
5) Tool result is sent back
6) Proxy resumes Cursor stream continuationDevelopment
bun install
bun run build
bun run testCompatibility
- OpenCode plugin runtime
- Bun runtime
- Node.js >= 18 (HTTP/2 bridge process)
- Active Cursor subscription
Performance and reliability notes
- Conversation state is managed to support continuation across multi-turn tool usage.
- Streaming and bridge lifecycle handling are designed to minimize stuck sessions.
- Tool execution path is optimized for MCP-based environments.
FAQ
Do I need to clone the repository to use this plugin?
Usually no. OpenCode can install npm plugins automatically when configured.
Is this package published on npm?
This repository publishes under @otto-assistant/opencode-cursor-oauth. If npm install fails, verify that the latest GitHub release workflow completed successfully.
Where is the license?
This project is released under the MIT license (declared in package metadata).
License
MIT
