Skip to main content
Glama

cursor_agent_analyze_files

Analyze files or directories using a prompt-based approach. Customize output formats like text, JSON, or markdown for efficient repository analysis and reduced token usage.

Instructions

Analyze one or more paths; optional prompt. Prompt-based wrapper.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdNo
echo_promptNo
executableNo
extra_argsNo
forceNo
modelNo
output_formatNotext
pathsYes
promptNo

Implementation Reference

  • Handler function for 'cursor_agent_analyze_files' tool. Composes a prompt listing the paths to analyze and an optional additional prompt, then delegates execution to runCursorAgent helper.
    async (args) => { try { const { paths, prompt, output_format, cwd, executable, model, force, extra_args } = args; const list = Array.isArray(paths) ? paths : [paths]; const composedPrompt = `Analyze the following paths in the repository:\n` + list.map((p) => `- ${String(p)}`).join('\n') + '\n' + (prompt ? `Additional prompt: ${String(prompt)}\n` : ''); 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 input parameters for the 'cursor_agent_analyze_files' tool: paths (string or array), optional prompt, and common fields like output_format, model, etc.
    const ANALYZE_FILES_SCHEMA = z.object({ paths: z.union([z.string().min(1), z.array(z.string().min(1)).min(1)]), prompt: z.string().optional(), ...COMMON, });
  • server.js:320-337 (registration)
    Registration of the 'cursor_agent_analyze_files' tool on the MCP server, including name, description, schema, and inline handler function.
    server.tool( 'cursor_agent_analyze_files', 'Analyze one or more paths; optional prompt. Prompt-based wrapper.', ANALYZE_FILES_SCHEMA.shape, async (args) => { try { const { paths, prompt, output_format, cwd, executable, model, force, extra_args } = args; const list = Array.isArray(paths) ? paths : [paths]; const composedPrompt = `Analyze the following paths in the repository:\n` + list.map((p) => `- ${String(p)}`).join('\n') + '\n' + (prompt ? `Additional prompt: ${String(prompt)}\n` : ''); 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 }; } }, );
  • Helper function invoked by the tool handler to parse arguments and spawn the underlying 'cursor-agent' CLI process with the composed prompt.
    // Accepts either a flat args object or an object with an "arguments" field (some hosts). 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