Skip to main content
Glama
Custom Context MCP Server

Custom Context MCP Server

by omer-ayhan

사용자 정의 컨텍스트 MCP 서버

이 모델 컨텍스트 프로토콜(MCP) 서버는 JSON 템플릿에 따라 텍스트에서 데이터를 구조화하고 추출하기 위한 도구를 제공합니다.

특징

텍스트-JSON 변환

  • 자리 표시자를 사용하여 JSON 템플릿을 기반으로 텍스트 그룹화 및 구조화

  • AI가 생성한 텍스트에서 정보를 추출하여 구조화된 JSON 형식으로 변환

  • 중첩된 플레이스홀더를 사용한 임의의 JSON 구조 지원

  • 텍스트에서 키-값 쌍의 지능적 추출

  • 다운스트림 애플리케이션을 위한 구조화된 데이터로 프로세스 AI 출력

Related MCP server: Unstructured Document Processor MCP

시작하기

설치

지엑스피1

서버 실행

npm start

핫 리로딩을 통한 개발의 경우:

npm run dev:watch

용법

이 MCP 서버는 두 가지 주요 도구를 제공합니다.

1. JSON으로 텍스트 그룹화( group-text-by-json )

이 도구는 플레이스홀더가 포함된 JSON 템플릿을 사용하여 AI가 템플릿의 구조에 따라 텍스트를 그룹화하도록 프롬프트를 생성합니다.

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

이 도구는 템플릿을 분석하고, 플레이스홀더 키를 추출하고, AI가 키-값 형식으로 정보를 추출하도록 안내하는 프롬프트를 반환합니다.

2. 텍스트를 JSON으로( text-to-json )

이 도구는 이전 단계에서 그룹화된 텍스트 출력을 가져와 원래 템플릿을 기반으로 구조화된 JSON 개체로 변환합니다.

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

텍스트에서 키-값 쌍을 추출하고 템플릿에 따라 구조화합니다.

워크플로 예시

  1. 플레이스홀더를 사용하여 JSON 템플릿을 정의합니다.

    {
     "item": {
         "name": "<name>",
         "price": "<price>",
         "description": "<description>"
     }
    }
  2. group-text-by-json 사용하여 AI에 대한 프롬프트를 만듭니다.

    • 이 도구는 이름, 가격, 설명 등의 플레이스홀더 키를 식별합니다.

    • 이러한 키로 정보를 그룹화하도록 AI에 지시하는 프롬프트를 생성합니다.

  3. AI 모델에 프롬프트를 보내고 그룹화된 텍스트를 받습니다.

    name: Blue Pen
    price: $2.99
    description: A smooth-writing ballpoint pen with blue ink
  4. text-to-json 사용하여 그룹화된 텍스트를 JSON으로 변환합니다.

    • 결과: GXP8

템플릿 형식

템플릿에는 유효한 JSON 구조 내의 어느 곳에나 플레이스홀더가 포함될 수 있습니다.

  • 자리 표시자를 정의하려면 꺾쇠괄호를 사용합니다: <name> , <type> , <price> 등.

  • 템플릿은 유효한 JSON 문자열이어야 합니다.

  • 플레이스홀더는 모든 중첩 수준에 있을 수 있습니다.

  • 복잡한 중첩 구조 지원

중첩된 플레이스홀더가 있는 템플릿 예:

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

구현 세부 사항

서버는 다음과 같이 작동합니다.

  1. JSON 템플릿을 분석하여 플레이스홀더 키 추출

  2. 이러한 키로 정보를 추출하도록 AI 모델을 안내하는 프롬프트 생성

  3. AI가 생성한 텍스트를 구문 분석하여 키-값 쌍 추출

  4. 원래 템플릿 구조를 기반으로 JSON 객체 재구성

개발

필수 조건

  • Node.js v18 이상

  • npm 또는 yarn

빌드하고 실행

# Install dependencies
npm install

# Build the project
npm run build

# Run the server
npm start

# Development with hot reloading
npm run dev:watch

맞춤형 핫 리로딩

이 프로젝트에는 다음이 결합된 맞춤형 핫 리로딩 설정이 포함되어 있습니다.

  • nodemon : src 디렉토리의 파일 변경 사항을 감시하고 TypeScript 파일을 다시 빌드합니다.

  • browser-sync : 빌드 파일이 변경되면 브라우저를 자동으로 새로 고칩니다.

  • 동시 실행 : 출력 동기화를 통해 두 서비스를 동시에 실행합니다.

설정은 다음과 같이 구성됩니다.

  • nodemon.json : TypeScript 감시 및 재구축을 제어합니다.

  • package.json : nodemon과 browser-sync를 동시에 실행하기 위해 사용합니다.

사용자 정의 핫 리로딩 기능을 사용하려면:

npm run dev:watch

이렇게 하면 다음과 같은 개발 환경이 생성됩니다.

  1. TypeScript 파일은 변경 시 자동으로 다시 빌드됩니다.

  2. MCP 서버가 업데이트된 코드로 다시 시작됩니다.

  3. 연결된 브라우저가 새로 고쳐져 최신 변경 사항이 표시됩니다.

MCP Inspector와 함께 사용

디버깅을 위해 MCP Inspector를 사용할 수 있습니다.

npm run dev

이는 요청과 응답의 시각적 디버깅을 위해 MCP Inspector로 서버를 실행합니다.

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.

Inputs: template (required).

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.

Inputs: template (required), text (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    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.

    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
      90
      MIT
    • A
      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
      MIT
    • -
      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
      23 npm
      -