
Cursor (Anysphere)
Script Cursor's coding agent from Python and TypeScript, locally or in Cursor-hosted cloud VMs.
GitHub Stars
32.9K
Contributors
33
npm / Week
128.4K
PyPI / Month
—
The Cursor SDK is the official programmatic interface to the same agent runtime that powers the Cursor IDE, CLI, and web app. Maintained by Cursor (Anysphere), it ships as both a Python and TypeScript library under a proprietary license. First released in 2026, the SDK occupies a unique niche: it is both an agent runtime (you run the agent inside your own process or on Cursor-hosted cloud VMs) and an inference SDK (it wraps the composer-2.5 model family with planning, tool use, and memory).
The problem it solves is straightforward: teams that need a production-proven coding agent embedded into CI/CD, internal tools, or multi-repo workflows no longer have to build one from scratch. Instead, they get the same agent loop that already handles millions of editor actions daily. The SDK is optimized for scripting Cursor’s coding agent in automation contexts, not for general-purpose chat or non-code workflows. Its design philosophy is “take our agent harness and run it anywhere” — local filesystem, cloud VM, or self-hosted worker — without reinventing repository indexing, MCP integration, or subagent orchestration.
Within the agent framework landscape, Cursor SDK competes most directly with task-specific coding agents (Claude Code SDK, OpenAI Codex CLI) rather than general-purpose multi-agent orchestrators like LangChain or CrewAI. It is not a framework for building arbitrary agent architectures; it is a purpose-built runtime for one very capable agent that can be scripted, parallelized, and embedded.
The Cursor SDK is imperative and code-first. You write a Python or TypeScript script that imports the SDK, creates an agent instance, configures its runtime (local or cloud), and calls methods to execute tasks. There are no declarative YAML configs, no graph definitions, and no chain-of-thought templates. The core abstraction is the agent run: a single session that can work in either plan mode or agent mode. In plan mode, the agent analyzes the task, scopes the work, and produces a plan before taking action. In agent mode, it jumps directly to implementation, reading files, running commands, and editing code.
Control flow is synchronous or streaming. The agent emits a stream of events (tool calls, file edits, status updates) that your script can consume for logging, progress bars, or human-in-the-loop approvals. The SDK provides a Run object with methods like agent.run({ task }) that returns an AgentRunResult or an AsyncIterable of events.
A minimal agent in TypeScript looks like this:
1import { Agent } from '@cursor/sdk';23const agent = new Agent({4 runtime: 'local', // runs inline in your process5 projectPath: '/path/to/repo',6 model: 'composer-2.5',7});89const result = await agent.run({10 task: 'Add error handling to all API routes in src/api',11 mode: 'plan', // or 'agent'12});
Key abstractions beyond the agent itself:
.cursor/hooks.json. You can intercept tool calls (e.g., block rm -rf in CI) or require approval before file writes.The runtime switch (local vs cloud) is a one-line configuration. Local execution runs the agent in your own Node or Python process, reading and writing files on the local filesystem. Cloud execution spins up an isolated Cursor-hosted VM, clones the repo, and runs the agent there. The SDK abstracts the exact same interface for both.
The Cursor SDK delivers a set of capabilities that are directly useful for production coding workflows:
Specific maintainer-provided features worth calling out:
Teams deploying the Cursor SDK tend to fall into three categories, each reflecting a known use case.
Coding agents in CI/CD – The most common pattern. A pipeline task uses the SDK to run agent mode against a local checkout, performs a set of edits (e.g., migrating a deprecated API, fixing lint errors, adding tests), and optionally creates a PR via the autoCreatePR flag. Idempotency keys ensure the agent only runs once per commit even if the pipeline restarts. This replaces fragile shell scripts and regex-based code mods with a model that understands the full codebase.
Parallel agent fleets – Teams with large monorepos fan out work across many cloud VMs. For example, upgrading a shared library that touches 50 packages: spawn one agent per package, each in its own VM, each with the same base repo but a different sub-task. The parent run waits, collects diffs, and merges them. This cuts a week-long manual effort to hours.
Multi-repo refactors and audits – The SDK supports a target list of up to 20 repositories. A single agent run clones each repo, executes the same task, and collects results. Useful for enforcing security policies (e.g., “remove all hardcoded secrets in every JavaScript repo”) or rolling out a change across microservices.
The SDK is a poor fit for workloads that are not code-based (e.g., customer support chatbots, document summarization) because its model and context are optimized for repository understanding. It is also not suited for long-running background agents that need persistent state across days. For those, you would pair the SDK with an external database and orchestration layer.
To start building with the Cursor SDK, install it from npm or PyPI:
1npm install @cursor/sdk2# or3pip install cursor-sdk
The smallest meaningful script (TypeScript):
1import { Agent } from '@cursor/sdk';23const agent = new Agent({4 runtime: 'local',5 projectPath: process.cwd(),6});78const stream = agent.run({9 task: 'List all files that contain the word "TODO"',10 mode: 'agent',11});1213for await (const event of stream) {14 console.log(event.type, event.data);15}
What you need around it:
Documentation is available at [cursor.com/sdk](https://cursor.com/sdk). Community support is primarily through the Cursor forum and the @cursor/sdk GitHub repository. The SDK is in public beta, so expect API changes and limited documentation depth initially.
Cursor SDK vs. Claude Code SDK (Anthropic) – Both are purpose-built coding agents exposed as an SDK. Claude Code SDK runs locally via the claude CLI and is open-source; Cursor SDK is proprietary and offers cloud VMs. Cursor’s advantage is the first-class TypeScript and Python package, the hooks system for fine-grained access control, and multi-repo support. Claude Code SDK wins on transparency and the ability to swap models (you can use any Anthropic model). Choose Cursor if you want a managed cloud execution environment and tight MCP integration; choose Claude Code SDK if you need open-source code and model flexibility.
Cursor SDK vs. OpenAI Codex CLI – Codex CLI is a command-line tool, not a library you can embed. The Cursor SDK gives you programmatic control (streaming events, subagents, hooks) that Codex CLI does not. If you need to build a custom pipeline or product around a coding agent, Cursor SDK is the more extensible option. If you just want to run ad-hoc code generation from the terminal, Codex CLI is simpler.
Cursor SDK vs. LangChain / CrewAI – These are general-purpose agent frameworks. Cursor SDK is for a single, specific, highly optimized coding agent. You would not use LangChain to build a coding agent unless you wanted full control over every component (indexing, model selection, tool design). Cursor SDK is the “batteries included” choice for code tasks; LangChain/CrewAI are the “build your own” alternatives. The trade-off: Cursor SDK is faster to start but locked to Cursor’s models and pricing.
When to choose Cursor SDK: Your team needs a reliable, testable coding agent for CI, refactors, or audits. You already use Cursor IDE or are comfortable with a proprietary platform. You want cloud execution without managing VMs.
When to choose an alternative: You need to bring your own LLM provider, require open-source code for security audit, or need a general-purpose agent framework that can also handle non-code tasks.
What the framework gives you out of the box, in plain language.
The same SDK either runs the agent inline in your Node or Python process against files on disk, or in an isolated Cursor-hosted VM with the repo cloned.
Choose plan mode to scope work first, or agent mode to implement directly, with per-run model overrides such as reasoning effort and max mode.
Connect MCP servers over HTTP, SSE, or stdio, gate tool calls with file-based hooks at .cursor/hooks.json, and spawn named subagents from a parent run.
The jobs this framework is best suited for.
Agents that read files, run commands, and edit code as part of pipelines, with idempotency keys and optional PR automation via autoCreatePR.
Fan out work across many Cursor-hosted cloud VMs so multiple agents tackle independent tasks on the same repo at once.
Run a single agent across up to 20 repositories to coordinate changes, audits, or migrations that span more than one codebase.

Side-by-Side
Add a second or third framework and see stars, downloads, and capabilities lined up next to each other.
Close alternatives worth a look before you decide.
Claude Code as a library — production agents with built-in file, shell, and code-edit tools.
Production agents on Claude with code execution
Stars
7.0K
npm / wk
5.9M
PyPI / mo
13.0M
Composable building blocks for LLM apps — chains, agents, retrievers, and integrations.
Composable LLM building blocks
Stars
137.3K
npm / wk
2.3M
PyPI / mo
247.9M
Multi-agent crews with role-based prompts and explicit task hand-offs.
Role-based multi-agent crews
Stars
51.6K
npm / wk
—
PyPI / mo
9.6M