Skip to main content
Glama

Get Completion

get_completion

Provides code completion suggestions for Svelte development by analyzing symbols to reveal available members, methods, and types.

Instructions

Get code completion suggestions at a symbol position. Useful for discovering available members, methods, and types.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to the file
symbolNameYesName of the symbol to get completions at (positions cursor at the symbol)
symbolKindNoKind of symbol
limitNoMax items to return. Default: 30

Implementation Reference

  • Handler function for the 'get_completion' tool that uses the LSP client to fetch and format completion suggestions.
      async ({
        filePath,
        symbolName,
        symbolKind,
        limit,
      }): Promise<ToolResult> => {
        try {
          const prep = await prepareSymbolRequest(lsp, filePath, symbolName, symbolKind);
          if ("error" in prep) return textResult(prep.error);
    
          const params = {
            ...makePositionParams(prep.ctx),
            context: { triggerKind: 1 }, // Invoked
          };
    
          const result = await lsp.request("textDocument/completion", params);
          if (!result) return textResult("No completions available.");
    
          let items: any[];
          if (Array.isArray(result)) {
            items = result;
          } else if (Array.isArray(result.items)) {
            items = result.items;
          } else {
            return textResult("No completions available.");
          }
    
          if (items.length === 0) return textResult("No completions available.");
    
          const lines: string[] = [];
          let shown = 0;
    
          for (const item of items) {
            if (shown >= limit) break;
    
            const label = item.label ?? "?";
            const kindVal = item.kind ?? 0;
            const kindName = completionItemKindName(kindVal);
            const detail = item.detail;
            const labelDetail = item.labelDetails?.detail;
            const labelDesc = item.labelDetails?.description;
    
            let entry = `  ${label}`;
            if (labelDetail) entry += labelDetail;
            entry += ` (${kindName})`;
            if (detail) entry += ` - ${detail}`;
            if (labelDesc) entry += ` [${labelDesc}]`;
            lines.push(entry);
            shown++;
          }
    
          const header =
            shown < items.length
              ? `Showing ${shown} of ${items.length} completion(s)`
              : `Found ${items.length} completion(s)`;
    
          return textResult(
            `${header} at '${symbolName}':\n\n` + lines.join("\n")
          );
        } catch (ex) {
          return textResult(formatError(ex));
        }
      }
    );
  • Input schema definition for the 'get_completion' tool.
    inputSchema: z.object({
      filePath: z
        .string()
        .describe("Absolute path to the file"),
      symbolName: z
        .string()
        .describe(
          "Name of the symbol to get completions at (positions cursor at the symbol)"
        ),
      symbolKind: z.string().optional().describe("Kind of symbol"),
      limit: z
        .number()
        .default(30)
        .describe("Max items to return. Default: 30"),
    }),
  • Registration of the 'get_completion' tool within the registerIntelliSenseTools function.
    server.registerTool(
      "get_completion",
      {
        title: "Get Completion",
        description:
          "Get code completion suggestions at a symbol position. Useful for discovering available members, methods, and types.",
        inputSchema: z.object({
          filePath: z
            .string()
            .describe("Absolute path to the file"),
          symbolName: z
            .string()
            .describe(
              "Name of the symbol to get completions at (positions cursor at the symbol)"
            ),
          symbolKind: z.string().optional().describe("Kind of symbol"),
          limit: z
            .number()
            .default(30)
            .describe("Max items to return. Default: 30"),
        }),
      },
      async ({
        filePath,
        symbolName,
        symbolKind,
        limit,
      }): Promise<ToolResult> => {
        try {
          const prep = await prepareSymbolRequest(lsp, filePath, symbolName, symbolKind);
          if ("error" in prep) return textResult(prep.error);
    
          const params = {
            ...makePositionParams(prep.ctx),
            context: { triggerKind: 1 }, // Invoked
          };
    
          const result = await lsp.request("textDocument/completion", params);
          if (!result) return textResult("No completions available.");
    
          let items: any[];
          if (Array.isArray(result)) {
            items = result;
          } else if (Array.isArray(result.items)) {
            items = result.items;
          } else {
            return textResult("No completions available.");
          }
    
          if (items.length === 0) return textResult("No completions available.");
    
          const lines: string[] = [];
          let shown = 0;
    
          for (const item of items) {
            if (shown >= limit) break;
    
            const label = item.label ?? "?";
            const kindVal = item.kind ?? 0;
            const kindName = completionItemKindName(kindVal);
            const detail = item.detail;
            const labelDetail = item.labelDetails?.detail;
            const labelDesc = item.labelDetails?.description;
    
            let entry = `  ${label}`;
            if (labelDetail) entry += labelDetail;
            entry += ` (${kindName})`;
            if (detail) entry += ` - ${detail}`;
            if (labelDesc) entry += ` [${labelDesc}]`;
            lines.push(entry);
            shown++;
          }
    
          const header =
            shown < items.length
              ? `Showing ${shown} of ${items.length} completion(s)`
              : `Found ${items.length} completion(s)`;
    
          return textResult(
            `${header} at '${symbolName}':\n\n` + lines.join("\n")
          );
        } catch (ex) {
          return textResult(formatError(ex));
        }
      }
    );
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 the tool is 'useful for discovering available members, methods, and types,' which gives some context about the output, but it doesn't cover critical aspects like whether this is a read-only operation, potential rate limits, authentication needs, or error handling. For a tool with no annotations, this leaves significant gaps in understanding its behavior.

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

Conciseness5/5

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

The description is concise and well-structured with two sentences: the first states the purpose, and the second adds usage context. Every sentence earns its place by providing essential information without redundancy. It's front-loaded with the core functionality, making it easy to understand quickly.

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 tool's complexity (4 parameters, no annotations, no output schema), the description is incomplete. It lacks details on behavioral traits (e.g., read-only vs. destructive), output format, error conditions, and how it integrates with sibling tools. Without annotations or an output schema, the description should do more to compensate, but it only provides basic purpose and usage hints, leaving the agent with insufficient context for reliable invocation.

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

Parameters3/5

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

Schema description coverage is 100%, meaning the input schema already documents all parameters thoroughly. The description adds minimal value beyond the schema: it implies parameters relate to 'symbol position' but doesn't provide additional syntax, format details, or examples. With high schema coverage, the baseline score of 3 is appropriate, as the description doesn't compensate but also doesn't detract.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get code completion suggestions at a symbol position.' It specifies the verb ('Get') and resource ('code completion suggestions'), and mentions the context ('at a symbol position'). However, it doesn't explicitly differentiate from sibling tools like 'get_signature_help' or 'get_hover', which are also related to code assistance.

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

Usage Guidelines3/5

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

The description provides implied usage guidance: 'Useful for discovering available members, methods, and types.' This suggests when to use it (for code completion in development contexts), but it doesn't explicitly state when not to use it or mention alternatives among sibling tools (e.g., 'get_signature_help' for parameter hints). The guidance is helpful but lacks specificity about tool selection.

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/adainrivers/SvelteLS.MCP'

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