cursor-background-agent-api
Use Cursor Background Agents as an API or MCP Server
claude mcp add --transport stdio mjdierkes-cursor-background-agent-api node dist/server.js \ --env CURSOR_SESSION_TOKEN="your_session_token_here"
How to use
This MCP server provides programmatic access to Cursor's Background Composer functionality via the Cursor Background Agent API client, enabling AI assistants and automation workflows to create, manage, and monitor background coding tasks. After building the project, start the MCP server alongside your client to enable Model Context Protocol interactions. You can then integrate the MCP server into your AI-enabled workflows to submit composer tasks, fetch status, and retrieve results, all through structured MCP messages and contexts.
To use the server locally, ensure you have a valid Cursor session token (via CURSOR_SESSION_TOKEN or a cookies.json file) and start the MCP server using the project's development commands. The server exposes endpoints and intents via MCP that allow you to create new background composers, list existing ones, fetch details, and check or update user settings related to privacy and web access. When interfacing through an MCP-enabled assistant, you can issue actions like createComposer, listComposers, and getComposerDetails, and the MCP layer will translate these into API calls to the Cursor service and return structured results for your agent.
How to install
Prerequisites:
- Node.js (recommended LTS version) and npm
- Git
- Access to the Cursor API token (see setup below)
Installation steps:
-
Install the package globally (or install locally and use scripts): npm install -g cursor-api-client
-
(Optional) Clone the repository and install dependencies: git clone https://github.com/mjdierkes/cursor-background-agent-api.git cd cursor-background-agent-api npm install
-
Build the project (if applicable): npm run build
-
Set up your environment:
- Obtain a Cursor session token (via environment variable CURSOR_SESSION_TOKEN or cookies.json as described in the Setup section).
- Ensure the MCP server can be started (see the Start MCP server script in package.json).
-
Start the MCP server (development): npm run mcp-server:dev
-
If you’re consuming via CLI or JS/TS client, install and configure the cursor-api-client as shown in the API Client Usage section of the README.
Additional notes
Tips and common considerations:
- Ensure CURSOR_SESSION_TOKEN is kept secure and not committed to version control.
- If you use cookies.json, place it in a secure, accessible location and reference it in your environment accordingly.
- The MCP server path may vary after build; if dist/server.js does not exist, verify your build output location in your build script and adjust the MCP args accordingly.
- Use the MCP start command in development as documented (npm run mcp-server:dev) to leverage hot-reload and easier testing.
- When integrating with an AI assistant, structure your MCP messages to align with the available commands: createComposer, listComposers, details, web-access, privacy, settings, test, and check the mcp-server status.
- If you encounter token-related errors, double-check that the token has the required permissions for Cursor Background Composer operations.
- Review the repository’s GitHub Actions workflow to understand how background agents are triggered for issues; you can adapt similar patterns for your tasks.
Related MCP Servers
apify
The Apify MCP server enables your AI agents to extract data from social media, search engines, maps, e-commerce sites, or any other website using thousands of ready-made scrapers, crawlers, and automation tools available on the Apify Store.
Vibe-Coder
Vibe-Coder-MCP server extends AI assistants with specialized software development tools.
kanban
MCP Kanban is a specialized middleware designed to facilitate interaction between Large Language Models (LLMs) and Planka, a Kanban board application. It serves as an intermediary layer that provides LLMs with a simplified and enhanced API to interact with Planka's task management system.
cco
Real-time audit and approval system for Claude Code tool calls.
zip
An MCP tool that provides AI with the ability to compress and decompress local files.
mcpkit
Easy to use Official MCP Registry Client UI. npx @cybertheory/mcpkit