Skip to main content

grep_resource

Search inside a single text resource and get back the matching lines with their line numbers — instead of reading the whole resource. This is the read counterpart to patch_resource: a large resource stays cheap to search, and the result points you straight at the lines you care about. Address it by its path — set team for a team resource.

With a credential that represents a user, omitting team targets that user's space. A userless organization credential must name a team it is bound to.

Only text resources can be searched. A binary resource (an image, a PDF, an archive) is rejected.

query is a literal substring by default. Set regex to treat it as a regular expression instead, and ignore_case to match regardless of case.

Parameters​

ParameterTypeRequiredDescription
pathstringYesThe resource to search, addressed by its path.
teamstringNoThe team that owns it. Omit to target the represented user's space.
querystringYesWhat to search for — a literal substring, or a regex if regex is set.
regexbooleanNoTreat query as a regular expression instead of a literal substring.
ignore_casebooleanNoMatch case-insensitively (default: case-sensitive).

Response​

FieldTypeDescription
pathstringThe resource path.
matchesarrayThe matching lines (see below), in order.
truncatedbooleantrue if there were more matches than the result cap.
versionintegerThe resource's current version — pass as expected_version to a guarded edit.

Each entry in matches:

FieldTypeDescription
lineintegerThe 1-based line number.
textstringThe matching line (very long lines are shortened).

Example​

{
"path": "docs/api.md",
"query": "version",
"ignore_case": true
}

Result:

{
"path": "docs/api.md",
"matches": [
{ "line": 12, "text": "version: 1.2.0" },
{ "line": 40, "text": "Version history" }
],
"truncated": false,
"version": 1
}

Errors​

Each failure carries a precise code in the response. A domain rejection — a not-found, a bad query, or a capability denial — is returned as a tool result with isError: true, so the agent can read the code and self-correct; malformed arguments and server faults are JSON-RPC protocol errors.

CodeCauseDelivered as
resource_not_foundNo matching resource is visible to you — it doesn't exist, is disabled, or is out of scope.tool error (isError)
not_a_text_resourceThe resource is not a text type.tool error (isError)
empty_queryquery is empty.tool error (isError)
invalid_regexregex is set but the pattern doesn't compile.tool error (isError)
team_not_foundNo team with that name is bound to this credential.tool error (isError)
capability_deniedThe credential lacks the Resources capability required for this read.tool error (isError)
personal_cannot_address_teamYou used a team/ prefix (or team field) with a personal credential.tool error (isError)
no_personal_spaceThis credential has no personal space — address a team instead.tool error (isError)
resource_not_utf8The resource is text but its stored bytes aren't valid UTF-8 — read it in the dashboard.tool error (isError)
invalid_argumentsThe arguments are missing or don't match the input schema.protocol error (invalid_params)
internal_errorAn unexpected error occurred.protocol error (internal_error)

Notes​

  • Matches and version come from the same revision. If a concurrent update or deletion makes that revision unavailable during the read, the call can fail with internal_error; search again before editing.
  • You can search any resource you can read — there is no separate permission. A resource you can't see (it's disabled or out of your scope) simply reads as not found.
  • The result is capped at a fixed number of matching lines; truncated tells you when more matched than were returned. Narrow your query to see the rest.
  • Use the returned line numbers directly with patch_resource to edit what you found.
  • Searching a resource counts as one tool call against your plan's tool-invocation allowance.