omer ayhan custom context mcp

omer ayhan custom context mcp avatar

by omer-ayhan

This Model Context Protocol (MCP) server provides tools for structuring and extracting data from text according to JSON templates.

What is omer ayhan custom context mcp

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.

Leave a Comment

Frequently Asked Questions

What is MCP?

MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.

What are MCP Servers?

MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.

How do MCP Servers work?

MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.

Are MCP Servers secure?

Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.

Related MCP Servers

chrisdoc hevy mcp avatar

chrisdoc hevy mcp

mcp
sylphlab pdf reader mcp avatar

sylphlab pdf reader mcp

An MCP server built with Node.js/TypeScript that allows AI agents to securely read PDF files (local or URL) and extract text, metadata, or page counts. Uses pdf-parse.

pdf-parsetypescriptnodejs
aashari mcp server atlassian bitbucket avatar

aashari mcp server atlassian bitbucket

Node.js/TypeScript MCP server for Atlassian Bitbucket. Enables AI systems (LLMs) to interact with workspaces, repositories, and pull requests via tools (list, get, comment, search). Connects AI directly to version control workflows through the standard MCP interface.

atlassianrepositorymcp
aashari mcp server atlassian confluence avatar

aashari mcp server atlassian confluence

Node.js/TypeScript MCP server for Atlassian Confluence. Provides tools enabling AI systems (LLMs) to list/get spaces & pages (content formatted as Markdown) and search via CQL. Connects AI seamlessly to Confluence knowledge bases using the standard MCP interface.

atlassianmcpconfluence
prisma prisma avatar

prisma prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB

cockroachdbgomcp
Zzzccs123 mcp sentry avatar

Zzzccs123 mcp sentry

mcp sentry for typescript sdk

mcptypescript
zhuzhoulin dify mcp server avatar

zhuzhoulin dify mcp server

mcp
zhongmingyuan mcp my mac avatar

zhongmingyuan mcp my mac

mcp
zhixiaoqiang desktop image manager mcp avatar

zhixiaoqiang desktop image manager mcp

MCP 服务器,用于管理桌面图片、查看详情、压缩、移动等(完全让Trae实现)

mcp
zhixiaoqiang antd components mcp avatar

zhixiaoqiang antd components mcp

An MCP service for Ant Design components query | 一个减少 Ant Design 组件代码生成幻觉的 MCP 服务,包含系统提示词、组件文档、API 文档、代码示例和更新日志查询

designantdapi

Submit Your MCP Server

Share your MCP server with the community

Submit Now