Skip to main content
Glama
TMYTiMidlY

portal-mcp-server

by TMYTiMidlY

portal_patch

Apply patches to a remote file with hash-based conflict detection, preventing overwrites when the file changes concurrently.

Instructions

Apply patches to a remote file with hash-based conflict detection.

Workflow:

  1. Call portal_read to obtain content + file_hash + range_hash for each region.

  2. Call portal_patch with the SAME file_hash and per-patch range_hash.

  3. If the file was modified by anyone else in between, this call returns {"result": "error", "reason": "Content hash mismatch ...", "current_file_hash": ...} — re-read and try again. The remote file is untouched.

patches_json must decode to a list of patch objects: [{"start": int, "end": int|null, "contents": str, "range_hash": str}, ...]

Notes:

  • Patches are applied bottom-to-top so line numbers stay valid.

  • Overlapping patches are rejected.

  • Writes are atomic (tmp file + rename) and re-hashed after write.

  • When auto_newline is true, missing trailing newlines on patch contents are auto-appended only if the slice they replace ended with one. The result includes a "warnings" list either way.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYes
pathYes
encodingNoutf-8
file_hashYes
auto_newlineNo
patches_jsonYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

With no annotations, the description fully discloses behavioral traits: hash-based conflict detection, atomic writes via tmp+rename, bottom-to-top patch application, rejection of overlapping patches, auto_newline behavior, and error return format.

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 well-structured with workflow, parameter format, and notes. It is front-loaded with the main purpose. While a bit long, every sentence adds value, and the structure aids comprehension.

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

Completeness5/5

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

Given the tool's complexity (6 parameters, conflict detection, multiple steps), the description covers conflict detection workflow, atomic writes, error handling, patch format, and auto_newline behavior. The existence of an output schema likely covers return values, so no gap.

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

Parameters4/5

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

Although schema coverage is 0%, the description adds significant meaning for key parameters: it details the format of patches_json as a list of objects with start, end, contents, range_hash. It also explains file_hash and auto_newline. Host and path are not elaborated but are self-explanatory in context.

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?

Description clearly states the tool's purpose: 'Apply patches to a remote file with hash-based conflict detection.' It uses a specific verb ('Apply patches') and resource ('remote file'), and the workflow distinguishes it from sibling tools like portal_read and portal_exec.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit workflow steps (1. portal_read, 2. portal_patch) and error handling guidance. It explains when to use (for atomic patching with conflict detection) and implicitly when not to (if file modified by others).

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

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/TMYTiMidlY/portal-mcp-server'

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