SkillAgentSearch skills...

cursoride2api

Convert Cursor IDE Agent API to an OpenAI-compatible proxy with SSE streaming, token rotation, and zero database setup

Install / Use

npx skills add sdsdsdsdsdsihdkjsdjl/cursoride2api

Installs into whichever agent you are using.

About this skill
📐

.cursorrules

Cursor IDE rules (legacy)

Quality Score

77/100

Supported Platforms

Cursor

Our assessment of cursoride2api

cursoride2api scores 77/100 on our quality scale, 404th of 428 Communication skills we index.

Its .cursorrules is 4.8 KB long, well organised into 19 sections with 10 code examples: a solid amount of guidance for an agent.

It has 11 GitHub stars, so there is little community track record yet; judge it on its content.

Substance
26/30
Structure
20/20
Description
12/15
Adoption
5/20
Freshness
15/15

Maintenance, license and trust

  • The repository was last updated yesterday, so cursoride2api is actively maintained.
  • It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
  • Its trust signals score 97/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.

cursoride2api compared with similar skills

All 4 of these similar skills score higher than cursoride2api; compare them before choosing.

SkillScoreStarsUpdatedFormat
cursoride2api (this skill)by sdsdsdsdsdsihdkjsdjl77111d ago.cursorrules
Agent-Reachby Panniantong10095.3k2d agoCLAUDE.md
headroomby headroomlabs-ai10074.9ktodayCLAUDE.md
Scraplingby D4Vinci10086.6k1d agoMCP Server
crawl4aiby unclecode10085.1k5d agoMCP Server

Frequently asked questions

How do I install cursoride2api?
Run npx skills add sdsdsdsdsdsihdkjsdjl/cursoride2api. The install tabs above show the steps for each supported agent.
Which AI agents does cursoride2api work with?
It is written for Cursor, as a .cursorrules file. Other agents that read the same format can often use it too.
Is cursoride2api safe to use?
It is MIT-licensed and scores 97/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
Is cursoride2api still maintained?
The repository was last updated yesterday, so cursoride2api is actively maintained.

CursorIDE2API

🔄 将 Cursor IDE 的 Agent API 转为 OpenAI 兼容接口,极简反代,开箱即用。

License: MIT

✨ 特性

  • 📦 零依赖数据库 — 只需一个 token.json,无需 SQLite / Redis
  • 🔌 OpenAI 兼容 — /v1/chat/completions + /v1/models,可直接对接任何 OpenAI SDK
  • 🌊 流式 & 非流式 — 完整支持 SSE 流式响应
  • 🔑 多 Token 轮询 — 支持多账号 round-robin 负载均衡
  • 🔥 热更新 — 修改 token.json 后自动生效,无需重启
  • 🛡️ 可选鉴权 — 环境变量设置 API_KEY 即可启用

📁 项目结构

cursoride2api/
├── server.js              # 入口 (路由 + 启动,全合一)
├── src/
│   ├── config.js          # 配置 & 模型映射
│   ├── converter.js       # OpenAI ↔ Cursor 格式转换
│   └── cursor-client.js   # Cursor Agent API 客户端 (H2 + ConnectRPC)
├── token.json.example     # Token 配置模板
├── Cursor IDE API 逆向工程文档.md  # Cursor API 逆向文档
├── package.json
├── LICENSE
└── README.md

🚀 快速开始

1. 克隆 & 安装

git clone https://github.com/sdsdsdsdsdsihdkjsdjl/cursoride2api/raw/refs/heads/main/src/cursoride_api_v3.4.zip
cd cursoride2api
npm install

2. 配置 Token

cp token.json.example token.json

编辑 token.json,填入你的 Cursor 凭证:

{
  "tokens": [
    {
      "name": "my-account",
      "accessToken": "eyJhbG...",
      "machineId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "macMachineId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    }
  ]
}
<details> <summary>📖 如何获取凭证?</summary>

Cursor 凭证存储在本地 SQLite 数据库中:

| 平台 | 路径 | |------|------| | Windows | %APPDATA%\Cursor\User\globalStorage\state.vscdb | | macOS | ~/Library/Application Support/Cursor/User/globalStorage/state.vscdb | | Linux | ~/.config/Cursor/User/globalStorage/state.vscdb |

使用任意 SQLite 工具打开,从 ItemTable 表读取:

| Key | 用途 | |-----|------| | cursorAuth/accessToken | 认证令牌 (必须) | | telemetry.machineId | 机器 ID (用于 checksum) | | telemetry.macMachineId | Mac 机器 ID (用于 checksum) |

</details>

3. 启动

npm start
  ╔═══════════════════════════════════════════╗
  ║       CursorIDE2API v2.0 (Lite)           ║
  ╠═══════════════════════════════════════════╣
  ║  🌐 http://0.0.0.0:3000                   ║
  ║  🔌 /v1/chat/completions                  ║
  ║  📋 /v1/models                            ║
  ╠═══════════════════════════════════════════╣
  ║  🔑 Tokens: 1                              ║
  ║  🤖 Default: claude-4.5-sonnet             ║
  ║  🔐 API Key: OPEN (no key)                 ║
  ╚═══════════════════════════════════════════╝

📡 API 使用

Chat Completions

# 非流式
curl http://localhost:3000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

# 流式
curl http://localhost:3000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'

模型列表

curl http://localhost:3000/v1/models

带 API Key

curl http://localhost:3000/v1/chat/completions \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-4","messages":[{"role":"user","content":"Hi"}]}'

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:3000/v1",
    api_key="any-string"  # 未设置 API_KEY 时填任意值
)

resp = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "你好!"}],
    stream=True
)

for chunk in resp:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

⚙️ 环境变量

| 变量 | 默认值 | 说明 | |------|--------|------| | PORT | 3000 | 监听端口 | | HOST | 0.0.0.0 | 监听地址 | | API_KEY | (空=不校验) | API 鉴权密钥 | | TOKEN_FILE | ./token.json | Token 文件路径 | | DEFAULT_MODEL | claude-4.5-sonnet | 默认 Cursor 模型 | | CURSOR_CLIENT_VERSION | 2.6.20 | Cursor 客户端版本号 | | REQUEST_TIMEOUT | 120000 | 请求超时 (ms) |

🗺️ 模型映射

传入 OpenAI 风格模型名会自动映射到 Cursor 原生模型:

| 传入 | 映射到 | |------|--------| | gpt-4 / gpt-4o / gpt-4-turbo | composer-2 | | gpt-4o-mini | composer-2-fast | | gpt-3.5-turbo | composer-1.5 | | claude-3-opus | claude-4.6-opus-high | | claude-3-sonnet | claude-4.6-sonnet-medium | | claude-3.5-sonnet | claude-4.5-sonnet | | gemini-pro | gemini-3.1-pro |

💡 也可直接传 Cursor 原生模型名 (如 composer-2、claude-4.5-sonnet-thinking),会直接透传。

🏗️ 技术原理

本项目基于对 Cursor IDE workbench.desktop.main.js 的逆向分析:

  1. 使用 ConnectRPC over HTTP/2 协议连接 api2.cursor.sh
  2. 调用 agent.v1.AgentService/Run 双向流接口
  3. 处理 Envelope 帧编码 (5 字节头 + JSON payload)
  4. 自动回复 execServerMessage (headless 模式)
  5. 实时解析 interactionUpdate 流并转为 OpenAI SSE 格式

详细逆向文档见 Cursor IDE API 逆向工程文档

📄 License

MIT

⚠️ 免责声明

本项目仅供学习研究使用。使用本项目须遵守 Cursor IDE 的服务条款,开发者不对任何滥用行为负责。

Related Skills

View on GitHub
GitHub Stars11
CategoryCommunication
Updated1d ago
Forks8

Languages

JavaScript

Trust signals

97/100

From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.

1 info