Cover image
Try Now
2025-04-08

Este servidor de protocolo de contexto modelo (MCP) proporciona herramientas para estructurar y extraer datos del texto de acuerdo con las plantillas JSON.

3 years

Works with Finder

1

Github Watches

0

Github Forks

1

Github Stars

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.

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • tomoyoshi hirata
  • Sony α7IIIマニュアルアシスタント

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • apappascs
  • Descubra la colección más completa y actualizada de servidores MCP en el mercado. Este repositorio sirve como un centro centralizado, que ofrece un extenso catálogo de servidores MCP de código abierto y propietarios, completos con características, enlaces de documentación y colaboradores.

  • ShrimpingIt
  • Manipulación basada en Micrypthon I2C del expansor GPIO de la serie MCP, derivada de AdaFruit_MCP230xx

  • jae-jae
  • Servidor MCP para obtener contenido de la página web con el navegador sin cabeza de dramaturgo.

  • ravitemer
  • Un poderoso complemento Neovim para administrar servidores MCP (protocolo de contexto del modelo)

  • patruff
  • Puente entre los servidores Ollama y MCP, lo que permite a LLM locales utilizar herramientas de protocolo de contexto del modelo

  • pontusab
  • La comunidad de cursor y windsurf, encontrar reglas y MCP

  • av
  • Ejecute sin esfuerzo LLM Backends, API, frontends y servicios con un solo comando.

  • Mintplex-Labs
  • La aplicación AI de escritorio todo en uno y Docker con trapo incorporado, agentes de IA, creador de agentes sin código, compatibilidad de MCP y más.

  • WangRongsheng
  • 🧑‍🚀 全世界最好的 llM 资料总结(数据处理、模型训练、模型部署、 O1 模型、 MCP 、小语言模型、视觉语言模型) | Resumen de los mejores recursos del mundo.

  • modelcontextprotocol
  • Servidores de protocolo de contexto modelo

    Reviews

    2 (1)
    Avatar
    user_ywfoLCzB
    2025-04-18

    I've been using custom-context-mcp by omer-ayhan for a while now, and it's truly a game-changer for managing multiple contexts with ease. The seamless integration and intuitive interface make it a must-have tool for any developer. Highly recommend checking it out on GitHub!