home / mcp / kv extractor mcp server

KV Extractor MCP Server

Provides automatic key-value extraction from unstructured text with autonomous key discovery and type-safe, multi-format outputs.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "kunihiros-kv-extractor-mcp-server": {
      "command": "python",
      "args": [
        "server.py"
      ],
      "env": {
        "OPENAI_API_KEY": "YOUR_API_KEY"
      }
    }
  }
}

This MCP server automatically extracts key-value pairs from noisy or unstructured text using LLMs and enforces type-safe output in JSON, YAML, or TOML formats. It is robust to imperfect inputs and discovers keys automatically, making it suitable for diverse real-world data.

How to use

You interact with the kv-extractor-mcp-server through an MCP client to process any text you provide. The server will autonomously identify relevant keys, infer their values, and return a well-structured result in your chosen format (JSON, YAML, or TOML). You can rely on it for robust extraction from messy inputs, with language support for Japanese, English, and Chinese.

Typical usage patterns include sending a block of text to the MCP endpoint and requesting one of the supported output formats. The server prioritizes producing a complete, well-formed response even if some data cannot be extracted fully.

How to install

Prerequisites: Python 3.9+ and an OpenAI API key. The OpenAI key should be available to the server as an environment variable.

Start the server using Python:

python server.py

If you prefer configuring the MCP host for logging, you can start the server process via the MCP command wrapper as shown below. This enables logging with an explicit log file path when needed.

"kv-extractor-mcp-server": {
  "command": "pipx",
  "args": ["run", "kv-extractor-mcp-server", "--log=off"],
  "env": {
    "OPENAI_API_KEY": "{apikey}"
  }
}

To enable logging with a specific log file path, use the following configuration example:

"kv-extractor-mcp-server": {
  "command": "pipx",
  "args": ["run", "kv-extractor-mcp-server", "--log=on", "--logfile=/workspace/logs/kv-extractor-mcp-server.log"],
  "env": {
    "OPENAI_API_KEY": "{apikey}"
  }
}

Configuration, security, and notes

Key environment and runtime notes you should know when using this MCP server:

  • On first launch, spaCy models are downloaded as part of preprocessing; this may take longer initially.
  • Ensure the OPENAI_API_KEY environment variable is set with your OpenAI key before starting the server.
  • The server aims to return a well-formed response in JSON, YAML, or TOML even if extraction is partial or encounters issues.
  • If you enable logging, provide an absolute path for the log file; relative paths are not accepted.

Example inputs and outputs

Provide your input text to the server and request a JSON, YAML, or TOML formatted output. The results include keys discovered from the input and their corresponding values, structured according to the chosen format.

Available tools

extract_json

Extracts key-value pairs from arbitrary noisy text and returns them as type-safe JSON (Python dict).

extract_yaml

Extracts key-value pairs from arbitrary noisy text and returns them as type-safe YAML (string).

extract_toml

Extracts key-value pairs from arbitrary noisy text and returns them as type-safe TOML (string).