The mcp-data-extractor server extracts embedded data and components from TypeScript/JavaScript source code into structured files.
- Data Extraction: Extracts data like i18n translations into JSON files, preserving nested structures, arrays, and template variables.
- SVG Extraction: Extracts SVG components from React/TypeScript/JavaScript files into individual .svg files, removing React-specific code.
- Source File Replacement: Optionally replaces original source files with migration messages to track processed files.
- Customization: Supports customizing warning messages and extending supported patterns via Babel AST traversal.
- Integration: Easily integrates into MCP Client configurations for automated extraction workflows.
Uses Babel to parse and traverse the AST (Abstract Syntax Tree) of source files for data extraction
Extracts data from JavaScript source code files, including nested objects, string literals, and template literals
Extracts SVG components from React files and removes React-specific code and props
Extracts SVG components from source files and creates individual .svg files with preserved structure and attributes
Extracts data from TypeScript source code files, including nested objects, string literals, and template literals
mcp-data-extractor MCP Server
A Model Context Protocol server that extracts embedded data (such as i18n translations or key/value configurations) from TypeScript/JavaScript source code into structured JSON configuration files.
Features
- Data Extraction:
- Extracts string literals, template literals, and complex nested objects
- Preserves template variables (e.g.,
Hello, {{name}}!
) - Supports nested object structures and arrays
- Maintains hierarchical key structure using dot notation
- Handles both TypeScript and JavaScript files with JSX support
- Replaces source file content with "MIGRATED TO " after successful extraction (configurable)
- SVG Extraction:
- Extracts SVG components from React/TypeScript/JavaScript files
- Preserves SVG structure and attributes
- Removes React-specific code and props
- Creates individual .svg files named after their component
- Replaces source file content with "MIGRATED TO " after successful extraction (configurable)
Usage
Add to your MCP Client configuration:
Basic Usage
The server provides two tools:
1. Data Extraction
Use extract_data
to extract data (like i18n translations) from source files:
2. SVG Extraction
Use extract_svg
to extract SVG components into individual files:
Source File Replacement
By default, after successful extraction, the server will replace the content of the source file with:
- "MIGRATED TO " for data extraction
- "MIGRATED TO " for SVG extraction
This helps track which files have already been processed and prevents duplicate extraction. It also makes it easy for LLMs and developers to see where the extracted data now lives when they encounter the source file later.
To disable this behavior, set the DISABLE_SOURCE_REPLACEMENT
environment variable to true
in your MCP configuration:
Supported Patterns
Data Extraction Patterns
The data extractor supports various patterns commonly used in TypeScript/JavaScript applications:
- Simple Object Exports:
- Nested Objects:
- Complex Structures with Arrays:
- Template Literals with Variables:
Output Formats
Data Extraction Output
The extracted data is saved as a JSON file with dot notation for nested structures:
SVG Extraction Output
SVG components are extracted into individual .svg files, with React-specific code removed. For example:
Input (React component):
Output (InspectionIcon.svg):
Extending Supported Patterns
The extractor uses Babel to parse and traverse the AST (Abstract Syntax Tree) of your source files. You can extend the supported patterns by modifying the source code:
- Add New Node Types: The
extractStringValue
method insrc/index.ts
handles different types of string values. Extend it to support new node types:
- Custom Value Processing: The
processValue
method handles different value types (strings, arrays, objects). Extend it to support new value types or custom processing:
- Custom AST Traversal: The server uses Babel's traverse to walk the AST. You can add new visitors to handle different node types:
Development
Install dependencies:
Build the server:
For development with auto-rebuild:
Debugging
Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector, which is available as a package script:
The Inspector will provide a URL to access debugging tools in your browser.
License
This project is licensed under the MIT License - see the LICENSE file for details.
You must be authenticated.
local-only server
The server can only run on the client's local machine because it depends on local resources.
A Model Context Protocol server that extracts embedded data (such as i18n translations or key/value configurations) from TypeScript/JavaScript source code into structured JSON configuration files.
Related Resources
Related MCP Servers
- AsecurityAlicenseAqualityA production-ready template for creating Model Context Protocol servers with TypeScript, providing tools for efficient testing, development, and deployment.Last updated -1112JavaScriptMIT License
- AsecurityFlicenseAqualityA TypeScript-based template for developing Model Context Protocol servers with features like dependency injection and service-based architecture, facilitating the creation and integration of custom data processing tools.Last updated -12TypeScript
- -securityAlicense-qualityA TypeScript implementation of a Model Context Protocol server that provides a frictionless framework for developers to build and deploy AI tools and prompts, focusing on developer experience with zero boilerplate and automatic tool registration.Last updated -6TypeScriptMIT License
- AsecurityAlicenseAqualityA TypeScript implementation of a Model Context Protocol server that provides marketing tools based on Open Strategy Partners' methodologies, enabling content creation, optimization, and product positioning through tools like value map generation, meta information creation, and content editing.Last updated -6491TypeScriptCC BY-SA 4.0