Skip to main content
Glama
sailay1996

Cursor Agent MCP Server

by sailay1996

cursor_agent_analyze_files

Analyze file paths to extract insights using a prompt-based approach, supporting multiple output formats for repository examination.

Instructions

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

Input Schema

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

Implementation Reference

  • Handler function for the cursor_agent_analyze_files tool. It destructures input args, composes a prompt listing the paths to analyze (with optional additional prompt), and invokes runCursorAgent to execute the underlying cursor-agent CLI.
    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 input schema for cursor_agent_analyze_files: requires paths (single string or array of strings), optional prompt, and inherits common options 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)
    MCP server.tool registration for cursor_agent_analyze_files, including name, description, schema, and 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 delegated by the handler; handles prompt execution via cursor-agent CLI, with arg normalization, env overrides, timeouts, and optional prompt echoing.
    // 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;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. The description mentions it's a 'Prompt-based wrapper' which hints at some LLM-based functionality, but doesn't explain what analysis actually entails, what permissions are needed, whether it modifies files, what the output looks like, or any rate limits. For a tool with 9 parameters and no annotation coverage, this leaves significant behavioral gaps.

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 extremely concise at just two short phrases. While this could be considered under-specified rather than appropriately concise, the structure is front-loaded with the core purpose. There's no wasted language, though the brevity comes at the cost of completeness. The two phrases each serve a purpose: stating the action and hinting at implementation.

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?

For a tool with 9 parameters, no annotations, no output schema, and 0% schema description coverage, the description is woefully incomplete. It doesn't explain what analysis means, what the tool actually does, what the output looks like, or how to use any of the parameters. The description provides only the barest minimum context for a complex multi-parameter tool.

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?

With 0% schema description coverage for 9 parameters, the description provides no information about any parameters. It doesn't explain what 'paths' should contain, what the 'prompt' should include, what 'extra_args' might be used for, or the purpose of parameters like 'cwd', 'executable', 'model', 'force', or 'echo_prompt'. The description fails to compensate for the complete lack of schema documentation.

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 'Analyze one or more paths; optional prompt' which provides a basic verb+resource combination, but it's vague about what 'analyze' means in this context. The phrase 'Prompt-based wrapper' adds some context but doesn't clearly differentiate this from sibling tools like cursor_agent_search_repo or cursor_agent_raw. The purpose is understandable but lacks specificity about the type of analysis performed.

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?

The description provides no guidance about when to use this tool versus alternatives. There's no mention of when this analysis tool is appropriate versus cursor_agent_search_repo for searching or cursor_agent_edit_file for modifications. The description doesn't specify any prerequisites, constraints, or typical use cases that would help an agent decide when to invoke this particular tool.

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