@willpowell8/cursor-cloud-agent-mcp
v1.0.1
Published
Model Context Protocol server for Cursor Cloud Agents API - programmatically create, manage, and interact with AI-powered coding agents through MCP stdio transport. Integrate automated code generation, repository management, and agent workflows into your
Maintainers
Readme
Cursor Cloud Agent MCP Connector
A comprehensive Model Context Protocol (MCP) server implementation that provides seamless access to Cursor's Cloud Agents API through stdio transport. This connector enables developers to programmatically create, manage, and interact with AI-powered coding agents, automate code generation workflows, and integrate Cursor's agent capabilities into their development tools and applications.
Overview
This MCP server implementation exposes the complete Cursor Cloud Agents API as a set of standardized MCP tools, making it easy to integrate automated code generation, repository management, and agent orchestration into any MCP-compatible application. Built with TypeScript for type safety and reliability, the server communicates via stdio transport following the Model Context Protocol specification, ensuring compatibility with a wide range of MCP clients and development environments.
The connector provides full programmatic control over Cursor's cloud-based AI agents, allowing you to launch agents on GitHub repositories, manage agent lifecycles, retrieve conversation histories, configure pull request automation, and monitor agent status—all through a unified MCP interface.
Features
- Complete API Coverage: Full implementation of all Cursor Cloud Agents API endpoints as MCP tools, including agent creation, management, conversation retrieval, and repository operations
- Type-Safe Implementation: Built entirely with TypeScript, providing comprehensive type definitions for all API requests, responses, and agent data structures
- Robust Error Handling: Intelligent error handling with detailed error messages for authentication failures, rate limiting, API errors, and network issues
- Rate Limit Management: Built-in awareness and graceful handling of Cursor API rate limits with clear error messaging
- Secure Authentication: Environment variable-based API key authentication following Cursor's Basic Authentication requirements
- MCP Protocol Compliance: Full adherence to Model Context Protocol specification with stdio transport support
- Developer-Friendly: Clean, well-documented codebase with comprehensive tool descriptions and parameter validation
- Production Ready: Error handling, type safety, and proper async/await patterns for reliable operation in production environments
Installation
Prerequisites
- Node.js 18 or higher
- npm (comes with Node.js)
- A Cursor API key (obtainable from Cursor Dashboard → Integrations)
Quick Start with npx (Recommended)
The easiest way to use this MCP server is via npx, which downloads and runs the package without requiring a local installation:
npx @willpowell/cursor-cloud-agent-mcpThis will automatically use the latest version from npm. The server reads the CURSOR_API_KEY environment variable for authentication.
Local Installation (Optional)
For local development or if you want to install globally:
Global installation:
npm install -g @willpowell/cursor-cloud-agent-mcpThen run:
cursor-cloud-agent-mcpLocal installation:
npm install @willpowell/cursor-cloud-agent-mcp
npx @willpowell/cursor-cloud-agent-mcpDevelopment Setup
If you want to contribute or modify the code:
- Clone this repository:
git clone <repository-url>
cd cursor-cloud-agent-mcp- Install dependencies:
npm install- Build the TypeScript project:
npm run buildThe compiled JavaScript will be available in the dist/ directory.
Configuration
API Key Setup
Authentication is required to access the Cursor Cloud Agents API. Set the CURSOR_API_KEY environment variable with your Cursor API key:
export CURSOR_API_KEY=key_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxObtaining an API Key:
- Navigate to your Cursor Dashboard
- Go to the Integrations section
- Create a new API key for Cloud Agents API access
- Copy the generated key (format:
key_...) - Set it as an environment variable before running the MCP server
The API key is tied to your organization and provides access to all repositories and agents associated with your Cursor account.
Usage
Running the MCP Server
The server uses stdio transport for communication, which means it should be launched and managed by an MCP-compatible client application. The server reads from stdin and writes to stdout following the MCP protocol specification.
Using npx (recommended):
npx @willpowell8/cursor-cloud-agent-mcpUsing globally installed package:
cursor-cloud-agent-mcpLocal development mode (with TypeScript):
npm run devMCP Client Configuration
To integrate this server with an MCP client (such as Claude Desktop, custom MCP applications, or other Model Context Protocol implementations), add the following configuration to your MCP client settings:
Example configuration for Claude Desktop (using npx):
{
"mcpServers": {
"cursor-cloud-agents": {
"command": "npx",
"args": ["-y", "@willpowell8/cursor-cloud-agent-mcp"],
"env": {
"CURSOR_API_KEY": "your-api-key-here"
}
}
}
}The -y flag automatically answers "yes" to the npm prompt, ensuring non-interactive execution.
Example configuration with system environment variable:
{
"mcpServers": {
"cursor-cloud-agents": {
"command": "npx",
"args": ["-y", "@willpowell8/cursor-cloud-agent-mcp"]
}
}
}(Ensure CURSOR_API_KEY is set in your system environment)
Example configuration with globally installed package:
{
"mcpServers": {
"cursor-cloud-agents": {
"command": "@willpowell8/cursor-cloud-agent-mcp",
"env": {
"CURSOR_API_KEY": "your-api-key-here"
}
}
}
}Example configuration for local development:
{
"mcpServers": {
"cursor-cloud-agents": {
"command": "node",
"args": ["/absolute/path/to/cursor-cloud-agent-mcp/dist/index.js"],
"env": {
"CURSOR_API_KEY": "your-api-key-here"
}
}
}
}Using the Tools
Once configured, the MCP client can invoke any of the available tools. Each tool corresponds to a Cursor Cloud Agents API endpoint and accepts parameters as defined in the tool schema. The server handles authentication, request formatting, error handling, and response parsing automatically.
Available MCP Tools
The server exposes 10 tools covering all aspects of Cursor Cloud Agents API functionality. Each tool is fully typed and includes comprehensive parameter validation.
Agent Lifecycle Management
list_agents: Retrieve a paginated list of all cloud agents associated with the authenticated user's account. Supports pagination via cursor-based navigation.- Parameters:
limit(optional, number): Number of agents to return (default: 20, max: 100)cursor(optional, string): Pagination cursor from previous response for retrieving additional pages
- Parameters:
get_agent: Fetch detailed status information for a specific cloud agent, including current state, repository details, branch information, pull request URLs, and completion summary.- Parameters:
id(required, string): Unique agent identifier (e.g.,bc_abc123)
- Parameters:
get_agent_conversation: Retrieve the complete conversation history between the user and a cloud agent, including all prompts, follow-ups, and assistant responses. Useful for understanding agent decision-making and debugging agent behavior.- Parameters:
id(required, string): Unique agent identifier
- Parameters:
launch_agent: Create and start a new cloud agent to work on a specified GitHub repository. The agent will analyze the codebase, execute the provided instructions, and generate code changes.- Parameters:
prompt(required, object): Task instructions with optional image attachmentstext(required, string): Instruction text describing the taskimages(optional, array): Up to 5 images with base64 data and dimensions
source(required, object): Repository source configurationrepository(required, string): GitHub repository URLref(optional, string): Git branch, tag, or commit hash to use as base
model(optional, string): LLM model to use (e.g.,claude-4-sonnet). Omit for auto-selectiontarget(optional, object): Target branch and PR configurationbranchName(optional, string): Custom branch nameautoCreatePr(optional, boolean): Automatically create PR on completionopenAsCursorGithubApp(optional, boolean): Open PR as Cursor GitHub AppskipReviewerRequest(optional, boolean): Skip adding user as reviewer
webhook(optional, object): Webhook configuration for status notificationsurl(required, string): Webhook endpoint URLsecret(optional, string): Webhook secret for payload verification (min 32 chars)
- Parameters:
add_followup: Send additional instructions to an existing cloud agent. Useful for iterating on agent work, requesting modifications, or providing clarifications.- Parameters:
id(required, string): Unique agent identifierprompt(required, object): Follow-up instructions with optional imagestext(required, string): Follow-up instruction textimages(optional, array): Up to 5 images with base64 data and dimensions
- Parameters:
stop_agent: Pause execution of a currently running cloud agent without deleting it. Stopped agents can be resumed by sending a follow-up prompt.- Parameters:
id(required, string): Unique agent identifier
- Parameters:
delete_agent: Permanently delete a cloud agent and all associated data. This action cannot be undone.- Parameters:
id(required, string): Unique agent identifier
- Parameters:
Utility and Information Tools
get_api_key_info: Retrieve metadata about the API key currently being used for authentication, including key name, creation date, and associated user email.- Parameters: None
list_models: Get a list of recommended LLM models available for use with cloud agents. Helps in selecting the appropriate model for specific tasks.- Parameters: None
list_repositories: Retrieve all GitHub repositories accessible to the authenticated user. Note: This endpoint has strict rate limits (1 request per minute, 30 per hour) and may take tens of seconds for users with many repositories.- Parameters: None
API Endpoint Mapping
This MCP server provides a complete wrapper around the Cursor Cloud Agents API, mapping each REST endpoint to a corresponding MCP tool:
| MCP Tool | HTTP Method | API Endpoint | Description |
|----------|-------------|--------------|-------------|
| list_agents | GET | /v0/agents | Paginated list of all cloud agents |
| get_agent | GET | /v0/agents/{id} | Detailed agent status and metadata |
| get_agent_conversation | GET | /v0/agents/{id}/conversation | Complete conversation history |
| launch_agent | POST | /v0/agents | Create and start a new agent |
| add_followup | POST | /v0/agents/{id}/followup | Send follow-up instructions |
| stop_agent | POST | /v0/agents/{id}/stop | Pause agent execution |
| delete_agent | DELETE | /v0/agents/{id} | Permanently delete an agent |
| get_api_key_info | GET | /v0/me | API key metadata and user info |
| list_models | GET | /v0/models | Available LLM models |
| list_repositories | GET | /v0/repositories | Accessible GitHub repositories |
All API interactions use Basic Authentication with your API key, and the server handles request formatting, response parsing, and error translation automatically.
Rate Limits and Best Practices
The Cursor Cloud Agents API implements rate limiting to ensure fair usage and system stability. This MCP server handles rate limit errors gracefully and provides clear error messages when limits are exceeded.
Rate Limit Handling
When a rate limit is exceeded, the server will return a 429 Too Many Requests error with a descriptive message. The server does not implement automatic retry logic, allowing clients to implement their own backoff strategies as needed.
Best Practices
- Repository Listing: The
list_repositoriesendpoint has very strict limits (1/minute, 30/hour). Cache results when possible. - Agent Polling: When monitoring agent status, poll at reasonable intervals (e.g., every 30-60 seconds) rather than continuously.
- Error Handling: Implement exponential backoff in your MCP client when encountering rate limit errors.
- Batch Operations: When creating multiple agents, space out requests to avoid hitting rate limits.
For detailed rate limit information, refer to the Cursor API documentation.
Error Handling
The server provides comprehensive error handling for all API interaction scenarios. Errors are translated into user-friendly messages and returned in the standard MCP protocol error format.
HTTP Status Code Mapping
- 400 Bad Request: Invalid request parameters or missing required fields
- 401 Unauthorized: Invalid, missing, or expired API key
- 403 Forbidden: Valid API key but insufficient permissions (e.g., Enterprise features on non-Enterprise plan)
- 404 Not Found: Requested agent, repository, or resource does not exist
- 429 Too Many Requests: Rate limit exceeded - implement exponential backoff
- 500 Internal Server Error: Cursor API server-side error - contact support if persistent
Error Response Format
All errors are returned as MCP error responses with descriptive messages:
{
"content": [
{
"type": "text",
"text": "Error: Rate limit exceeded: Rate limit exceeded. Please try again later."
}
],
"isError": true
}The server automatically handles network errors, JSON parsing errors, and unexpected API responses, ensuring robust operation in production environments.
Development
Building the Project
Compile TypeScript to JavaScript:
npm run buildThe compiled output will be in the dist/ directory, ready for production use.
Development Mode
Run the server directly from TypeScript source with hot reloading:
npm run devThis uses tsx to execute TypeScript directly without a build step, useful for development and testing.
Project Structure
cursor-cloud-agent-mcp/
├── src/
│ ├── index.ts # Main MCP server implementation with tool definitions
│ └── api-client.ts # Cursor Cloud Agents API client with type definitions
├── dist/ # Compiled JavaScript output (generated)
├── package.json # Project configuration and dependencies
├── tsconfig.json # TypeScript compiler configuration
├── .gitignore # Git ignore patterns
└── README.md # This fileTypeScript Configuration
The project uses strict TypeScript settings with ES2022 target and ES modules. All API types are defined in api-client.ts for full type safety across the codebase.
Contributing
When contributing to this project:
- Ensure all TypeScript code compiles without errors
- Maintain type safety - avoid
anytypes - Follow existing code style and error handling patterns
- Update tool descriptions if adding new functionality
- Test with actual Cursor API endpoints when possible
Use Cases
This MCP connector enables various automation and integration scenarios:
- CI/CD Integration: Automate code generation and testing workflows in continuous integration pipelines
- Development Automation: Create agents programmatically to handle repetitive coding tasks
- Repository Management: Bulk operations on multiple repositories with consistent agent configurations
- Monitoring and Analytics: Track agent performance, completion rates, and code generation metrics
- Custom Development Tools: Build custom interfaces and dashboards for managing Cursor cloud agents
- Workflow Orchestration: Integrate agent creation and management into larger development workflows
- Testing and QA: Automate test case generation and code review processes using AI agents
License
MIT License - see LICENSE file for details
Package Information
This package is published to npm as @willpowell8/cursor-cloud-agent-mcp. You can install it via:
npm install @willpowell8/cursor-cloud-agent-mcpOr use it directly with npx without installation:
npx @willpowell8/cursor-cloud-agent-mcpSupport and Resources
Getting Help
- MCP Connector Issues: Open an issue in this repository's issue tracker
- Cursor API Questions: Refer to the official Cursor API documentation
- MCP Protocol: Learn more about Model Context Protocol at the MCP specification
Related Resources
- npm Package - Install from npm
- Cursor Cloud Agents API Documentation
- Model Context Protocol Specification
- Cursor Dashboard - Manage API keys and view agent activity
