Skip to main content
Glama

cursor_agent_plan_task

Generate structured plans for achieving goals with customizable constraints. Supports text, JSON, and markdown outputs for efficient task planning and execution.

Instructions

Generate a plan for a goal with optional constraints. Prompt-based wrapper.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
constraintsNo
cwdNo
echo_promptNo
executableNo
extra_argsNo
forceNo
goalYes
modelNo
output_formatNotext

Implementation Reference

  • The tool handler function. It destructures the arguments, composes a specific prompt for planning a task given a goal and optional constraints, and delegates to the shared runCursorAgent helper.
    async (args) => { try { const { goal, constraints, output_format, cwd, executable, model, force, extra_args } = args; const cons = constraints ?? []; const composedPrompt = `Create a step-by-step plan to accomplish the following goal:\n` + `- Goal: ${String(goal)}\n` + (cons.length ? `- Constraints:\n${cons.map((c)=>` - ${String(c)}`).join('\n')}\n` : '') + `Provide a numbered list of actions.`; return await runCursorAgent({ prompt: composedPrompt, output_format, extra_args, cwd, executable, model, force }); } catch (e) { return { content: [{ type: 'text', text: `Invalid params: ${e?.message || e}` }], isError: true }; } },
  • Zod schema defining the input parameters for the tool: required 'goal' string and optional 'constraints' array, plus shared COMMON fields.
    const PLAN_TASK_SCHEMA = z.object({ goal: z.string().min(1, 'goal is required'), constraints: z.array(z.string()).optional(), ...COMMON, });
  • server.js:361-379 (registration)
    Registration of the tool using McpServer.tool() method, providing name, description, schema, and inline handler function.
    server.tool( 'cursor_agent_plan_task', 'Generate a plan for a goal with optional constraints. Prompt-based wrapper.', PLAN_TASK_SCHEMA.shape, async (args) => { try { const { goal, constraints, output_format, cwd, executable, model, force, extra_args } = args; const cons = constraints ?? []; const composedPrompt = `Create a step-by-step plan to accomplish the following goal:\n` + `- Goal: ${String(goal)}\n` + (cons.length ? `- Constraints:\n${cons.map((c)=>` - ${String(c)}`).join('\n')}\n` : '') + `Provide a numbered list of actions.`; return await runCursorAgent({ prompt: composedPrompt, output_format, extra_args, cwd, executable, model, force }); } catch (e) { return { content: [{ type: 'text', text: `Invalid params: ${e?.message || e}` }], isError: true }; } }, );
  • Shared helper function invoked by the handler (and other tools). Normalizes input, constructs argv with prompt as positional arg, calls invokeCursorAgent, handles prompt echoing.
    async function runCursorAgent(input) { const source = (input && typeof input === 'object' && input.arguments && typeof input.prompt === 'undefined') ? input.arguments : input; const { prompt, output_format = 'text', extra_args, cwd, executable, model, force, } = source || {}; const argv = [...(extra_args ?? []), String(prompt)]; const usedPrompt = argv.length ? String(argv[argv.length - 1]) : ''; // Optional prompt echo and debug diagnostics if (process.env.DEBUG_CURSOR_MCP === '1') { try { const preview = usedPrompt.slice(0, 400).replace(/\n/g, '\\n'); console.error('[cursor-mcp] prompt:', preview); if (extra_args?.length) console.error('[cursor-mcp] extra_args:', JSON.stringify(extra_args)); if (model) console.error('[cursor-mcp] model:', model); if (typeof force === 'boolean') console.error('[cursor-mcp] force:', String(force)); } catch {} } const result = await invokeCursorAgent({ argv, output_format, cwd, executable, model, force }); // Echo prompt either when env is set or when caller provided echo_prompt: true (if host forwards unknown args it's fine) const echoEnabled = process.env.CURSOR_AGENT_ECHO_PROMPT === '1' || source?.echo_prompt === true; if (echoEnabled) { const text = `Prompt used:\n${usedPrompt}`; const content = Array.isArray(result?.content) ? result.content : []; return { ...result, content: [{ type: 'text', text }, ...content] }; } return result; }

Other Tools

Related 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