@blowmage/cursor-agent-acp
v0.7.1
Published
Production-ready Agent Client Protocol (ACP) adapter for Cursor CLI with comprehensive tool system, security framework, and seamless AI-powered coding assistance in ACP-compliant editors like Zed
Maintainers
Readme
Cursor Agent ACP Adapter
A full-featured Agent Client Protocol (ACP) adapter for Cursor CLI, enabling seamless AI-powered coding assistance in ACP-compliant editors like Zed.
Overview
This TypeScript implementation provides a production-ready bridge between the Cursor CLI and editors that support the Agent Client Protocol. Built on the standard stdio transport per ACP specification, it offers feature parity with Zed's built-in Claude and Codex adapters while maintaining high performance and reliability.
Features
- ACP Protocol Core - Initialize, session management, prompt processing
- Strict Schema Compliance - 100% adherence to ACP Schema
- Stdio Transport - Standard ACP stdio transport per protocol specification
- Session Management - Persistent sessions with metadata and history
- Content Processing - Text, code, and image block handling per ContentBlock schema
- Real-time Streaming - Live response streaming for immediate feedback
- Complete Tool System - Filesystem, terminal, and Cursor-specific tools
- Security Framework - Path validation, command filtering, access controls
- Error Handling & Recovery - Robust error handling with comprehensive validation
- Type Safety - Written in TypeScript with strict type checking using
@agentclientprotocol/sdk - SDK Integration - All protocol types imported from official
@agentclientprotocol/sdk - Test Coverage - 200+ unit and integration tests with security coverage
- Cursor CLI Integration - Complete integration with cursor-agent CLI features
- Advanced Tool Registry - Dynamic provider management and validation
- Cross-Tool Workflows - Seamless filesystem, terminal, and code operations
- High Performance - <100ms average response time optimization
- Memory Efficiency - Zero memory leaks, optimal resource usage
- Cross-platform - Works on macOS, Linux, and Windows
ACP Schema Compliance
This adapter strictly adheres to the Agent Client Protocol Schema. Key compliance features:
Protocol Types
- All types imported from
@agentclientprotocol/sdk- No custom protocol type definitions - PromptRequest - Uses
promptfield per schema (ContentBlock[]) - SessionUpdate - Full union type support (user_message_chunk, agent_message_chunk, agent_thought_chunk, tool_call, tool_call_update, plan, available_commands_update, current_mode_update)
- ContentBlock - Complete support for text, image, audio, resource, resource_link
- SessionCapabilities - Properly declared in AgentCapabilities
- Terminal types - Full Terminal, TerminalHandle, TerminalExitStatus support
Validation
- Content block validation - Strict validation against ContentBlock schema
- Annotations support - Full Annotations type support with _meta extensions
- Error responses - JSON-RPC 2.0 compliant error structures
- Type guards - Runtime validation using SDK type structures
Documentation
- TSDoc comments - All protocol methods link to ACP schema documentation
- Schema references - Direct links to relevant schema sections
- Internal vs Protocol types - Clear separation and documentation
Installation
Prerequisites
- Node.js 18+ - Required for running the adapter
- Cursor CLI - Must be installed and authenticated
# Install Cursor CLI
curl https://cursor.com/install -fsSL | bash
# Authenticate with your Cursor account
cursor-agent loginInstall the Adapter
# Install globally
npm install -g @blowmage/cursor-agent-acp
# Or install locally in your project
npm install @blowmage/cursor-agent-acpUsage
Basic Usage
# Start the ACP adapter with stdio transport
cursor-agent-acp
# Or run directly with npx
npx cursor-agent-acpThe adapter uses stdio transport by default, which is the standard transport for the Agent Client Protocol. The adapter reads JSON-RPC messages from stdin and writes responses to stdout, with messages delimited by newlines as specified in the ACP Transport Specification.
Zed Editor Integration
Add this configuration to your Zed settings (~/.config/zed/settings.json):
{
"agent_servers": {
"cursor-agent": {
"command": "cursor-agent-acp",
"args": [],
"env": {}
}
}
}If installed locally:
{
"agent_servers": {
"cursor-agent": {
"command": "npx",
"args": ["@blowmage/cursor-agent-acp"],
"env": {}
}
}
}JetBrains IDE Integration
The adapter supports JetBrains IDEs (WebStorm, IntelliJ IDEA, PyCharm, etc.) version 25.3 and later.
Create or edit ~/.jetbrains/acp.json:
{
"agent_servers": {
"Cursor Agent": {
"command": "cursor-agent-acp",
"args": [],
"env": {}
}
}
}Or configure through the IDE:
- Open AI Chat tool window
- Click ⚙️ settings → "Configure ACP Agents"
- Add the configuration above
Using with Other Editors
The adapter works with any ACP-compliant editor using the standard stdio transport. Configure your editor to launch cursor-agent-acp as an agent server process.
Transport Layer
This adapter implements the stdio transport as specified in the ACP Transport Specification.
Stdio Transport (Default)
The stdio transport is the recommended transport for ACP:
- Standard Communication: JSON-RPC messages over stdin/stdout
- Message Format: Newline-delimited JSON (
\ndelimiter) - Logging: Uses stderr for diagnostic output
- No Embedded Newlines: Messages must not contain
\nor\r - SDK Compliant: Uses
@agentclientprotocol/sdkfor all protocol handling
Why Stdio?
Stdio is the default and recommended transport for ACP because:
- Universal Support: Works with any process-based editor integration
- Simple & Reliable: Well-understood subprocess communication
- Specification Compliant: Follows ACP transport specification exactly
- SDK Integration: Full support via
@agentclientprotocol/sdk
Configuration
The adapter supports various configuration options:
# Custom configuration file
cursor-agent-acp --config /path/to/config.json
# Set log level
cursor-agent-acp --log-level debug
# Specify session storage directory
cursor-agent-acp --session-dir ~/.cursor-sessionsConfiguration File Example
{
"logLevel": "info",
"sessionDir": "~/.cursor-sessions",
"maxSessions": 100,
"sessionTimeout": 3600000,
"tools": {
"filesystem": {
"enabled": true,
"allowedPaths": ["./"],
"maxFileSize": 10485760,
"allowedExtensions": [".ts", ".js", ".json", ".md"]
},
"terminal": {
"enabled": true,
"maxProcesses": 5,
"defaultOutputByteLimit": 10485760,
"maxOutputByteLimit": 52428800,
"forbiddenCommands": ["rm", "sudo", "su"],
"allowedCommands": [],
"defaultCwd": "./"
},
"cursor": {
"enabled": true,
"enableCodeModification": true,
"enableTestExecution": true,
"maxSearchResults": 50
}
},
"cursor": {
"timeout": 30000,
"retries": 3
}
}Development
Setup
# Clone the repository
git clone https://github.com/blowmage/cursor-agent-acp.git
cd cursor-agent-acp
# Install dependencies
npm install
# Build the project
npm run buildTesting
# Run unit tests
npm test
# Run integration tests
npm run test:integration
# Run all tests with coverage
npm run test:coverage
# Watch mode for development
npm run test:watchDevelopment Server
# Run in development mode with hot reload
npm run dev
# Build and watch for changes
npm run build:watchArchitecture
┌─────────────────────────────────────────────────────┐
│ ACP Editor (Zed) │
└─────────────────┬───────────────────────────────────┘
│ JSON-RPC over stdio
┌─────────────────▼───────────────────────────────────┐
│ Cursor Agent ACP Adapter │
│ ┌─────────────────────────────────────────────────┐│
│ │ Protocol Layer ││
│ │ • Initialization • Session Management ││
│ │ • Prompt Handling • Content Processing ││
│ │ • Tool Calling • Error Handling ││
│ └─────────────────────────────────────────────────┘│
│ ┌─────────────────────────────────────────────────┐│
│ │ Integration Layer ││
│ │ • CLI Bridge • Authentication ││
│ │ • Session Sync • Response Translation ││
│ └─────────────────────────────────────────────────┘│
└─────────────────┬───────────────────────────────────┘
│ Command execution
┌─────────────────▼───────────────────────────────────┐
│ Cursor CLI │
└─────────────────────────────────────────────────────┘API Documentation
Core Classes
CursorAgentAdapter- Main adapter class implementing ACP protocolSessionManager- Handles session lifecycle and persistenceCursorCliBridge- Interfaces with cursor-agent CLIToolRegistry- Manages available tools and capabilities
Supported ACP Methods
initialize- Initialize the adapter with capabilitiessession/new- Create a new conversation sessionsession/load- Load an existing sessionsession/list- List all available sessionssession/update- Update session metadatasession/delete- Delete a sessionsession/prompt- Send a prompt and receive streaming response
Available Tools
File System Tools
read_file- Read file contents with security validationwrite_file- Write file contents with path restrictionslist_directory- List directory contents recursivelycreate_directory- Create directories with parent supportdelete_file- Delete files/directories with safety checksget_file_info- Get detailed file/directory information
Terminal Tools
execute_command- Execute shell commands with security filteringstart_shell_session- Start interactive shell sessionssend_to_shell- Send input to active shell sessionsclose_shell_session- Close and cleanup shell sessionslist_processes- List active processes and sessions
Cursor-Specific Tools
search_codebase- Advanced code search with pattern matchinganalyze_code- Code structure and quality analysisapply_code_changes- Atomic code modifications with backuprun_tests- Execute tests with framework auto-detectionget_project_info- Project metadata and dependency informationexplain_code- AI-powered code explanations and suggestions
Troubleshooting
Common Issues
"cursor-agent not found"
# Install Cursor CLI
curl https://cursor.com/install -fsSL | bash
# Verify installation
cursor-agent --version"Authentication required"
# Login to Cursor
cursor-agent login
# Check authentication status
cursor-agent status"Permission denied"
# Make sure the binary is executable
chmod +x ./node_modules/.bin/cursor-agent-acp"Session not found"
- Sessions are stored locally and may expire
- Check session directory permissions
- Verify session storage configuration
Debug Mode
Enable debug logging to troubleshoot issues:
cursor-agent-acp --log-level debugCheck logs in:
- macOS/Linux:
~/.cursor-agent-acp/logs/ - Windows:
%APPDATA%\cursor-agent-acp\logs\
Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Workflow
- Fork the repository
- Create a feature branch
- Write tests for your changes
- Implement the feature
- Ensure all tests pass
- Submit a pull request
Code Standards
- TypeScript: Strict mode enabled
- Testing: >95% test coverage required
- Linting: ESLint + Prettier
- Commits: Conventional commit messages
License
MIT License - see LICENSE file for details.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Full API Docs
Related Projects
- Agent Client Protocol - Official ACP specification
- Cursor CLI - Official Cursor command-line interface
- Zed Editor - High-performance code editor with ACP support
