docker-cursor-agent
v0.0.1
Published
Docker wrapper for Cursor CLI
Readme
Docker Cursor Agent
A Docker wrapper for Cursor CLI that allows you to run cursor-agent commands inside a container.
Overview
This project provides a Docker container that wraps the Cursor CLI, allowing you to execute cursor-agent commands as if it were a native binary. The container acts as a transparent wrapper, passing all arguments through to the cursor-agent binary.
Prerequisites
- Docker installed and running
- Bun runtime (for development)
ghCLI installed and authenticated (required for local deployment)CURSOR_API_KEYenvironment variable set (required for testing)
Installation
Build the Docker Image
# Using npm script
bun run build
# Or directly with Docker
docker build -t docker-cursor-agent .The image is based on debian:stable-slim and optimized for size (~291MB).
Pull from GHCR
docker pull ghcr.io/circlesac/docker-cursor-agent:latestUsage
MCP Config Generator CLI
This package includes a CLI tool to generate cursor-agent MCP configuration files from an mcp.json file.
Installation
# Install globally
npm install -g docker-cursor-agent
# Or use with npx (no installation needed)
npx docker-cursor-agent --file <mcp.json> --out <output-dir>Usage
# Generate MCP config from mcp.json
npx docker-cursor-agent --file ./mcp.json --out ./build
# This creates:
# ./build/.cursor/mcp.json
# ./build/.cursor/projects/workspace/mcp-approvals.jsonOptions
--file, -f- Path to inputmcp.jsonfile (required)--out, -o- Output directory where.cursorfolder will be created (required, defaults to current directory)
Example with Docker
After generating the config files, use them with the Docker container:
docker run --rm \
-e CURSOR_API_KEY=your_key \
-v $(pwd)/build/.cursor:/root/.cursor \
ghcr.io/circlesac/docker-cursor-agent:latest \
--print --output-format stream-json "your prompt"Docker Container Usage
Basic Usage
Run cursor-agent commands through Docker:
# Using the published image from GHCR
docker run --rm -e CURSOR_API_KEY=your_key ghcr.io/circlesac/docker-cursor-agent:latest --version
docker run --rm -e CURSOR_API_KEY=your_key ghcr.io/circlesac/docker-cursor-agent:latest --help
# Or using locally built image
docker run --rm -e CURSOR_API_KEY=your_key docker-cursor-agent --versionPassing Arguments
All arguments are passed through to cursor-agent:
# Using published image
docker run --rm -e CURSOR_API_KEY=your_key ghcr.io/circlesac/docker-cursor-agent:latest <your-args>
# Or using locally built image
docker run --rm -e CURSOR_API_KEY=your_key docker-cursor-agent <your-args>Environment Variables
CURSOR_API_KEY- Required for cursor-agent to function (pass via-eflag)
Development
Setup
bun installBuild
# Build TypeScript source code
bun run build
# Build Docker image
bun run build:dockerThe build script compiles TypeScript source to JavaScript in the dist/ directory. The build:docker script builds the Docker image locally.
Run Tests
bun run testNote: Tests require CURSOR_API_KEY to be set in your environment. Tests will fail if it's not present.
Lint
bun run lintDeploy to GHCR
Deploy the Docker image to GitHub Container Registry:
# Deploy using TypeScript script (recommended for production)
bun run deploy
# Or test deployment locally using act (requires act installed)
bun run deploy:actThe deploy script will:
- Get authentication token (from
GITHUB_TOKEN,GHCR_TOKEN, orghCLI) - Extract repository info from git remote
- Build Docker image
- Push to
ghcr.io/circlesac/docker-cursor-agent:latest
Published Image: The image is available at ghcr.io/circlesac/docker-cursor-agent:latest
Note: deploy:act uses act to test the GitHub Actions workflow locally. It passes GITHUB_TOKEN directly to act using gh auth token.
Environment Variables for Deploy
GITHUB_TOKEN- Auto-provided in GitHub Actions (has GHCR permissions)GHCR_TOKEN- Optional override for local deploymentGHCR_TAG- Optional image tag (defaults tolatest)GITHUB_ACTOR- Optional username for login (defaults to repo owner)
Local Deployment
For local deployment, ensure you have gh CLI authenticated:
gh auth login --scopes write:packagesOr set GHCR_TOKEN environment variable:
export GHCR_TOKEN=your_token
bun run deployProject Structure
docker-cursor-agent/
├── .dockerignore # Docker ignore patterns
├── .github/
│ └── workflows/
│ └── deploy.yml # GitHub Actions workflow for automated deployment
├── .gitignore # Git ignore patterns
├── Dockerfile # Debian-based container definition
├── package.json # Bun project configuration
├── README.md # This file
├── src/
│ ├── cli.ts # CLI entry point
│ └── utils.ts # MCP config processing utilities
├── scripts/
│ └── deploy.ts # Deployment script to GHCR
├── tests/
│ ├── cli.test.ts # CLI tests
│ └── docker.test.ts # Docker tests
├── tsconfig.json # TypeScript configuration (base)
├── tsconfig.build.json # TypeScript build configuration
└── vitest.config.ts # Vitest configuration