
Data Extractor
Extracts embedded data like i18n translations and configurations from TypeScript/JavaScript code into separate JSON files. Also extracts SVG components from React files into individual .svg files.
Extracts data from TypeScript/JavaScript code into JSON configuration files, facilitating code refactoring and improved maintainability.
What it does
- Extract i18n translations from TypeScript/JavaScript to JSON
- Extract SVG components from React files to individual .svg files
- Preserve template variables and nested object structures
- Replace extracted code with migration markers
- Handle both TypeScript and JavaScript with JSX support
Best for
About Data Extractor
Data Extractor is a community-built MCP server published by sammcj that provides AI assistants with tools and capabilities via the Model Context Protocol. Data Extractor converts JavaScript and TypeScript code into JSON configuration files using JSON stringify for better mai It is categorized under productivity, developer tools. This server exposes 2 tools that AI clients can invoke during conversations and coding sessions.
How to install
You can install Data Extractor in your AI client of choice. Use the install panel on this page to get one-click setup for Cursor, Claude Desktop, VS Code, and other MCP-compatible clients. This server runs locally on your machine via the stdio transport.
License
Data Extractor is released under the MIT license. This is a permissive open-source license, meaning you can freely use, modify, and distribute the software.
Tools (2)
Extract data content (e.g. i18n translations) from source code to a JSON file. IMPORTANT: When encountering files with data such as i18n content embedded in code, use this tool directly instead of reading the file content first. This tool will programmatically extract all translations into a structured JSON file, preserving nested objects, arrays, template variables, and formatting. This helps keep translations as configuration and prevents filling up the AI context window with translation content. By default, the source file will be replaced with "MIGRATED TO <target absolute path>" and a warning message after successful extraction, making it easy to track where the data was moved to. This behaviour can be disabled by setting the DISABLE_SOURCE_REPLACEMENT environment variable to 'true'. The warning message can be customized by setting the WARNING_MESSAGE environment variable.
Extract SVG components from React/TypeScript/JavaScript files into individual .svg files. This tool will preserve the SVG structure and attributes while removing React-specific code. By default, the source file will be replaced with "MIGRATED TO <target absolute path>" and a warning message after successful extraction, making it easy to track where the SVGs were moved to. This behaviour can be disabled by setting the DISABLE_SOURCE_REPLACEMENT environment variable to 'true'. The warning message can be customized by setting the WARNING_MESSAGE environment variable.
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:
{
"mcpServers": {
"data-extractor": {
"command": "npx",
"args": [
"-y",
"mcp-data-extractor"
],
"disabled": false,
"autoApprove": [
"extract_data",
"extract_svg"
]
}
}
}
Basic Usage
The server provides two tools:
1. Data Extraction
Use extract_data to extract data (like i18n translations) from source files:
<use_mcp_tool>
<server_name>data-extractor</server_name>
<tool_name>extract_data</tool_name>
<arguments>
{
"sourcePath": "src/translations.ts",
"targetPath": "src/translations.json"
}
</arguments>
</use_mcp_tool>
2. SVG Extraction
Use extract_svg to extract SVG components into individual files:
<use_mcp_tool>
<server_name>data-extractor</server_name>
<tool_name>extract_svg</tool_name>
<arguments>
{
"sourcePath": "src/components/icons/InspectionIcon.tsx",
"targetDir": "src/assets/icons"
}
</arguments>
</use_mcp_tool>
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:
{
"mcpServers": {
"data-extractor": {
"command": "npx",
"args": [
"-y",
"mcp-data-extractor"
],
"env": {
"DISABLE_SOURCE_REPLACEMENT": "true"
},
"disabled": false,
"autoApprove": [
"extract_data",
"extract_svg"
]
}
}
}
Supported Patterns
Data Extraction Patterns
The data extractor supports various patterns commonly used in TypeScript/JavaScript applications:
- Simple Object Exports:
export default {
welcome: "Welcome to our app",
greeting: "Hello, {name}!",
submit: "Submit form"
};
- Nested Objects:
export default {
header: {
title: "Book Your Flight",
subtitle: "Find the best deals"
},
footer: {
content: [
"Please refer to {{privacyPolicyUrl}} for details",
"© {{year}} {{companyName}}"
]
}
};
- Complex Structures with Arrays:
export default {
faq: {
heading: "Common questions",
content: [
{
heading: "What if I need to change my flight?",
content: "You can change your flight online if:",
list: [
"You have a flexible fare type",
"Your flight is more than 24 hours away"
]
}
]
}
};
- Template Literals with Variables:
export default {
greeting: `Hello, {{username}}!`,
message: `Welcome to {{appName}}`
};
Output Formats
Data Extraction Output
The extracted data is saved as a JSON file with dot notation for nested structures:
{
"welcome": "Welcome to our app",
"header.title": "Book Your Flight",
"footer.content.0": "Please refer to {{privacyPolicyUrl}} for details",
"footer.content.1": "© {{year}} {{companyName}}",
"faq.content.0.heading": "What if I need to change my flight?"
}
SVG Extraction Output
SVG components are extracted into individual .svg files, with React-specific code removed. For example:
Input (React component):
const InspectionIcon: React.FC<InspectionIconProps> = ({ title }) => (
<svg className="c-tab__icon" width="40px" id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<title>{title}</title>
<path className="cls-1" d="M18.89,12.74a3.18,3.18,0,0,1-3.24-3.11..." />
</svg>
);
Output (InspectionIcon.svg):
<svg width="40px" id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<path class="cls-1" d="M18.89,12.74a3.18,3.18,0,0,1-3.24-3.11..." />
</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
extractStringValuemethod insrc/index.tshandles different types of string values. Extend it to support new node types:
private extractStringValue(node: t.Node): string | null {
if (t.isStringLiteral(node)) {
return node.value;
} else if (t.isTemplateLiteral(node)) {
return node.quasis.map(quasi => quasi.value.raw).join('{{}}');
}
// Add support for new node types here
return null;
}
- Custom Value Processing: The
processValuemethod handles different value types (strings, arrays, objects). Extend it to support new value types or custom processing:
private processValue(value: t.Node, currentPath: string[]): void {
if (t.isStringLiteral(value) || t.isTemplateLiteral(value)) {
// Process string values
} else if (t.isArrayExpression(value)) {
// Process arrays
} else if (t.isObjectExpression(value)) {
// Process objects
}
// Add support for new value types here
}
- Custom AST Traversal: The server uses Babel's traverse to walk the AST. You can add new visitors to handle different node types:
traverse(ast, {
ExportDefaultDeclaration(path: NodePath<t.ExportDefaultDeclaration>) {
// Handle default exports
},
// Add new visitors here
});
Development
Install dependencies:
npm install
Build the server:
npm run build
For development with auto-rebuild:
npm run watch
Debugging
Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the MCP Inspector, which is available as a package script:
npm run inspector
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.
Alternatives
Related Skills
Browse all skillsUse when building MCP servers or clients that connect AI systems with external tools and data sources. Invoke for MCP protocol compliance, TypeScript/Python SDKs, resource providers, tool functions.
CCXT cryptocurrency exchange library for TypeScript and JavaScript developers (Node.js and browser). Covers both REST API (standard) and WebSocket API (real-time). Helps install CCXT, connect to exchanges, fetch market data, place orders, stream live tickers/orderbooks, handle authentication, and manage errors. Use when working with crypto exchanges in TypeScript/JavaScript projects, trading bots, arbitrage systems, or portfolio management tools. Includes both REST and WebSocket examples.
.NET/C# backend developer for ASP.NET Core APIs with Entity Framework Core. Builds REST APIs, minimal APIs, gRPC services, authentication with Identity/JWT, authorization, database operations, background services, SignalR real-time features. Activates for: .NET, C#, ASP.NET Core, Entity Framework Core, EF Core, .NET Core, minimal API, Web API, gRPC, authentication .NET, Identity, JWT .NET, authorization, LINQ, async/await C#, background service, IHostedService, SignalR, SQL Server, PostgreSQL .NET, dependency injection, middleware .NET.
Build full-stack applications with Supabase (PostgreSQL, Auth, Storage, Real-time, Edge Functions). Use when implementing authentication, database design with RLS, file storage, real-time features, or serverless functions.
Senior Python developer expertise for writing clean, efficient, and well-documented code. Use when: writing Python code, optimizing Python scripts, reviewing Python code for best practices, debugging Python issues, implementing type hints, or when user mentions Python, PEP 8, or needs help with Python data structures and algorithms.
UI design system toolkit for Senior UI Designer including design token generation, component documentation, responsive design calculations, and developer handoff tools. Use for creating design systems, maintaining visual consistency, and facilitating design-dev collaboration.