Source Map Parser MCP Server

Source Map Parser MCP Server

Enables mapping JavaScript error stack traces back to original source code, extracting context information to help developers locate and fix issues.

Category
Visit Server

Tools

operating_guide

# Parse Error Stack Trace This tool allows you to parse error stack traces by mapping them to the corresponding source code locations using source maps. It is particularly useful for debugging production errors where the stack trace points to minified or obfuscated code.

parse_stack

# Parse Error Stack Trace This tool allows you to parse error stack traces by providing the following: - A downloadable source map URL. - The line and column numbers from the stack trace. The tool will map the provided stack trace information to the corresponding source code location using the source map. It also supports fetching additional context lines around the error location for better debugging. ## Parameters: - **stacks**: An array of stack trace objects, each containing: - **line**: The line number in the stack trace. - **column**: The column number in the stack trace. - **sourceMapUrl**: The URL of the source map file corresponding to the stack trace. - **ctxOffset** (optional): The number of additional context lines to include before and after the error location in the source code. Defaults to 5. ## Returns: - A JSON object containing the parsed stack trace information, including the mapped source code location and context lines. - If parsing fails, an error message will be returned for the corresponding stack trace.

README

Source Map Parser

smithery badge

🌐 Languages: English | 简体中文

This project implements a WebAssembly-based Source Map parser that maps JavaScript error stack traces back to the original source code and extracts relevant context information. Developers can easily locate and fix issues by mapping JavaScript error stack traces to the original source code. We hope this documentation helps developers better understand and use this tool.

MCP Integration

Note: The minimum required Node.js version is 18+.

npx -y source-map-parser-mcp@latest

Features

  1. Stack Trace Parsing: Parse the corresponding source code location based on the provided line number, column number, and Source Map file.
  2. Batch Parsing: Support parsing multiple stack traces simultaneously and return batch results.
  3. Context Extraction: Extract a specified number of context lines to help developers better understand the environment where the error occurred.

MCP Service Tools

operating_guide

Retrieve the usage guide for the MCP service. This tool provides an interactive way to understand how to use the MCP service.

parse_stack

Parse stack trace information and Source Map URLs.

Request Example

  • stacks: Stack trace information, including line number, column number, and Source Map URL.
    • line: Line number (required).
    • column: Column number (required).
    • sourceMapUrl: URL of the Source Map file (required).
  • ctxOffset: Number of context lines (default is 5).
{
  "stacks": [
    {
      "line": 10,
      "column": 5,
      "sourceMapUrl": "https://example.com/source.map"
    }
  ],
  "ctxOffset": 5
}

Response Example

{
  "content": [
    {
      "type": "text",
      "text": "[{\"success\":true,\"token\":{\"line\":10,\"column\":5,\"sourceCode\":[{\"line\":8,\"isStackLine\":false,\"raw\":\"function foo() {\"},{\"line\":9,\"isStackLine\":false,\"raw\":\"  console.log('bar');\"},{\"line\":10,\"isStackLine\":true,\"raw\":\"  throw new Error('test');\"},{\"line\":11,\"isStackLine\":false,\"raw\":\"}\"}],\"src\":\"index.js\"}}]"
    }
  ]
}

4. Parsing Result Explanation

  • success: Indicates whether the parsing was successful.
  • token: The parsed token object returned upon successful parsing, including source code line number, column number, context code, etc.
  • error: Error information returned when parsing fails.

Advanced Usage

For security or performance reasons, some teams may prefer not to expose Source Maps directly to the browser for parsing. Instead, they preprocess the upload paths of Source Maps. For example, the path /assets/index.js can be transformed into source_backup/index.js.map.

In such cases, you can guide the model to complete the path transformation using prompt-based rules.

Prompt Example

**Source Map Tool Usage Guide**

Below are the rules for resolving remote Source Map URLs, where `origin_url` represents the error path in the stack trace.

1. Replace the Source Map resource URL based on the source path in the stack trace:
   `https://example.com${origin_url.replace('/assets/', '/source_backup/')}.map`

2. If no matching rule is found, use the following fallback rule:
   `${origin_url}.map` and retry.

FAQ

1. WebAssembly Module Loading Failure

If the tool returns the following error message, follow these steps to troubleshoot:

parser init error: WebAssembly.instantiate(): invalid value type 'externref', enable with --experimental-wasm-reftypes @+86

  1. Check Node.js Version: Ensure that the Node.js version is 18 or higher. If it is lower than 18, upgrade Node.js.
  2. Enable Experimental Flag: If the Node.js version is 18+ but the issue persists, start the tool with the following command:
    npx --node-arg=--experimental-wasm-reftypes -y source-map-parser-mcp@latest
    

Local Development Guide

1. Install Dependencies

Ensure Node.js and npm are installed, then run the following command to install project dependencies:

npm install

2. Link MCP Service

Run the following command to start the MCP server:

npx tsx src/main.ts

Internal Logic Overview

1. Key Files

  • stack_parser_js_sdk.js: JavaScript wrapper for the WebAssembly module, providing core functionality for stack trace parsing.
  • parser.ts: Main implementation of the parser, responsible for initializing the WebAssembly module, fetching Source Map content, and parsing stack trace information.
  • server.ts: Implementation of the MCP server, providing the parse_stack tool interface for external calls.

2. Modify Parsing Logic

To modify the parsing logic, edit the getSourceToken method in the parser.ts file.

3. Add New Tools

In the server.ts file, you can add new tool interfaces using the server.tool method.

Notes

  1. Source Map Files: Ensure the provided Source Map file URL is accessible and the file format is correct.
  2. Context Lines: The ctxOffset parameter controls the number of context lines to extract. Adjust it based on your needs.
  3. Error Handling: Parsing may encounter issues such as network errors or file format errors. It is recommended to handle errors appropriately when calling the tool.

Contribution Guide

We welcome Issues and Pull Requests to improve this project together.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured