Skip to main content
Glama
web-algebra-mcp

web-algebra-mcp

Official
by AtomGraph

Replace

Substitutes regular-expression matches in a string with a replacement value, supporting capture-group references and preserving the input literal's datatype or language tag.

Instructions

Replaces occurrences of a regular-expression pattern in an input string, per SPARQL's REPLACE() / XPath fn:replace. The replacement string may reference capture groups as $1, $2, ...; flags s, m, i, x, q are supported. The result is a string literal of the same kind (datatype/language tag) as the input.

    Note: this function should not be used to build URIs! That should be done using EncodeForURI()/ResolveURI().
    

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "input": "<input>",
      "pattern": "<pattern>",
      "replacement": "<replacement>"
    },
    "name": "Replace"
  }
}

Input Schema

NameRequiredDescriptionDefault
flagsNoOptional XPath regex flags: any of s, m, i, x, q
inputYesThe input string to process
patternYesThe regular expression to be replaced (XPath fn:replace syntax)
replacementYesThe replacement string; $1, $2, ... reference capture groups

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.4

TDQS

A4.1/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 burden and does well: it discloses capture-group replacement syntax, the supported flag set, and the result type (same datatype/language tag as input). It omits error behavior for invalid regex patterns or non-matching input, which is the main remaining gap for a regex tool.

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?

Front-loaded with the core behavior in the first clause, then supporting details, then a caveat. Slight redundancy in re-listing the flags that the schema enum-free description already enumerates, but nothing is wasted.

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?

For a pure string-transformation function with 3 required parameters, the definition covers semantics, flags, capture groups, and return typing, which substitutes for the absent output schema. Only failure-mode behavior on malformed regex is missing, a minor omission for this complexity level.

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 all four parameters are already documented in the schema. The description only restates the capture-group syntax and flag list that the schema already contains, adding no new meaning beyond it. Baseline 3 applies.

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?

States a specific verb and resource ('Replaces occurrences of a regular-expression pattern in an input string') and anchors it to a well-known standard (SPARQL REPLACE() / XPath fn:replace), so an agent knows exact semantics without guessing. The closing note explicitly separates it from EncodeForURI/ResolveURI, making it distinguishable from URI-building siblings.

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

Usage Guidelines4/5

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

Gives a clear negative rule ('should not be used to build URIs') and names the two alternatives for that case, which is strong routing guidance. However, it never addresses when to pick this over the closely related Substitute sibling, so the most likely confusion point is left unaddressed.

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