Sponsored by Deepsite.site

Custom Context MCP Server

Created By
omer-ayhan8 months ago
This Model Context Protocol (MCP) server provides tools for structuring and extracting data from text according to JSON templates.
Content

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

# Install dependencies
npm install

# Build the project
npm run build

# Run the server
npm start

# Development with hot reloading
npm run dev:watch

Custom Hot Reloading

This project includes a custom hot reloading setup that combines:

  • nodemon: Watches for file changes in the src directory and rebuilds TypeScript files
  • browser-sync: Automatically refreshes the browser when build files change
  • Concurrent execution: Runs both services simultaneously with output synchronization

The setup is configured in:

  • nodemon.json: Controls TypeScript watching and rebuilding
  • package.json: Uses concurrently to run nodemon and browser-sync together

To use the custom hot reloading feature:

npm run dev:watch

This creates a development environment where:

  1. TypeScript files are automatically rebuilt when changed
  2. The MCP server restarts with the updated code
  3. Connected browsers refresh to show the latest changes

Using with MCP Inspector

You can use the MCP Inspector for debugging:

npm run dev

This runs the server with the MCP Inspector for visual debugging of requests and responses.

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Serper MCP ServerA Serper MCP Server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Amap Maps高德地图官方 MCP Server
Tavily Mcp
ChatWiseThe second fastest AI chatbot™
Playwright McpPlaywright MCP server
DeepChatYour AI Partner on Desktop
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
CursorThe AI Code Editor
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
WindsurfThe new purpose-built IDE to harness magic
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors