Skip to main content
Glama
tatn

MCP Server Diff TypeScript

by tatn

get-unified-diff

Generate unified diff format to compare and analyze differences between two text strings for clear text comparison insights.

Instructions

Get the difference between two text articles in Unified diff format.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
newStringYesnew string to compare
oldStringYesold string to compare

Implementation Reference

  • Handler for the 'get-unified-diff' tool: extracts oldString and newString arguments, validates them, calls generateUnifiedDiff helper, and returns the diff result as text content.
    case "get-unified-diff": { const oldString = String(request.params.arguments?.oldString); const newString = String(request.params.arguments?.newString); if (!oldString || !newString) { throw new Error("oldString and newString are required"); } const diffResult = generateUnifiedDiff(oldString, newString, "", "", ""); return { content: [{ type: "text", text: diffResult }] }; }
  • Input schema definition for the 'get-unified-diff' tool, specifying oldString and newString as required string properties.
    inputSchema: { type: "object", properties: { oldString: { type: "string", description: "old string to compare" }, newString: { type: "string", description: "new string to compare" } }, required: ["oldString", "newString"] }
  • src/index.ts:35-52 (registration)
    Registration of the 'get-unified-diff' tool in the ListTools response, including name, description, and input schema.
    { name: "get-unified-diff", description: "Get the difference between two text articles in Unified diff format.", inputSchema: { type: "object", properties: { oldString: { type: "string", description: "old string to compare" }, newString: { type: "string", description: "new string to compare" } }, required: ["oldString", "newString"] } }
  • Helper function that generates the unified diff using the 'diff' library's diffLines and createPatch functions.
    export function generateUnifiedDiff(oldString: string, newString: string, oldHeader: string = '', newHeader: string = '', fileName: string = ''): string { const diff = diffLines(oldString, newString); if (diff.length === 1 && !diff[0].added && !diff[0].removed) { return ''; // No change detected } return createPatch(fileName, oldString, newString, oldHeader, newHeader, { context: 3 }); }

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/tatn/mcp-server-diff-typescript'

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