Skip to main content
Glama
sailay1996

Cursor Agent MCP Server

by sailay1996

cursor_agent_raw

Execute raw command-line arguments for the Cursor Agent CLI to perform repository analysis, code search, file editing, and task planning operations.

Instructions

Advanced: provide raw argv array to pass after common flags (e.g., ["search","--query","foo"]).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
argvYes
printNo
output_formatNotext
extra_argsNo
cwdNo
executableNo
modelNo
forceNo
echo_promptNo

Implementation Reference

  • The execution handler for the 'cursor_agent_raw' MCP tool. It extracts parameters from args and invokes the core 'invokeCursorAgent' helper with print disabled for raw access.
    async (args) => {
      try {
        const { argv, output_format, cwd, executable, model, force } = args;
        // For raw calls we disable implicit --print to allow commands like "--help"
        return await invokeCursorAgent({ argv, output_format, cwd, executable, model, force, print: false });
      } catch (e) {
        return { content: [{ type: 'text', text: `Invalid params: ${e?.message || e}` }], isError: true };
      }
    },
  • server.js:382-395 (registration)
    MCP tool registration call using server.tool() for 'cursor_agent_raw', specifying name, description, input schema, and handler function.
    server.tool(
     'cursor_agent_raw',
     'Advanced: provide raw argv array to pass after common flags (e.g., ["search","--query","foo"]).',
     RAW_SCHEMA.shape,
     async (args) => {
       try {
         const { argv, output_format, cwd, executable, model, force } = args;
         // For raw calls we disable implicit --print to allow commands like "--help"
         return await invokeCursorAgent({ argv, output_format, cwd, executable, model, force, print: false });
       } catch (e) {
         return { content: [{ type: 'text', text: `Invalid params: ${e?.message || e}` }], isError: true };
       }
     },
    );
  • Zod schema defining inputs for 'cursor_agent_raw': required argv array, optional print flag, and shared COMMON fields like output_format, cwd, etc.
    const RAW_SCHEMA = z.object({
      // raw argv to pass after common flags; e.g., ["--help"] or ["subcmd","--flag"]
      argv: z.array(z.string()).min(1, 'argv must contain at least one element'),
      print: z.boolean().optional(),
      ...COMMON,
    });
  • Core utility function invoked by the handler. Spawns 'cursor-agent' CLI process with argv, adds common flags (--print, --output-format, -m, -f), manages env vars, process lifecycle, stdout/stderr capture, timeouts, and idle termination.
    async function invokeCursorAgent({ argv, output_format = 'text', cwd, executable, model, force, print = true }) {
     const cmd = resolveExecutable(executable);
    
     // Compute model/force from args/env
     const userArgs = [...(argv ?? [])];
     const hasModelFlag = userArgs.some((a) => a === '-m' || a === '--model' || /^(?:-m=|--model=)/.test(String(a)));
     const envModel = process.env.CURSOR_AGENT_MODEL && process.env.CURSOR_AGENT_MODEL.trim();
     const effectiveModel = model?.trim?.() || envModel;
    
     const hasForceFlag = userArgs.some((a) => a === '-f' || a === '--force');
     const envForce = (() => {
       const v = (process.env.CURSOR_AGENT_FORCE || '').toLowerCase();
       return v === '1' || v === 'true' || v === 'yes' || v === 'on';
     })();
     const effectiveForce = typeof force === 'boolean' ? force : envForce;
    
     const finalArgv = [
       ...(print ? ['--print', '--output-format', output_format] : []),
       ...userArgs,
       ...(hasForceFlag || !effectiveForce ? [] : ['-f']),
       ...(hasModelFlag || !effectiveModel ? [] : ['-m', effectiveModel]),
     ];
    
     return new Promise((resolve) => {
       let settled = false;
       let out = '';
       let err = '';
       let idleTimer = null;
       let killedByIdle = false;
    
       const cleanup = () => {
         if (mainTimer) clearTimeout(mainTimer);
         if (idleTimer) clearTimeout(idleTimer);
       };
    
       if (process.env.DEBUG_CURSOR_MCP === '1') {
         try {
           console.error('[cursor-mcp] spawn:', cmd, ...finalArgv);
         } catch {}
       }
    
       const child = spawn(cmd, finalArgv, {
         shell: false, // safer across platforms; rely on PATH/PATHEXT
         cwd: cwd || process.cwd(),
         env: process.env,
       });
       try { child.stdin?.end(); } catch {}
    
       const idleMs = Number.parseInt(process.env.CURSOR_AGENT_IDLE_EXIT_MS || '0', 10);
       const scheduleIdleKill = () => {
         if (!Number.isFinite(idleMs) || idleMs <= 0) return;
         if (idleTimer) clearTimeout(idleTimer);
         idleTimer = setTimeout(() => {
           killedByIdle = true;
           try { child.kill('SIGKILL'); } catch {}
         }, idleMs);
       };
    
       child.stdout.on('data', (d) => {
         out += d.toString();
         scheduleIdleKill();
       });
    
       child.stderr.on('data', (d) => {
         err += d.toString();
       });
    
       child.on('error', (e) => {
         if (settled) return;
         settled = true;
         cleanup();
         if (process.env.DEBUG_CURSOR_MCP === '1') {
           try { console.error('[cursor-mcp] error:', e); } catch {}
         }
         const msg =
           `Failed to start "${cmd}": ${e?.message || e}\n` +
           `Args: ${JSON.stringify(finalArgv)}\n` +
           (process.env.CURSOR_AGENT_PATH ? `CURSOR_AGENT_PATH=${process.env.CURSOR_AGENT_PATH}\n` : '');
         resolve({ content: [{ type: 'text', text: msg }], isError: true });
       });
    
       const defaultTimeout = 30000;
       const timeoutMs = Number.parseInt(process.env.CURSOR_AGENT_TIMEOUT_MS || String(defaultTimeout), 10);
       const mainTimer = setTimeout(() => {
         try { child.kill('SIGKILL'); } catch {}
         if (settled) return;
         settled = true;
         cleanup();
         resolve({
           content: [{ type: 'text', text: `cursor-agent timed out after ${Number.isFinite(timeoutMs) ? timeoutMs : defaultTimeout}ms` }],
           isError: true,
         });
       }, Number.isFinite(timeoutMs) ? timeoutMs : defaultTimeout);
    
       child.on('close', (code) => {
         if (settled) return;
         settled = true;
         cleanup();
         if (process.env.DEBUG_CURSOR_MCP === '1') {
           try { console.error('[cursor-mcp] exit:', code, 'stdout bytes=', out.length, 'stderr bytes=', err.length); } catch {}
         }
         if (code === 0 || (killedByIdle && out)) {
           resolve({ content: [{ type: 'text', text: out || '(no output)' }] });
         } else {
           resolve({
             content: [{ type: 'text', text: `cursor-agent exited with code ${code}\n${err || out || '(no output)'}` }],
             isError: true,
           });
         }
       });
     });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'Advanced' and provides an example, but doesn't explain what the tool actually does (e.g., executes a command, invokes an agent, returns output), what permissions or side effects are involved, or how errors are handled. For a tool with 9 parameters and no annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with an example, making it appropriately concise and front-loaded. However, it could be more structured by explicitly stating the tool's action and context. Every word earns its place, but the brevity contributes to underspecification rather than clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (9 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the tool's core functionality, how parameters interact, what the output looks like, or how it relates to sibling tools. The example helps but doesn't provide enough context for an agent to use the tool effectively without additional assumptions.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning none of the 9 parameters are documented in the schema. The description only mentions 'argv' with an example, ignoring the other 8 parameters (print, output_format, extra_args, cwd, executable, model, force, echo_prompt). This fails to compensate for the schema gap, leaving most parameters unexplained and their purposes unclear.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'provide[s] raw argv array to pass after common flags' with an example, which gives a vague purpose of passing command-line arguments. However, it doesn't specify what tool or command these arguments are for, what 'common flags' refer to, or how this differs from sibling tools like cursor_agent_run. The description is functional but lacks specificity about the target resource or context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. The description mentions 'common flags' but doesn't explain what these are, when this raw approach is preferred over more structured sibling tools (e.g., cursor_agent_run), or any prerequisites. Usage is implied through the example but not explicitly stated, leaving the agent to infer context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sailay1996/cursor-agent-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server