Skip to main content

cursor-agent

Standalone Python client for Cursor CLI in ACP mode (agent acp): JSON-RPC over stdio to drive Composer from your own code — similar in spirit to anthropic or google-genai, but talking to the local agent binary instead of a hosted HTTP API.

Requirements

  • Python 3.11+
  • Cursor CLI with agent on PATH (often ~/.local/bin)
  • CURSOR_API_KEY or CURSOR_AUTH_TOKEN in the environment (or pass explicitly). From a checkout of this repo, you can pass the key inline (replace x with your real key):
CURSOR_API_KEY=x python examples/quickstart.py

Install

From this monorepo (path dependency):

uv add "cursor-agent @ file:./packages/cursor-agent"

Or from PyPI:

pip install cursor-acp

The import name is still cursor_agent (package directory unchanged).

Quick start

Run the included example from the repo (after an editable install):

pip install -e .
CURSOR_API_KEY=x python examples/quickstart.py

Optional prompt and working directory:

CURSOR_API_KEY=x python examples/quickstart.py --cwd /path/to/project "What does this codebase do?"

Equivalent minimal script:

import asyncio
from pathlib import Path
from cursor_agent import CursorAgent

async def main():
    agent = CursorAgent(cwd=Path("."))
    result = await agent.prompt("Summarize this repository")
    print(result.text)
    print(result.completed_tool_rounds)
    await agent.shutdown()

asyncio.run(main())

Hooks

All extension points live in a single CursorAgentHooks dataclass — pass only the hooks you need:

from cursor_agent import CursorAgent, CursorAgentHooks

hooks = CursorAgentHooks(
    before_process_start=my_setup,     # async (cwd: Path) -> None
    wrap_command=my_sandbox_wrapper,   # async (argv, cwd_str) -> str
    on_opaque_tool_call=my_mcp_bridge, # async (conversation_id, on_event) -> None
)
agent = CursorAgent(cwd=Path("."), hooks=hooks)
  • before_process_start — called with the working directory before the ACP subprocess spawns (e.g. write config files).
  • wrap_command — transforms argv + working-directory string into a shell command (e.g. sandbox wrapping). Defaults to shlex.join(argv).
  • on_opaque_tool_call — invoked when the ACP stream reports a tool call the package cannot handle natively (title starts with "MCP:"). Receives (conversation_id, on_event) so the caller can bridge the call and emit real events.

License

MIT

Metadata

Release files for cursor-acp 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cursor-acp 0.1.1
File Size Uploaded Provenance Actions
cursor_acp-0.1.1.tar.gz 10.4 kB Without provenance Details for cursor_acp-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cursor-acp 0.1.1
File Interpreter ABI Platform Actions
cursor_acp-0.1.1-py3-none-any.whl Python 3 none any Details for cursor_acp-0.1.1-py3-none-any.whl

Total release size: 22.9 kB

Release files / cursor_acp-0.1.1.tar.gz

Download URL cursor_acp-0.1.1.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8cb7a6398a348baec671bd13935a7932a6c96e1c1d700200884abee2fe2cb353
BLAKE2b-256 checksum
How to use checksums
1c9bf5c7054ede28304f2ae4bd6fa37504e4317e57b8692610fdcdcfe49b23ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.4

Release files / cursor_acp-0.1.1-py3-none-any.whl

Download URL cursor_acp-0.1.1-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
62fdebefcd6fb6d4b3bd2a67a4ee4f7f6be4a4029eb85d926da3f4b966214304
BLAKE2b-256 checksum
How to use checksums
2dd2ee811967230a5b82888b00e88521192b27afd9adefcd70e62a2d7ea400a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.4

Security for cursor-acp 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page