Skip to main content
Glama
MasonChow

Source Map Parser MCP Server

lookup_context

Map compiled JavaScript code positions to original source code context using source maps, helping developers locate and fix issues by providing surrounding code lines.

Instructions

Lookup Source Code Context

This tool looks up original source code context for a specific line and column position in compiled/minified code.

Parameters:

  • line: The line number in the compiled code (1-based)

  • column: The column number in the compiled code

  • sourceMapUrl: The URL of the source map file

  • contextLines (optional): Number of context lines to include before and after the target line (default: 5)

Returns:

  • A JSON object containing the source code context snippet with file path, target line info, and surrounding context lines

  • Returns null if the position cannot be mapped

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
lineYesThe line number in the compiled code (1-based)
columnYesThe column number in the compiled code
sourceMapUrlYesThe URL of the source map file
contextLinesNoNumber of context lines to include (default: 5)

Implementation Reference

  • MCP tool handler for 'lookup_context'. Awaits parser instance, invokes parser.lookupContext with parameters, and returns JSON-formatted result as text content.
    handler: async ({ line, column, sourceMapUrl, contextLines }, getParser) => {
      const parser = await getParser();
      const result = await parser.lookupContext(line, column, sourceMapUrl, contextLines);
    
      return {
        content: [{
          type: "text",
          text: JSON.stringify(result, null, 2)
        }],
      }
    }
  • Zod input schema for 'lookup_context' tool parameters: line (number), column (number), sourceMapUrl (string), contextLines (optional number, default 5).
    schema: {
      line: z.number({
        description: "The line number in the compiled code (1-based)",
      }),
      column: z.number({
        description: "The column number in the compiled code",
      }),
      sourceMapUrl: z.string({
        description: "The URL of the source map file",
      }),
      contextLines: z.number({
        description: "Number of context lines to include (default: 5)",
      }).optional().default(5),
    },
  • src/tools.ts:263-305 (registration)
    Declarative tool definition object for 'lookup_context' in toolDefinitions array, used by registerTools to conditionally register the tool with the MCP server via server.tool().
        {
          name: "lookup_context",
          description: `
      # Lookup Source Code Context
    
      This tool looks up original source code context for a specific line and column position in compiled/minified code.
    
      ## Parameters:
      - **line**: The line number in the compiled code (1-based)
      - **column**: The column number in the compiled code
      - **sourceMapUrl**: The URL of the source map file
      - **contextLines** (optional): Number of context lines to include before and after the target line (default: 5)
    
      ## Returns:
      - A JSON object containing the source code context snippet with file path, target line info, and surrounding context lines
      - Returns null if the position cannot be mapped
    `,
          schema: {
            line: z.number({
              description: "The line number in the compiled code (1-based)",
            }),
            column: z.number({
              description: "The column number in the compiled code",
            }),
            sourceMapUrl: z.string({
              description: "The URL of the source map file",
            }),
            contextLines: z.number({
              description: "Number of context lines to include (default: 5)",
            }).optional().default(5),
          },
          handler: async ({ line, column, sourceMapUrl, contextLines }, getParser) => {
            const parser = await getParser();
            const result = await parser.lookupContext(line, column, sourceMapUrl, contextLines);
    
            return {
              content: [{
                type: "text",
                text: JSON.stringify(result, null, 2)
              }],
            }
          }
        },
  • Core helper method in Parser class: lookupContext. Validates URL, fetches source map content, initializes parser, calls external sourceMapParser.lookup_context WASM function, and returns the source context result. Invoked by the tool handler.
    public async lookupContext(line: number, column: number, sourceMapUrl: string, contextLines: number = 5) {
      validateUrl(sourceMapUrl);
      await this.init();
    
      try {
        const sourceMapContent = await this.fetchSourceMapContent(sourceMapUrl);
        // Use the high-level lookup_context function directly
        const result = sourceMapParser.lookup_context(sourceMapContent, line, column, contextLines);
    
        return result;
      } catch (error) {
        throw new Error("lookup context error: " + (error instanceof Error ? error.message : error), {
          cause: error,
        });
      }
    }
Behavior4/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. It effectively describes what the tool does (looks up source code context), returns (JSON object or null), and key behaviors (e.g., returns null if unmappable, includes context lines). It adds value by explaining the output format and failure case, though it could mention performance or error-handling details.

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 well-structured with headings and bullet points, making it easy to scan. It is appropriately sized with no wasted sentences, though it could be slightly more concise by avoiding repetition of schema details. Every sentence contributes to understanding the tool's purpose and usage.

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

Completeness4/5

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

Given no annotations and no output schema, the description does a good job of explaining the tool's behavior, parameters, and returns. It covers the core functionality and failure case, but could be more complete by detailing error conditions or performance aspects. For a tool with 4 parameters and no structured output, it provides adequate context.

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 repeats parameter details (e.g., line number, default for contextLines) without adding significant meaning beyond the schema. This meets the baseline of 3 for high schema coverage, but no extra value is provided.

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

Purpose5/5

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

The description clearly states the tool 'looks up original source code context for a specific line and column position in compiled/minified code,' which is a specific verb (looks up) + resource (source code context) + scope (for compiled/minified code). It distinguishes from siblings like 'parse_stack' and 'unpack_sources' by focusing on mapping positions to source code rather than parsing or extracting sources.

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 implies usage for mapping compiled code positions to source code, but does not explicitly state when to use this tool vs. alternatives like 'parse_stack' or 'unpack_sources.' It provides context (e.g., for compiled/minified code) but lacks explicit exclusions or named alternatives, leaving some ambiguity for the agent.

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/MasonChow/source-map-parser-mcp'

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