Sponsored by Deepsite.site

Source_map_parser

Created By
MasonChow9 months ago
Content

Source Map Parser

🌐 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

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.

Local Development Guide

1. Install Dependencies

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

npm install

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.

Server Config

{
  "mcpServers": {
    "source_map_parser": {
      "command": "npx",
      "args": [
        "-y",
        "source-map-parser-mcp"
      ]
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
WindsurfThe new purpose-built IDE to harness magic
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Serper MCP ServerA Serper MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
CursorThe AI Code Editor
Playwright McpPlaywright MCP server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Amap Maps高德地图官方 MCP Server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
ChatWiseThe second fastest AI chatbot™
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
DeepChatYour AI Partner on Desktop
Tavily Mcp