Skip to main content
Glama
MasonChow

Source Map Parser MCP Server

unpack_sources

Extract original source files and their content from a source map to map JavaScript error stack traces back to original code for debugging.

Instructions

Unpack Source Map Sources

This tool extracts all source files and their content from a source map.

Parameters:

  • sourceMapUrl: The URL of the source map file to unpack

Returns:

  • A JSON object containing:

    • sources: Object with source file paths as keys and their content as values

    • sourceRoot: The source root path from the source map

    • file: The original file name

    • totalSources: Total number of source files found

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceMapUrlYesThe URL of the source map file to unpack

Implementation Reference

  • MCP tool handler function for 'unpack_sources'. Awaits the parser instance and calls its unpackSources method, then returns the result as formatted JSON text content.
    handler: async ({ sourceMapUrl }, getParser) => {
      const parser = await getParser();
      const result = await parser.unpackSources(sourceMapUrl);
    
      return {
        content: [{
          type: "text",
          text: JSON.stringify(result, null, 2)
        }],
      }
    }
  • Zod input schema for the 'unpack_sources' tool, validating the required sourceMapUrl parameter.
    schema: {
      sourceMapUrl: z.string({
        description: "The URL of the source map file to unpack",
      }),
    },
  • src/tools.ts:348-354 (registration)
    Registration loop in registerTools function that calls server.tool() for 'unpack_sources' (and other tools) if it passes the filter check.
    toolDefinitions.forEach(tool => {
      if (shouldRegisterTool(tool.name, options.toolFilter)) {
        server.tool(tool.name, tool.description, tool.schema, async (params) => {
          return tool.handler(params, getParser);
        });
      }
    });
  • Core helper method in Parser class that fetches and parses the source map JSON to extract all source file paths and contents (from sourcesContent if present, else null), returning structured result.
    public async unpackSources(sourceMapUrl: string) {
      validateUrl(sourceMapUrl);
    
      try {
        const sourceMapContent = await this.fetchSourceMapContent(sourceMapUrl);
        const sourceMap = JSON.parse(sourceMapContent);
    
        if (!sourceMap.sources || !Array.isArray(sourceMap.sources)) {
          throw new Error("Invalid source map: missing or invalid sources array");
        }
    
        const result: Record<string, string | null> = {};
    
        // Extract sources from sourcesContent if available
        if (sourceMap.sourcesContent && Array.isArray(sourceMap.sourcesContent)) {
          sourceMap.sources.forEach((source: string, index: number) => {
            result[source] = sourceMap.sourcesContent[index] || null;
          });
        } else {
          // If no sourcesContent, list sources with null content
          sourceMap.sources.forEach((source: string) => {
            result[source] = null;
          });
        }
    
        return {
          sources: result,
          sourceRoot: sourceMap.sourceRoot || null,
          file: sourceMap.file || null,
          totalSources: sourceMap.sources.length
        };
      } catch (error) {
        throw new Error("unpack sources error: " + (error instanceof Error ? error.message : error), {
          cause: error,
        });
      }
    }
Behavior3/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. It discloses the tool's behavior by describing the extraction process and return structure, but it does not mention potential issues like network errors for the URL, rate limits, authentication needs, or what happens if the source map is invalid. This leaves gaps in behavioral understanding.

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. However, the 'Returns' section is somewhat redundant as it details the output format without an output schema, and the overall length could be slightly reduced by integrating information more tightly. It's efficient but not minimal.

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 the tool has one parameter with full schema coverage and no output schema, the description provides a clear purpose, parameter details, and return structure, which is mostly complete. However, it lacks information on error handling or prerequisites, which could be important for a tool that fetches and processes a URL. It's adequate but has minor gaps.

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%, so the schema already documents the 'sourceMapUrl' parameter fully. The description repeats this information in the Parameters section but does not add meaning beyond the schema, such as examples of valid URLs or format constraints. Baseline 3 is appropriate as the schema does the heavy lifting.

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 specific action ('extracts all source files and their content') and the resource ('from a source map'), distinguishing it from sibling tools like 'lookup_context' and 'parse_stack' which likely handle different aspects of debugging or stack analysis. The purpose is precise and unambiguous.

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 by specifying what the tool does (extracting source files from a source map), but it does not explicitly state when to use this tool versus alternatives like 'parse_stack' or provide any exclusions. The context is clear but lacks explicit guidance on 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/MasonChow/source-map-parser-mcp'

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