Custom Context MCP Server
About
This Model Context Protocol (MCP) server provides tools for structuring and extracting data from text according to JSON templates.
Details
- Author
- omer-ayhan
- Downloads
- 285
- Categories
- Other
Jump to
- Group and structure text based on JSON templates with placeholders.
- Extract information from AI-generated text into structured JSON.
- Support for any arbitrary JSON structure with nested placeholders.
- Intelligent extraction of key‑value pairs from text.
- Process AI outputs into structured data for downstream applications.
- Two‑step workflow: prompt generation then structured conversion.
Install dependencies with npm install, then run the server with npm start. The server exposes two tools: group-text-by-json (generates a prompt for an AI to group text by a JSON template’s placeholder keys) and text-to-json (converts the grouped text back into a structured JSON object matching the original template). Templates use angle‑bracket placeholders (e.g., <name>) anywhere in a valid JSON structure.
Custom Context MCP Server
This Model Context Protocol (MCP) server provides tools for structuring and extracting data from text according to JSON templates.
Features
Text-to-JSON Transformation
- Group and structure text based on JSON templates with placeholders
- Extract information from AI-generated text into structured JSON formats
- Support for any arbitrary JSON structure with nested placeholders
- Intelligent extraction of key-value pairs from text
- Process AI outputs into structured data for downstream applications
Getting Started
Installation
npm install
Running the server
npm start
For development with hot reloading:
npm run dev:watch
Usage
This MCP server provides two main tools:
1. Group Text by JSON (group-text-by-json)
This tool takes a JSON template with placeholders and generates a prompt for an AI to group text according to the template's structure.
{
"template": "{ \"type\": \"<type>\", \"text\": \"<text>\" }"
}
The tool analyzes the template, extracts placeholder keys, and returns a prompt that guides the AI to extract information in a key-value format.
2. Text to JSON (text-to-json)
This tool takes the grouped text output from the previous step and converts it into a structured JSON object based on the original template.
{
"template": "{ \"type\": \"<type>\", \"text\": \"<text>\" }",
"text": "type: pen\ntext: This is a blue pen"
}
It extracts key-value pairs from the text and structures them according to the template.
Example Workflow
1. Define a JSON template with placeholders:
{
"item": {
"name": "<name>",
"price": "<price>",
"description": "<description>"
}
}
2. Use group-text-by-json to create a prompt for AI:
- The tool identifies placeholder keys: name, price, description
- Generates a prompt instructing the AI to group information by these keys
3. Send the prompt to an AI model and receive grouped text:
name: Blue Pen
price: $2.99
description: A smooth-writing ballpoint pen with blue ink
4. Use text-to-json to convert the grouped text to JSON:
- Result:
{
"item": {
"name": "Blue Pen",
"price": "$2.99",
"description": "A smooth-writing ballpoint pen with blue ink"
}
}
Template Format
Templates can include placeholders anywhere within a valid JSON structure:
- Use angle brackets to define placeholders: <name>, <type>, <price>, etc.
- The template must be a valid JSON string
- Placeholders can be at any level of nesting
- Supports complex nested structures
Example template with nested placeholders:
{
"product": {
"details": {
"name": "<name>",
"category": "<category>"
},
"pricing": {
"amount": "<price>",
"currency": "USD"
}
},
"metadata": {
"timestamp": "2023-09-01T12:00:00Z"
}
}
Implementation Details
The server works by:
1. Analyzing JSON templates to extract placeholder keys
2. Generating prompts that guide AI models to extract information by these keys
3. Parsing AI-generated text to extract key-value pairs
4. Reconstructing JSON objects based on the original template structure
Development
Prerequisites
- Node.js v18 or higher
- npm or yarn
Build and Run
```bash
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.



