Skip to main content
Glama
tatn

MCP Server Diff Python

by tatn

get-unified-diff

Extract differences between two text inputs and generate a Unified diff format output. Compare article variations or textual changes efficiently.

Instructions

Get the difference between two text articles in Unified diff format. Use this when you want to extract the difference between texts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
string_aYes
string_bYes

Implementation Reference

  • The @server.call_tool() handler that executes the get-unified-diff tool by generating a unified diff between two input strings using difflib.unified_diff.
    @server.call_tool()
    async def handle_call_tool(
        name: str, arguments: dict | None
    ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
        """
        Handle tool execution requests.
        Tools can modify server state and notify clients of changes.
        """
        if name != "get-unified-diff":
            raise ValueError(f"Unknown tool: {name}")
    
        if not arguments:
            raise ValueError("Missing arguments")
    
        string_a: str = arguments.get("string_a")
        string_b: str = arguments.get("string_b")
    
        if string_a is None or string_b is None:
            raise ValueError("Missing 'string_a' or 'string_b' in arguments")
    
        diff_iterator = difflib.unified_diff(string_a.splitlines(), string_b.splitlines())
    
        return [types.TextContent(type="text", text="\n".join(diff_iterator))]
  • JSON schema defining the required input parameters 'string_a' and 'string_b' for the get-unified-diff tool.
    inputSchema={
        "type": "object",
        "properties": {
            "string_a": {"type": "string"},
            "string_b": {"type": "string"},
        },
        "required": ["string_a", "string_b"],
    },
  • @server.list_tools() decorator registers the get-unified-diff tool including its name, description, and input schema.
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        """
        List available tools.
        Each tool specifies its arguments using JSON Schema validation.
        """
        return [
            types.Tool(
                name="get-unified-diff",
                description="Get the difference between two text articles in Unified diff format. Use this when you want to extract the difference between texts.",  # noqa: E501
                inputSchema={
                    "type": "object",
                    "properties": {
                        "string_a": {"type": "string"},
                        "string_b": {"type": "string"},
                    },
                    "required": ["string_a", "string_b"],
                },
            )
        ]
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 output format ('Unified diff format') but fails to describe critical behaviors such as error handling, performance characteristics, or any side effects. For a tool with two inputs and no annotation coverage, this leaves significant gaps in understanding how it operates beyond its basic function.

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

Conciseness5/5

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

The description is highly concise and well-structured, consisting of two sentences that efficiently state the tool's purpose and usage context without any redundant information. Every sentence earns its place, making it easy to parse and understand quickly.

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 tool's complexity (comparing two texts) and the lack of annotations, output schema, and parameter descriptions, the description is incomplete. It does not explain what the Unified diff format entails, how differences are computed, or what the return values look like. This leaves too many unknowns for effective tool selection and invocation.

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

Parameters2/5

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

Schema description coverage is 0%, meaning the input schema provides no descriptions for 'string_a' and 'string_b'. The description does not add any semantic details about these parameters, such as what they represent (e.g., original vs. modified text) or any constraints. This lack of compensation for the schema gap results in a low score, as users must guess parameter meanings.

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: 'Get the difference between two text articles in Unified diff format.' It specifies the verb ('Get'), resource ('difference'), and output format ('Unified diff format'), which is specific and actionable. However, since there are no sibling tools, the description cannot demonstrate differentiation from alternatives, preventing a perfect score.

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 provides some guidance with 'Use this when you want to extract the difference between texts,' which implies the context for usage. However, it lacks explicit when-not-to-use scenarios or comparisons to alternatives (though none exist here). This makes it adequate but not comprehensive, fitting a baseline score.

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

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