Skip to main content
Glama
omer-ayhan

Custom Context MCP Server

by omer-ayhan

Servidor MCP de contexto personalizado

Este servidor de Protocolo de Contexto de Modelo (MCP) proporciona herramientas para estructurar y extraer datos del texto de acuerdo con plantillas JSON.

Características

Transformación de texto a JSON

  • Agrupar y estructurar texto basado en plantillas JSON con marcadores de posición

  • Extraer información de texto generado por IA en formatos JSON estructurados

  • Soporte para cualquier estructura JSON arbitraria con marcadores de posición anidados

  • Extracción inteligente de pares clave-valor del texto

  • Procesar los resultados de IA en datos estructurados para aplicaciones posteriores

Related MCP server: Unstructured Document Processor MCP

Empezando

Instalación

npm install

Ejecutando el servidor

npm start

Para desarrollo con recarga en caliente:

npm run dev:watch

Uso

Este servidor MCP proporciona dos herramientas principales:

1. Agrupar texto por JSON ( group-text-by-json )

Esta herramienta toma una plantilla JSON con marcadores de posición y genera un mensaje para que una IA agrupe el texto de acuerdo con la estructura de la plantilla.

{
	"template": "{ \"type\": \"<type>\", \"text\": \"<text>\" }"
}

La herramienta analiza la plantilla, extrae claves de marcador de posición y devuelve un mensaje que guía a la IA para extraer información en un formato clave-valor.

2. Texto a JSON ( text-to-json )

Esta herramienta toma la salida de texto agrupada del paso anterior y la convierte en un objeto JSON estructurado basado en la plantilla original.

{
	"template": "{ \"type\": \"<type>\", \"text\": \"<text>\" }",
	"text": "type: pen\ntext: This is a blue pen"
}

Extrae pares clave-valor del texto y los estructura según la plantilla.

Ejemplo de flujo de trabajo

  1. Defina una plantilla JSON con marcadores de posición:

    {
        "item": {
            "name": "<name>",
            "price": "<price>",
            "description": "<description>"
        }
    }
  2. Utilice group-text-by-json para crear un mensaje para IA:

    • La herramienta identifica claves de marcador de posición: nombre, precio, descripción

    • Genera un mensaje que indica a la IA que agrupe la información mediante estas claves

  3. Envía el mensaje a un modelo de IA y recibe texto agrupado:

    name: Blue Pen
    price: $2.99
    description: A smooth-writing ballpoint pen with blue ink
  4. Utilice text-to-json para convertir el texto agrupado a JSON:

    • Resultado: GXP8

Formato de plantilla

Las plantillas pueden incluir marcadores de posición en cualquier lugar dentro de una estructura JSON válida:

  • Utilice corchetes angulares para definir marcadores de posición: <name> , <type> , <price> , etc.

  • La plantilla debe ser una cadena JSON válida

  • Los marcadores de posición pueden estar en cualquier nivel de anidación.

  • Admite estructuras anidadas complejas

Plantilla de ejemplo con marcadores de posición anidados:

{
	"product": {
		"details": {
			"name": "<name>",
			"category": "<category>"
		},
		"pricing": {
			"amount": "<price>",
			"currency": "USD"
		}
	},
	"metadata": {
		"timestamp": "2023-09-01T12:00:00Z"
	}
}

Detalles de implementación

El servidor funciona mediante:

  1. Análisis de plantillas JSON para extraer claves de marcador de posición

  2. Generar indicaciones que guíen a los modelos de IA para extraer información mediante estas claves

  3. Análisis de texto generado por IA para extraer pares clave-valor

  4. Reconstrucción de objetos JSON basados en la estructura de la plantilla original

Desarrollo

Prerrequisitos

  • Node.js v18 o superior

  • npm o hilo

Construir y ejecutar

# Install dependencies
npm install

# Build the project
npm run build

# Run the server
npm start

# Development with hot reloading
npm run dev:watch

Recarga en caliente personalizada

Este proyecto incluye una configuración de recarga en caliente personalizada que combina:

  • nodemon : vigila los cambios de archivos en el directorio src y reconstruye los archivos TypeScript

  • browser-sync : actualiza automáticamente el navegador cuando cambian los archivos de compilación

  • Ejecución concurrente : ejecuta ambos servicios simultáneamente con sincronización de salida

La configuración se realiza en:

  • nodemon.json : controla la observación y reconstrucción de TypeScript

  • package.json : se usa simultáneamente para ejecutar nodemon y browser-sync juntos

Para utilizar la función de recarga en caliente personalizada:

npm run dev:watch

Esto crea un entorno de desarrollo donde:

  1. Los archivos TypeScript se reconstruyen automáticamente cuando se modifican

  2. El servidor MCP se reinicia con el código actualizado

  3. Los navegadores conectados se actualizan para mostrar los últimos cambios

Uso con MCP Inspector

Puede utilizar el Inspector MCP para depurar:

npm run dev

Esto ejecuta el servidor con el Inspector MCP para la depuración visual de solicitudes y respuestas.

Available Tools

2 tools
group-text-by-jsonC

Gives a prompt text for AI to group text based on JSON placeholders. This tool accepts a JSON template with placeholders.

ParametersJSON Schema
NameRequiredDescriptionDefault
templateYesJSON template with placeholders

TDQS

C2.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool 'gives a prompt text' but does not explain what happens next—e.g., whether it returns a prompt for AI processing, requires additional steps, or has any side effects like rate limits or authentication needs. This leaves key behavioral traits unspecified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two sentences that directly address the tool's function and input. It avoids unnecessary details and is front-loaded with the core purpose. However, it could be more structured by explicitly separating usage guidelines or behavioral context.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It does not explain what the tool returns (e.g., the prompt text format or any output structure), nor does it cover behavioral aspects like error handling or prerequisites. For a tool with no structured support, the description should provide more context to be fully helpful.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal meaning beyond the input schema, which has 100% coverage for the single parameter 'template.' It restates that the tool 'accepts a JSON template with placeholders,' mirroring the schema's description. Since schema coverage is high, the baseline score is 3, as the description does not significantly enhance parameter understanding.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool 'gives a prompt text for AI to group text based on JSON placeholders,' which provides a vague purpose. It mentions the action ('gives a prompt text') and resource ('JSON placeholders'), but lacks specificity about what 'group text' means or how the prompt is used. It does not clearly distinguish from sibling tool 'text-to-json,' leaving ambiguity in its exact function.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description offers no guidance on when to use this tool versus alternatives. It does not mention the sibling tool 'text-to-json' or provide context for choosing between them. Without explicit usage instructions or exclusions, users must infer when this tool is appropriate, leading to potential misuse.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

text-to-jsonB

Converts groupped text from group-text-by-json tool to JSON. This tool accepts a JSON template with placeholders and groupped text from group-text-by-json tool.

ParametersJSON Schema
NameRequiredDescriptionDefault
templateYesJSON template with placeholders
textYesGroupped text from groupTextByJson tool

TDQS

B3.2/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes the conversion process but lacks details on error handling, output format, or any constraints (e.g., template syntax, validation rules). For a tool with no annotations, this leaves significant gaps in understanding how it behaves beyond the basic operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise with two sentences that directly state the tool's function and inputs. It avoids unnecessary words and is front-loaded with the core purpose. However, the repetition of 'group-text-by-json tool' could be slightly streamlined, and it lacks structural elements like bullet points for clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (data transformation with two parameters), lack of annotations, and no output schema, the description is incomplete. It covers the basic operation but misses details on output format, error cases, or example usage. While it mentions the sibling tool, more context on the overall workflow would improve completeness for effective agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('template' and 'text') with clear descriptions. The description adds minimal value by repeating that it accepts a 'JSON template with placeholders' and 'groupped text from groupTextByJson tool', but doesn't provide additional semantics beyond what the schema states. This meets the baseline for high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: converting grouped text to JSON using a template. It specifies the verb 'converts' and the resource 'groupped text from group-text-by-json tool', making the action and input source explicit. However, it doesn't fully distinguish from its sibling 'group-text-by-json' beyond mentioning it as the source, missing an opportunity to clarify the workflow relationship more distinctly.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by specifying that it accepts input from 'group-text-by-json tool', suggesting a sequential workflow. However, it lacks explicit guidance on when to use this tool versus alternatives (e.g., direct JSON creation tools) or any prerequisites beyond having the grouped text. No exclusions or clear when-not-to-use scenarios are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 2 tool updatesv1.0.0
    • First observedgroup-text-by-json
    • First observedtext-to-json

TDQS

B3/5.0

Scored across 2 tools

Disambiguation5/5

The two tools have clearly distinct purposes: group-text-by-json prepares text for grouping based on a JSON template, while text-to-json converts that grouped text into JSON. There is no overlap or ambiguity between them, as they represent sequential steps in a workflow.

Naming Consistency5/5

Both tools follow a consistent verb-noun pattern with hyphens (group-text-by-json and text-to-json), clearly indicating their actions and targets. The naming is predictable and readable across the set.

Tool Count2/5

With only 2 tools, the server feels thin for its apparent purpose of custom context management. This minimal set may limit functionality and require agents to work around gaps, as typical context-related operations might include more than just grouping and conversion.

Completeness2/5

The tool surface is severely incomplete for a custom context server. It lacks core operations such as creating, updating, deleting, or retrieving context entries, and only covers a narrow text-to-JSON conversion workflow, leaving significant gaps that will likely cause agent failures.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    C
    quality
    F
    maintenance
    A Model Context Protocol server implementation that enables LLMs to query and manipulate JSON data using JSONPath syntax with extended operations for filtering, sorting, transforming, and aggregating data.
    2
    36 npm
    90
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    A Model Context Protocol server for querying large JSON files using JSONPath expressions, enabling LLMs to efficiently search and extract information from large JSON data.
    3
    11
    -
  • -
    license
    B
    quality
    Not graded
    maintenance
    A Model Context Protocol server that enables AI models to extract structured data from websites through the extract\_structured\_data tool.
    1
    21 npm
    -