npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cursoride2api

v2.3.0

Published

Cursor IDE Agent API → Anthropic Messages compatible proxy

Readme

CursorIDE2API

将 Cursor IDE Agent API 转为 Anthropic Messages 兼容接口,便于对接 Claude Code / Anthropic SDK。

功能

  • POST /v1/messages:Anthropic Messages(流式 / 非流式、tool_use / tool_result
  • GET /v1/models:模型列表
  • GET /health:健康检查
  • 多 Token 轮询 + token.json 热更新
  • 可选 API_KEY 鉴权
  • Cursor execServerMessage → Claude tools 桥接(Read / Bash / Grep / Glob / Write / Edit / WebFetch / Agent 等)

未提供 OpenAI /v1/chat/completions/v1/messages/count_tokens

快速开始(npx,无需 clone)

# 前台启动,打印日志
npx cursoride2api

# 后台启动(若 token 不存在会自动 extract-token;失败则退出)
npx cursoride2api start

# 查看状态 / 停止服务
npx cursoride2api status
npx cursoride2api stop

# 从本机 Cursor IDE 提取凭证 → ~/.cursoride2api/token.json(并在终端打印账号对象)
npx cursoride2api extract-token

默认监听 http://0.0.0.0:3000。Token 默认路径:~/.cursoride2api/token.json。默认模型:composer-2.5

后台运行时,PID 写入 ~/.cursoride2api/server.pid,输出追加到 ~/.cursoride2api/server.log。关闭启动终端不会停止服务;重复执行 start 不会创建第二个进程。

# 自定义监听地址后后台启动;环境变量会传给后台进程
PORT=3011 HOST=127.0.0.1 npx cursoride2api start

# 前台运行,适合调试;Ctrl+C 停止
PORT=3011 HOST=127.0.0.1 npx cursoride2api

使用自定义 TOKEN_FILE 时,server.pidserver.log 位于该文件所在目录;后续 status / stop 需要传入相同的 TOKEN_FILE

extract-token 输出格式

成功时终端打印单个账号对象,并写入 ~/.cursoride2api/token.json

{
  "name": "account-1",
  "accessToken": "...",
  "machineId": "...",
  "macMachineId": "..."
}

文件内容为:

{
  "tokens": [
    {
      "name": "account-1",
      "accessToken": "...",
      "machineId": "...",
      "macMachineId": "..."
    }
  ]
}

依赖本机已登录 Cursor IDE,且系统可用 sqlite3 命令。

本地开发

git clone https://github.com/cddchen/cursoride2api.git
cd cursoride2api
npm install
npm run build
npm start                       # 前台运行,等同 node dist/cli.js
node dist/cli.js start          # 后台启动
node dist/cli.js status
node dist/cli.js stop
npm run extract-token
npm run test:cli-daemon         # 后台生命周期自测

也可用 TOKEN_FILE=./token.json npm start 指定仓库内 token。

API

Messages(Anthropic)

curl http://localhost:3000/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: any" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "composer-2.5",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Hello"}]
  }'

Python(Anthropic SDK)

from anthropic import Anthropic

client = Anthropic(
    base_url="http://localhost:3000",
    api_key="any",
)

msg = client.messages.create(
    model="composer-2.5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "你好"}],
)
print(msg.content)

模型列表

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

返回 Cursor 当前可用模型(账号/套餐不同列表可能变化)。常用示例:

| id | 说明 | |----|------| | composer-2.5 | 默认模型 | | composer-2.5-fast | 更快的 Composer | | claude-opus-4-8-thinking-high | Claude Opus 思考档 | | gpt-5.3-codex | GPT Codex | | cursor-grok-4.5-high | Grok |

完整列表以 GET /v1/models 为准;model 字段可直接使用返回的 id

环境变量

| 变量 | 默认 | 说明 | |------|------|------| | PORT | 3000 | 端口 | | HOST | 0.0.0.0 | 监听地址 | | API_KEY | 空(不校验) | x-api-key / Authorization: Bearer | | TOKEN_FILE | ~/.cursoride2api/token.json | Token 文件 | | DEFAULT_MODEL | composer-2.5 | 默认模型 | | CURSOR_CLIENT_VERSION | 3.2.16 | Cursor 客户端版本 | | REQUEST_TIMEOUT | 120000 | 上游超时 (ms) | | WORKSPACE_ROOT | 进程 cwd | 工具路径解析根目录 |

原理(简)

  1. ConnectRPC over HTTP/2 → api2.cursor.sh agent.v1.AgentService/Run
  2. 将 Anthropic messages / tools 转为 Cursor Agent 请求
  3. 拦截 execServerMessage,映射为 Claude tool_use;客户端回写 tool_result 后经 execClientMessage 恢复会话

License

MIT

免责声明

仅供学习研究。请遵守 Cursor 服务条款;开发者不对滥用负责。