Skip to main content
Glama
omer-ayhan

Custom Context MCP Server

by omer-ayhan

group-text-by-json

Structure text into JSON format using predefined templates with placeholders. Ideal for transforming unstructured input into organized, structured data for processing and analysis.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateYesJSON template with placeholders

Implementation Reference

  • The core implementation of the 'group-text-by-json' tool handler. Parses the JSON template to extract keys and generates a structured prompt for an AI to group subsequent text input based on those keys.
    const groupTextByJsonTool = (template: string) => {
    	if (!template) {
    		throw new Error("Both template and text are required");
    	}
    
    	try {
    		logger.info("Template:", template);
    
    		let objectKeys: string[] = [];
    
    		try {
    			const templateObj = JSON.parse(template);
    			objectKeys = deepObjectKeys(templateObj, true);
    		} catch (parseError) {
    			logger.error("Failed to parse template:", parseError);
    			throw new Error(`Invalid template format: ${parseError}`);
    		}
    
    		const resultPrompt = `
            You are a helpful assistant that groups text based on JSON keys.
            Here are the keys in the template: ${objectKeys.join(", ")}.
            Please group the text based on the keys. and give me the result in raw text.
            Don't give it in JSON format or object format. It should be in the following format:
    
            Format:
            <key>: <corresponding text found in the text>
    
            Here's an example:
    
            sentence: The MacBook Pro costs $2,499.
    
            result:
            brand: MacBook
            price: $2,499
            description: The MacBook Pro is a powerful laptop with a Retina display.
            
            `;
    
    		return {
    			content: [
    				{
    					type: "text",
    					text: resultPrompt,
    				},
    			],
    		};
    	} catch (error) {
    		logger.error("Error processing template:", error);
    		throw new Error(`Failed to process template: ${error}`);
    	}
    };
  • Zod schema defining the input for the 'group-text-by-json' tool: a JSON template string.
    const GroupTextByJsonSchema = z.object({
    	template: z.string().describe("JSON template with placeholders"),
    });
  • src/index.ts:39-44 (registration)
    Registration of the tool in the ListToolsRequestHandler, including name, description, and input schema.
    {
    	name: TOOL_NAMES.groupTextByJson,
    	description:
    		"Gives a prompt text for AI to group text based on JSON placeholders. This tool accepts a JSON template with placeholders.",
    	inputSchema: zodToJsonSchema(GroupTextByJsonSchema),
    },
  • src/index.ts:66-68 (registration)
    Dispatch/execution point in the CallToolRequestHandler switch statement that invokes the handler function.
    case TOOL_NAMES.groupTextByJson:
    	const groupTextByJsonArgs = args as GroupTextByJsonSchemaType;
    	return groupTextByJsonTool(groupTextByJsonArgs.template);
  • Constant mapping for the tool name used in registration and dispatching.
    groupTextByJson: "group-text-by-json",
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.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/omer-ayhan/custom-context-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server