Skip to main content
Glama
perforce

Perforce P4 MCP Server

Official
by perforce

query_files

Read Perforce file data: fetch content, history, metadata, diffs, annotations, or search by name and grep by content. Use read-only queries without modifying depot state.

Instructions

Get file content, history, info, diff, annotations, search by name, grep by content (READ permission)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
diff2NoUse p4 diff2 for depot-to-depot diff, false for mixed diff
file2NoSecond file path - required for diff action
actionYesFile query action, metadata includes extra information like optional attributes and file size
rangesNoOptional line ranges for the content action only. Each inner list is a [start, end] pair, 1-based inclusive. When set, the response carries a 'chunks' array with one entry per range instead of the whole file.
patternNoSearch or grep pattern - required for search and grep actions
file_pathYesPrimary file path - required for all actions
max_resultsNoMaximum number of results to return. Bounds history/search/grep and also caps fstat info/metadata via 'p4 fstat -m N'. Omit for unbounded info/metadata results.
case_insensitiveNoCase-insensitive matching for grep action

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2026.4.3078076
    • addedInput schema / properties / ranges
      Added value: +{
      +  "anyOf": [
      +    {
      +      "items": {
      +        "items": {
      +          "type": "integer"
      +        },
      +        "type": "array"
      +      },
      +      "type": "array"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Optional line ranges for the content action only. Each inner list is a [start, end] pair, 1-based inclusive. When set, the response carries a 'chunks' array with one entry per range instead of the whole file.",
      +  "examples": [
      +    [
      +      [
      +        10,
      +        20
      +      ],
      +      [
      +        50,
      +        60
      +      ]
      +    ]
      +  ]
      +}
  2. First observedv2026.3.2996147

TDQS

B3.4/5.0
Behavior3/5

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

With no annotations, the description carries the full behavioral burden. It does add one genuine behavioral fact — the READ permission requirement — which tells the agent this is a safe non-mutating call. However, it says nothing about error behavior, pagination, or the fact that ranges/max_results change the response shape, leaving gaps for an 8-parameter tool.

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?

A single dense sentence with zero filler, front-loading the verb and resource before enumerating modes and the permission constraint. Nothing could be cut without losing information.

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

Completeness4/5

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

An output schema exists, so return values need not be described, and the schema fully documents parameters. What remains thin is behavioral context around the multi-action dispatch and permission/error semantics, but for a read-only query tool this is close to sufficient.

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 description coverage is 100%, so every parameter is already documented in the schema, including the ranges/chunks behavior and max_results capping. The description adds no parameter-level detail beyond the action names, so the baseline 3 is appropriate.

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?

States a specific verb ('Get') plus the resource ('file') and enumerates the eight actions the tool supports, matching the action enum exactly. The '(READ permission)' tag implicitly separates it from the modify_* siblings, though it never names them. An agent can tell what this tool does without opening the schema.

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 lists what the actions are but gives no when-to-use guidance, no prerequisites, and no explicit routing away from siblings like modify_files or query_changelists. A reader can infer that 'search by name' vs 'grep by content' are different modes, but nothing states which to pick or under what conditions.

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