Skip to main content
Glama

Incoming Calls

incoming_calls

Identify all functions or methods that call a specified symbol in Svelte code to analyze dependencies and understand usage patterns.

Instructions

Find all functions/methods that call the specified symbol.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to the file
symbolNameYesName of the symbol to find
symbolKindNoKind of symbol

Implementation Reference

  • Tool registration and handler implementation for 'incoming_calls'. It attempts to use 'textDocument/prepareCallHierarchy' and 'callHierarchy/incomingCalls' from the LSP, falling back to 'incomingCallsFallback' if not supported.
    server.registerTool(
      "incoming_calls",
      {
        title: "Incoming Calls",
        description:
          "Find all functions/methods that call the specified symbol.",
        inputSchema: z.object({
          filePath: z.string().describe("Absolute path to the file"),
          symbolName: z
            .string()
            .describe("Name of the symbol to find"),
          symbolKind: z.string().optional().describe("Kind of symbol"),
        }),
      },
      async ({ filePath, symbolName, symbolKind }): Promise<ToolResult> => {
        try {
          const prep = await prepareSymbolRequest(lsp, filePath, symbolName, symbolKind);
          if ("error" in prep) return textResult(prep.error);
    
          // Try native call hierarchy
          try {
            const prepareResult = await lsp.request(
              "textDocument/prepareCallHierarchy",
              makePositionParams(prep.ctx)
            );
            if (Array.isArray(prepareResult) && prepareResult.length > 0) {
              const result = await lsp.request(
                "callHierarchy/incomingCalls",
                { item: prepareResult[0] }
              );
              if (Array.isArray(result) && result.length > 0) {
                const lines: string[] = [
                  `Found ${result.length} caller(s) of '${symbolName}':`,
                  "",
                ];
                for (const call of result) {
                  if (call.from) {
                    lines.push(formatHierarchyItem(call.from));
                  }
                }
                return textResult(lines.join("\n"));
              }
            }
          } catch {
            // call hierarchy not supported, try fallback
          }
    
          // Fallback: use references
          return textResult(
            await incomingCallsFallback(lsp, prep.ctx, symbolName)
          );
        } catch (ex) {
          return textResult(formatError(ex));
        }
      }
    );
  • Fallback handler for 'incoming_calls' when the native call hierarchy LSP method is not supported. It uses 'textDocument/references' to find callers.
    async function incomingCallsFallback(
      lsp: LspClient,
      ctx: { uri: string; line: number; character: number },
      symbolName: string
    ): Promise<string> {
      const params = {
        textDocument: { uri: ctx.uri },
        position: { line: ctx.line, character: ctx.character },
        context: { includeDeclaration: false },
      };
    
      const refs = await lsp.request("textDocument/references", params);
      if (!Array.isArray(refs) || refs.length === 0) {
        return `No incoming calls found for '${symbolName}'.`;
      }
    
      const callers: Array<{
        name: string;
        kind: string;
        path: string;
        line: number;
      }> = [];
      const seen = new Set<string>();
      const symbolCache = new Map<string, any[]>();
    
      for (const r of refs) {
        const refUri = r.uri;
        const refLine = r.range?.start?.line;
        if (!refUri || refLine == null) continue;
    
        const refPath = uriToPath(refUri);
    
        if (!symbolCache.has(refUri)) {
          await lsp.ensureDocumentOpen(refPath);
          const symResult = await lsp.request("textDocument/documentSymbol", {
            textDocument: { uri: refUri },
          });
          symbolCache.set(refUri, Array.isArray(symResult) ? symResult : []);
        }
    
        const symbols = symbolCache.get(refUri)!;
        const container = findContainingMethod(symbols, refLine);
        if (!container) continue;
    
        const name = container.name ?? "?";
        const kind = symbolKindName(container.kind ?? 0);
        const range = container.selectionRange ?? container.range;
        const line = (range?.start?.line ?? 0) + 1;
    
        const key = `${name}:${refPath}:${line}`;
        if (seen.has(key)) continue;
        seen.add(key);
    
        callers.push({ name, kind, path: refPath, line });
      }
    
      if (callers.length === 0) {
        return `No incoming calls found for '${symbolName}'.`;
      }
    
      const lines: string[] = [
        `Found ${callers.length} caller(s) of '${symbolName}':`,
        "",
      ];
      for (const c of callers) {
        lines.push(`  ${c.name} (${c.kind}) - ${c.path}:${c.line}`);
      }
      return lines.join("\n");
    }
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 only states what the tool does without mentioning permissions, rate limits, output format, or error handling. For a tool with no annotations, this is insufficient to inform the agent about operational traits.

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 a single, clear sentence that efficiently conveys the tool's purpose without unnecessary words. It is front-loaded and wastes no space, making it easy for an agent to parse quickly.

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

Completeness3/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is minimally adequate. It explains the basic purpose but lacks details on behavior, output, or usage context, which are needed for full completeness in this environment.

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?

The schema description coverage is 100%, meaning all parameters are documented in the schema. The description does not add any additional meaning or context beyond what the schema provides, such as examples or usage notes for the parameters, so it meets the baseline score of 3.

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: 'Find all functions/methods that call the specified symbol.' It uses specific verbs ('find') and identifies the resource ('functions/methods'), but does not explicitly distinguish it from sibling tools like 'find_references' or 'outgoing_calls', which prevents a score of 5.

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 on when to use this tool versus alternatives. It does not mention sibling tools such as 'find_references' or 'outgoing_calls', nor does it specify any prerequisites or exclusions for usage, leaving the agent without contextual direction.

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