Skip to main content
Glama

code.apply_patch

Apply a unified diff to modify code, validating that all touched paths remain within the allowed workspace and are not forbidden.

Instructions

[approval required][workspace write][risk:dangerous] Apply a unified diff after validating all touched paths stay inside workspaceRoot and are not forbidden.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patchYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0-alpha.14

TDQS

A3.9/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full behavioral burden and it does so well: it discloses approval requirement, workspace-write mutation, dangerous risk, and the path-validation rule before touching any files. It falls just short of full transparency because it doesn't describe what happens on validation failure, partial application, or how to revert the change.

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 a single compact sentence with the safety badges front-loaded before the operative verb. Every phrase carries operational value and there is no repeated schema information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple one-parameter tool, the description covers the core operation, input type, and safety constraints. It is less complete because there is no output schema and the description does not indicate what the tool returns on success or error, nor does it specify the patch format beyond 'unified diff'; an agent may still have to discover those details.

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?

Schema coverage is 0%, so the description must add meaning. It adds that the patch must be a unified diff and that touched paths are restricted, but it gives no formatting details, path-root conventions, or example of the expected patch syntax. For a single required string, this is adequate but leaves room for ambiguity.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names a specific operation (Apply a unified diff) and a distinct resource/scope (workspace files after path validation), which clearly separates it from sibling read/search/diff/commit tools. This is more than a tautology and lets an agent select it immediately.

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 verb 'Apply' plus 'unified diff' makes the use case inferable: use this when you have a patch to apply to code in the workspace. However, it never states when not to use it or names alternatives such as code.commit_changes for committing, so the guidance is implied rather than explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools