mcp-data-extractor
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.
<a href="https://glama.ai/mcp/servers/40c3iyazm5"><img width="380" height="200" src="https://glama.ai/mcp/servers/40c3iyazm5/badge" alt="MCP Data Extractor MCP server" /></a>
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 <target absolute path>" 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 <target absolute path>" 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 <target path>" for data extraction
- "MIGRATED TO <target directory>" 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.
This server cannot be installed
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.