Data Extractor MCP server

Extracts data from TypeScript/JavaScript code into JSON configuration files, facilitating code refactoring and improved maintainability.
Back to servers
Setup instructions
Provider
Sam McLeod
Release date
Feb 24, 2025
Language
TypeScript
Package
Stats
2.6K downloads
6 stars

This MCP server extracts data like i18n translations and SVG components from TypeScript/JavaScript source code into structured JSON configuration files or individual SVG files. It helps you separate your data from your code for better maintainability and organization.

Installation

Add the MCP-data-extractor server 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 main extraction tools:

Data Extraction

Use the extract_data tool 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>

SVG Extraction

Use the extract_svg tool 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>

Configuration Options

Source File Replacement

By default, after successful extraction, the server replaces the content of the source file with:

  • "MIGRATED TO " for data extraction
  • "MIGRATED TO " for SVG extraction

This helps track which files have been processed and prevents duplicate extraction.

To disable this behavior, set the DISABLE_SOURCE_REPLACEMENT environment variable:

{
  "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:

  • 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:

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>

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "data-extractor" '{"command":"npx","args":["-y","mcp-data-extractor"],"disabled":false,"autoApprove":["extract_data","extract_svg"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "data-extractor": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-data-extractor"
            ],
            "disabled": false,
            "autoApprove": [
                "extract_data",
                "extract_svg"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "data-extractor": {
            "command": "npx",
            "args": [
                "-y",
                "mcp-data-extractor"
            ],
            "disabled": false,
            "autoApprove": [
                "extract_data",
                "extract_svg"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later