π‘ Alternative Available
Check out opencode-cursor-auth by POSO-PocketSolutions - another implementation you may want to consider.
β οΈ Experimental Project - Use at Your Own RiskThis is a highly experimental project with limited support. It integrates with Cursor services via an unofficial interface, which means:
- It may break at any time without notice if Cursor changes their services
- No guarantees of stability, compatibility, or continued functionality
- "It Works On My Machineβ’" - your mileage may vary
- Not affiliated with or endorsed by Cursor - this is an unofficial community project
If it stops working, feel free to open an issue, but fixes depend on community contributions and ongoing compatibility work.
βοΈ Legal Disclaimer
This project may violate Cursor's Terms of Service.
Potential consequences include:
- Your Cursor account being suspended or terminated
- Loss of access to Cursor services
By using this project, you acknowledge these risks and accept full responsibility. This project is provided for educational and research purposes. The authors are not responsible for any consequences of using this software.
An OpenCode plugin that enables using Cursor's AI backend with OpenCode, featuring OAuth authentication, dynamic model discovery, and full tool calling support.
- OpenCode Plugin: Native integration with OpenCode via OAuth authentication
- Full Tool Calling Support: Complete support for function calling with bash, read, write, list, glob/grep
- Dynamic Model Discovery: Automatically fetches available models from Cursor's API
- Streaming Support: Real-time streaming responses via SSE
Add the plugin and Cursor provider to your opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [
"yet-another-opencode-cursor-auth"
],
"provider": {
"cursor": {
"name": "Cursor"
}
}
}Run OpenCode and authenticate:
opencode auth loginThen:
- Select "other" from the provider list
- Type "cursor" as the provider name
- Select "OAuth with Cursor"
- Complete the browser-based OAuth flow
That's it! The plugin will:
- Handle OAuth authentication with Cursor
- Automatically discover and register all available models
- Provide a custom fetch handler (no proxy server needed)
Models are fetched dynamically from Cursor's API. Common models include:
auto- Auto-select best modelsonnet-4.5- Claude 4.5 Sonnetsonnet-4.5-thinking- Claude 4.5 Sonnet (Thinking)opus-4.5- Claude 4.5 Opusgpt-5.1- GPT 5.1gemini-3-pro- Gemini 3 Pro
Use the OpenCode model picker to see all available models.
The plugin supports full OpenAI-compatible tool calling. Cursor's built-in tools are mapped to OpenAI function calls:
| Cursor Tool | OpenAI Function | Description |
|---|---|---|
shell |
bash |
Execute shell commands |
read |
read |
Read file contents |
write |
write |
Write/create files |
ls |
list |
List directory contents |
grep |
grep / glob |
Search file contents / patterns |
mcp |
Original name | MCP tool passthrough |
βββββββββββββββ βββββββββββββββββββ βββββββββββββββ
β OpenCode ββββββΆβ Plugin Fetch ββββββΆβ Cursor β
β βββββββ (no server) βββββββ API β
βββββββββββββββ βββββββββββββββββββ βββββββββββββββ
The plugin intercepts OpenCode's API requests and routes them directly to Cursor's Agent API via a custom fetch handler - no proxy server required.
Note: The standalone proxy server is primarily a development artifact used for testing and debugging. Most users should use the OpenCode plugin above.
For development, testing, or use with other OpenAI-compatible clients, a standalone proxy server is included.
- Bun v1.3.2+
- A Cursor account with valid credentials
# Clone and install
git clone https://github.com/Yukaii/yet-another-opencode-cursor-auth.git
cd yet-another-opencode-cursor-auth
bun install
# Authenticate first
bun run demo:login
# Start the server
bun run server
# Or with custom port
PORT=8080 bun run serverThe server starts on http://localhost:18741 by default.
| Endpoint | Method | Description |
|---|---|---|
/v1/chat/completions |
POST | Chat completions (streaming/non-streaming) |
/v1/models |
GET | List available models |
/health |
GET | Health check |
# Simple chat completion
curl http://localhost:18741/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "sonnet-4.5",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'
# List available models
curl http://localhost:18741/v1/modelsimport OpenAI from "openai";
const client = new OpenAI({
baseURL: "http://localhost:18741/v1",
apiKey: "not-needed", // Auth is handled by the server
});
const response = await client.chat.completions.create({
model: "sonnet-4.5",
messages: [{ role: "user", content: "Explain quantum computing" }],
stream: true,
});
for await (const chunk of response) {
process.stdout.write(chunk.choices[0]?.delta?.content || "");
}| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 18741 |
CURSOR_ACCESS_TOKEN |
Direct access token | - |
CURSOR_DEBUG |
Enable debug logging | 0 |
CURSOR_SESSION_REUSE |
Session reuse for tool calls | 1 (enabled) |
yet-another-opencode-cursor-auth/
βββ src/
β βββ server.ts # Standalone proxy server (dev artifact)
β βββ index.ts # Plugin exports
β βββ lib/
β β βββ api/
β β β βββ agent-service.ts # Cursor Agent API client
β β β βββ cursor-models.ts # Model discovery
β β βββ auth/ # Authentication helpers
β β βββ openai-compat/ # Shared OpenAI compatibility layer
β β βββ storage.ts # Credential storage
β βββ plugin/
β βββ plugin.ts # OpenCode plugin implementation
βββ docs/ # Documentation
βββ scripts/ # Utility scripts
- Authentication Flow - Detailed auth documentation
- Cursor API Reference - Cursor's API protocol
- OpenCode Plugin - Plugin implementation details
- Usage Metrics: Token usage is estimated, not exact.
- Session Reuse: Enabled by default. Set
CURSOR_SESSION_REUSE=0to disable if you encounter issues.
# Run tests
bun test
# Run server with debug logging
CURSOR_DEBUG=1 bun run server
# Run demo scripts
bun run demo:status # Check auth status
bun run demo:login # Interactive login
bun run demo:logout # Clear credentialsThis repo intentionally does not commit build output under dist/.
mkdir -p dist
bun build src/index.ts --outfile dist/index.js
bun build src/plugin/index.ts --outfile dist/plugin.jsRun bun run demo:login to authenticate, or set CURSOR_ACCESS_TOKEN environment variable.
Ensure you're including the tools array in your request. The proxy only emits tool calls when tools are provided.
Set CURSOR_DEBUG=1 to enable verbose logging for troubleshooting.
MIT
- Built by implementing an OpenCode plugin against Cursor services
- Uses Bun for fast TypeScript execution
- Protocol buffers handled via @bufbuild/protobuf