Add MCP and force mode support to cursor-cli module
- Add MCP (Model Context Protocol) configuration options - Add force mode for non-interactive automation - Add default model selection - Add rules system configuration - Update install script to configure MCP and rules - Update start script with environment variables - Add comprehensive Coder Tasks integration examples - Add configuration variables table - Add screenshot section placeholder - Update terminal usage examples with force mode Features added: - enable_mcp: Enable/disable MCP support - mcp_config_path: Custom MCP configuration file path - enable_force_mode: Enable force mode for automation - default_model: Set default AI model - enable_rules: Enable rules system Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
This commit is contained in:
parent
057d40554b
commit
443db3b7dc
@ -1,14 +1,14 @@
|
|||||||
---
|
---
|
||||||
display_name: Cursor CLI
|
display_name: Cursor CLI
|
||||||
description: Run Cursor CLI agent in your workspace
|
description: Run Cursor CLI agent in your workspace with MCP and force mode support
|
||||||
icon: ../../../../.icons/cursor.svg
|
icon: ../../../../.icons/cursor.svg
|
||||||
verified: true
|
verified: true
|
||||||
tags: [cli, cursor, ai, agent]
|
tags: [cli, cursor, ai, agent, mcp, automation]
|
||||||
---
|
---
|
||||||
|
|
||||||
# Cursor CLI
|
# Cursor CLI
|
||||||
|
|
||||||
Run the [Cursor CLI](https://docs.cursor.com/en/cli/overview) agent in your workspace for terminal-based AI coding assistance.
|
Run the [Cursor CLI](https://docs.cursor.com/en/cli/overview) agent in your workspace for terminal-based AI coding assistance. Supports both interactive and non-interactive modes, MCP (Model Context Protocol), and automation features.
|
||||||
|
|
||||||
```tf
|
```tf
|
||||||
module "cursor-cli" {
|
module "cursor-cli" {
|
||||||
@ -72,6 +72,67 @@ module "cursor-cli" {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### With MCP and force mode for automation
|
||||||
|
|
||||||
|
```tf
|
||||||
|
module "cursor-cli" {
|
||||||
|
count = data.coder_workspace.me.start_count
|
||||||
|
source = "registry.coder.com/coder/cursor-cli/coder"
|
||||||
|
version = "1.0.0"
|
||||||
|
agent_id = coder_agent.example.id
|
||||||
|
folder = "/home/coder/project"
|
||||||
|
|
||||||
|
# MCP Configuration
|
||||||
|
enable_mcp = true
|
||||||
|
mcp_config_path = "/home/coder/.cursor/custom-mcp.json"
|
||||||
|
|
||||||
|
# Automation Features
|
||||||
|
enable_force_mode = true
|
||||||
|
default_model = "gpt-5"
|
||||||
|
|
||||||
|
# Rules System
|
||||||
|
enable_rules = true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Integration with Coder Tasks
|
||||||
|
|
||||||
|
```tf
|
||||||
|
# Cursor CLI module with automation features
|
||||||
|
module "cursor-cli" {
|
||||||
|
count = data.coder_workspace.me.start_count
|
||||||
|
source = "registry.coder.com/coder/cursor-cli/coder"
|
||||||
|
version = "1.0.0"
|
||||||
|
agent_id = coder_agent.example.id
|
||||||
|
enable_force_mode = true
|
||||||
|
default_model = "claude-4-sonnet"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Automated code review task
|
||||||
|
resource "coder_task" "ai_code_review" {
|
||||||
|
agent_id = coder_agent.example.id
|
||||||
|
name = "AI Code Review"
|
||||||
|
command = "cursor-agent -p 'review the latest git changes for security issues and best practices' --force --output-format text"
|
||||||
|
cron = "0 9 * * 1-5" # Weekdays at 9 AM
|
||||||
|
}
|
||||||
|
|
||||||
|
# Automated test generation
|
||||||
|
resource "coder_task" "generate_tests" {
|
||||||
|
agent_id = coder_agent.example.id
|
||||||
|
name = "Generate Missing Tests"
|
||||||
|
command = "cursor-agent -p 'analyze the src/ directory and generate unit tests for functions missing test coverage' --force"
|
||||||
|
cron = "0 18 * * *" # Daily at 6 PM
|
||||||
|
}
|
||||||
|
|
||||||
|
# Documentation updates
|
||||||
|
resource "coder_task" "update_docs" {
|
||||||
|
agent_id = coder_agent.example.id
|
||||||
|
name = "Update Documentation"
|
||||||
|
command = "cursor-agent -p 'review and update README.md to reflect any new features or API changes' --force --model gpt-5"
|
||||||
|
cron = "0 12 * * 0" # Sundays at noon
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### With custom pre-install script
|
### With custom pre-install script
|
||||||
|
|
||||||
```tf
|
```tf
|
||||||
@ -107,9 +168,15 @@ cursor-agent "refactor the auth module to use JWT tokens"
|
|||||||
# Non-interactive mode with text output
|
# Non-interactive mode with text output
|
||||||
cursor-agent -p "find and fix performance issues" --output-format text
|
cursor-agent -p "find and fix performance issues" --output-format text
|
||||||
|
|
||||||
|
# Force mode for automation (non-interactive)
|
||||||
|
cursor-agent -p "review code for security issues" --force
|
||||||
|
|
||||||
# Use specific model
|
# Use specific model
|
||||||
cursor-agent -p "add error handling" --model "gpt-5"
|
cursor-agent -p "add error handling" --model "gpt-5"
|
||||||
|
|
||||||
|
# Combine force mode with model selection
|
||||||
|
cursor-agent -p "generate comprehensive tests" --force --model "claude-4-sonnet"
|
||||||
|
|
||||||
# Session management
|
# Session management
|
||||||
cursor-agent ls # List all previous chats
|
cursor-agent ls # List all previous chats
|
||||||
cursor-agent resume # Resume latest conversation
|
cursor-agent resume # Resume latest conversation
|
||||||
@ -131,14 +198,41 @@ cursor-agent --resume="chat-id" # Resume specific conversation
|
|||||||
- Model selection support
|
- Model selection support
|
||||||
- Git integration for change reviews
|
- Git integration for change reviews
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|
### Cursor CLI with Coder Tasks Integration
|
||||||
|
|
||||||
|
*Screenshot showing the cursor-cli module working with automated Coder Tasks will be added here*
|
||||||
|
|
||||||
|
- Interactive web interface for cursor-agent
|
||||||
|
- Automated code review tasks running in background
|
||||||
|
- Terminal output showing force mode execution
|
||||||
|
- MCP integration with custom tools
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
The module supports the same configuration options as the Cursor CLI:
|
The module supports comprehensive configuration options:
|
||||||
|
|
||||||
- **MCP (Model Context Protocol)**: Automatically detects `mcp.json` configuration
|
### Core Features
|
||||||
|
- **MCP (Model Context Protocol)**: Automatically detects `mcp.json` configuration or uses custom path
|
||||||
- **Rules System**: Supports `.cursor/rules` directory for custom agent behavior
|
- **Rules System**: Supports `.cursor/rules` directory for custom agent behavior
|
||||||
|
- **Force Mode**: Enable non-interactive automation for CI/CD pipelines
|
||||||
|
- **Model Selection**: Set default AI model (gpt-5, claude-4-sonnet, etc.)
|
||||||
- **Environment Variables**: Respects Cursor CLI environment settings
|
- **Environment Variables**: Respects Cursor CLI environment settings
|
||||||
|
|
||||||
|
### Available Variables
|
||||||
|
|
||||||
|
| Variable | Type | Default | Description |
|
||||||
|
|----------|------|---------|-------------|
|
||||||
|
| `enable_mcp` | bool | `true` | Enable MCP (Model Context Protocol) support |
|
||||||
|
| `mcp_config_path` | string | `""` | Path to custom MCP configuration file |
|
||||||
|
| `enable_force_mode` | bool | `false` | Enable force mode for non-interactive automation |
|
||||||
|
| `default_model` | string | `""` | Default AI model (e.g., gpt-5, claude-4-sonnet) |
|
||||||
|
| `enable_rules` | bool | `true` | Enable the rules system (.cursor/rules directory) |
|
||||||
|
| `install_cursor_cli` | bool | `true` | Whether to install Cursor CLI |
|
||||||
|
| `install_agentapi` | bool | `true` | Whether to install AgentAPI web interface |
|
||||||
|
| `folder` | string | `"/home/coder"` | Working directory for cursor-agent |
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
The module creates log files in the workspace's `~/.cursor-cli-module` directory. Check these files if you encounter issues:
|
The module creates log files in the workspace's `~/.cursor-cli-module` directory. Check these files if you encounter issues:
|
||||||
|
|||||||
@ -78,6 +78,36 @@ variable "post_install_script" {
|
|||||||
default = null
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "enable_mcp" {
|
||||||
|
type = bool
|
||||||
|
description = "Whether to enable MCP (Model Context Protocol) support."
|
||||||
|
default = true
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "mcp_config_path" {
|
||||||
|
type = string
|
||||||
|
description = "Path to the MCP configuration file (mcp.json)."
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "enable_force_mode" {
|
||||||
|
type = bool
|
||||||
|
description = "Whether to enable force mode for non-interactive automation."
|
||||||
|
default = false
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "default_model" {
|
||||||
|
type = string
|
||||||
|
description = "Default AI model to use (e.g., gpt-5, claude-4-sonnet)."
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "enable_rules" {
|
||||||
|
type = bool
|
||||||
|
description = "Whether to enable the rules system (.cursor/rules directory)."
|
||||||
|
default = true
|
||||||
|
}
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
app_slug = "cursor-cli"
|
app_slug = "cursor-cli"
|
||||||
install_script = file("${path.module}/scripts/install.sh")
|
install_script = file("${path.module}/scripts/install.sh")
|
||||||
@ -114,6 +144,11 @@ module "agentapi" {
|
|||||||
|
|
||||||
ARG_FOLDER='${var.folder}' \
|
ARG_FOLDER='${var.folder}' \
|
||||||
ARG_INSTALL='${var.install_cursor_cli}' \
|
ARG_INSTALL='${var.install_cursor_cli}' \
|
||||||
|
ARG_ENABLE_MCP='${var.enable_mcp}' \
|
||||||
|
ARG_MCP_CONFIG_PATH='${var.mcp_config_path}' \
|
||||||
|
ARG_ENABLE_FORCE_MODE='${var.enable_force_mode}' \
|
||||||
|
ARG_DEFAULT_MODEL='${var.default_model}' \
|
||||||
|
ARG_ENABLE_RULES='${var.enable_rules}' \
|
||||||
/tmp/install.sh
|
/tmp/install.sh
|
||||||
EOT
|
EOT
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,11 @@ set -o nounset
|
|||||||
echo "--------------------------------"
|
echo "--------------------------------"
|
||||||
echo "folder: $ARG_FOLDER"
|
echo "folder: $ARG_FOLDER"
|
||||||
echo "install: $ARG_INSTALL"
|
echo "install: $ARG_INSTALL"
|
||||||
|
echo "enable_mcp: $ARG_ENABLE_MCP"
|
||||||
|
echo "mcp_config_path: $ARG_MCP_CONFIG_PATH"
|
||||||
|
echo "enable_force_mode: $ARG_ENABLE_FORCE_MODE"
|
||||||
|
echo "default_model: $ARG_DEFAULT_MODEL"
|
||||||
|
echo "enable_rules: $ARG_ENABLE_RULES"
|
||||||
echo "--------------------------------"
|
echo "--------------------------------"
|
||||||
|
|
||||||
set +o nounset
|
set +o nounset
|
||||||
@ -28,6 +33,59 @@ if [ "${ARG_INSTALL}" = "true" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Cursor CLI installed"
|
echo "Cursor CLI installed"
|
||||||
|
|
||||||
|
# Configure MCP if enabled
|
||||||
|
if [ "${ARG_ENABLE_MCP}" = "true" ]; then
|
||||||
|
echo "Configuring MCP (Model Context Protocol)..."
|
||||||
|
|
||||||
|
# Create MCP config directory if it doesn't exist
|
||||||
|
mkdir -p "$HOME/.cursor"
|
||||||
|
|
||||||
|
# If custom MCP config path is provided, copy it
|
||||||
|
if [ -n "${ARG_MCP_CONFIG_PATH}" ] && [ -f "${ARG_MCP_CONFIG_PATH}" ]; then
|
||||||
|
cp "${ARG_MCP_CONFIG_PATH}" "$HOME/.cursor/mcp.json"
|
||||||
|
echo "MCP configuration copied from ${ARG_MCP_CONFIG_PATH}"
|
||||||
|
else
|
||||||
|
# Create a basic MCP config if none exists
|
||||||
|
if [ ! -f "$HOME/.cursor/mcp.json" ]; then
|
||||||
|
cat > "$HOME/.cursor/mcp.json" << 'EOF'
|
||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"filesystem": {
|
||||||
|
"command": "npx",
|
||||||
|
"args": ["@modelcontextprotocol/server-filesystem", "/tmp"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
echo "Basic MCP configuration created"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Configure rules system if enabled
|
||||||
|
if [ "${ARG_ENABLE_RULES}" = "true" ]; then
|
||||||
|
echo "Setting up Cursor rules system..."
|
||||||
|
mkdir -p "$HOME/.cursor/rules"
|
||||||
|
|
||||||
|
# Create a basic rules file if none exists
|
||||||
|
if [ ! -f "$HOME/.cursor/rules/general.md" ]; then
|
||||||
|
cat > "$HOME/.cursor/rules/general.md" << 'EOF'
|
||||||
|
# General Coding Rules
|
||||||
|
|
||||||
|
## Code Style
|
||||||
|
- Use consistent indentation (2 spaces for JS/TS, 4 for Python)
|
||||||
|
- Add meaningful comments for complex logic
|
||||||
|
- Follow language-specific naming conventions
|
||||||
|
|
||||||
|
## Best Practices
|
||||||
|
- Write tests for new functionality
|
||||||
|
- Handle errors gracefully
|
||||||
|
- Use descriptive variable and function names
|
||||||
|
EOF
|
||||||
|
echo "Basic rules configuration created"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "Skipping Cursor CLI installation"
|
echo "Skipping Cursor CLI installation"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -30,10 +30,32 @@ echo " - Start interactive session: cursor-agent"
|
|||||||
echo " - Non-interactive mode: cursor-agent -p 'your prompt here'"
|
echo " - Non-interactive mode: cursor-agent -p 'your prompt here'"
|
||||||
echo " - With specific model: cursor-agent -p 'prompt' --model 'gpt-5'"
|
echo " - With specific model: cursor-agent -p 'prompt' --model 'gpt-5'"
|
||||||
echo " - Text output format: cursor-agent -p 'prompt' --output-format text"
|
echo " - Text output format: cursor-agent -p 'prompt' --output-format text"
|
||||||
|
echo " - Force mode (non-interactive): cursor-agent -p 'prompt' --force"
|
||||||
echo " - List sessions: cursor-agent ls"
|
echo " - List sessions: cursor-agent ls"
|
||||||
echo " - Resume session: cursor-agent resume"
|
echo " - Resume session: cursor-agent resume"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# Set up environment variables for configuration
|
||||||
|
if [ -n "${ARG_DEFAULT_MODEL:-}" ]; then
|
||||||
|
export CURSOR_DEFAULT_MODEL="${ARG_DEFAULT_MODEL}"
|
||||||
|
echo "Default model set to: ${ARG_DEFAULT_MODEL}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${ARG_ENABLE_FORCE_MODE:-false}" = "true" ]; then
|
||||||
|
export CURSOR_FORCE_MODE="true"
|
||||||
|
echo "Force mode enabled for non-interactive automation"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${ARG_ENABLE_MCP:-true}" = "true" ]; then
|
||||||
|
echo "MCP (Model Context Protocol) support enabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${ARG_ENABLE_RULES:-true}" = "true" ]; then
|
||||||
|
echo "Rules system enabled (.cursor/rules directory)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
# Configure for interactive mode with text output
|
# Configure for interactive mode with text output
|
||||||
# If no arguments provided, start in interactive mode
|
# If no arguments provided, start in interactive mode
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user