Skip to main content
Glama

TextClean MCP

Text cleanup and destination formatting

clean_text

Clean supplied text deterministically without rewriting its meaning. Use for copied PDF text, Markdown/HTML artifacts, citations, spacing, or destination formatting; not OCR, file uploads, grammar correction, or AI-authorship detection. Preserves supported document structure unless a selected cleanup removes it. Returns cleanedText, destination-rendered text, optional html, a changes list, and usage counters as structured JSON and matching JSON text. No API key required. 20 calls per UTC day per network address; shared networks share this allowance. Service-wide load protection can return HTTP 429; honor Retry-After. Maximum 20000 UTF-16 code units per call. Accepted processing attempts consume quota, including repeats. Input and results are processed remotely in memory, not stored or logged; only quota metadata is retained. Validation and quota failures return errors. Example: {"text":"A split para-\ngraph.","preset":"pdf","destination":"email"}.

Input Schema

NameRequiredDescriptionDefault
textYesRequired nonblank source text, not a URL or file path. Length is measured in UTF-16 code units. Send only text you intend this remote service to process.
presetNoCleaning preset, default default: trim, collapse repeated spaces/blank lines, NFC Unicode. pdf also repairs hard wraps/hyphens and removes detected page numbers/edges. ai strips Markdown artifacts, not AI authorship. html removes HTML tags/scripts/styles and decodes entities. list removes blank/duplicate lines and sorts lines. Explicit flags override preset settings.
destinationNoOutput rendering, default preserve. preserve retains heading/quote markers and inline Markdown in text; other modes remove those markers, with bullet/numbered lists retained. email wraps HTML in a div; blog in an article; message and document return unwrapped semantic HTML; plain omits HTML. Does not change cleaning options.
stripMarkdownNoOverride Markdown artifact removal, including headings/list markers, emphasis, link markup, and code fences. Omit to use the preset: true for ai, false otherwise. May remove structure; false does not disable destination rendering of Markdown.
removeCitationsNoRemove recognized numbered brackets, footnote markers, and compact author-year citations. Default false for every preset. May remove meaningful references; enable only when requested.
replaceLongDashesNoReplace em/en dashes with the selected punctuation or space. Default preserve. Replacement normalizes surrounding whitespace and may join adjacent line breaks.

Output Schema

NameRequiredDescriptionDefault
htmlNoRendered semantic HTML. Omitted for plain destination.
textYesDestination-rendered text suitable for copying.
usageYesAggregate quota counters only; contains no API key or network address.
changesYesApplied transformations; empty when no cleanup changed the source.
cleanedTextYesText after selected cleanup, before destination rendering.
destinationYesSelected rendering destination.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changed
    • addedInput schema / properties / destination / description
      Added value: +"Output rendering, default preserve. preserve retains heading/quote markers and inline Markdown in text; other modes remove those markers, with bullet/numbered lists retained. email wraps HTML in a div; blog in an article; message and document return unwrapped semantic HTML; plain omits HTML. Does not change cleaning options."
    • addedInput schema / properties / preset / description
      Added value: +"Cleaning preset, default default: trim, collapse repeated spaces/blank lines, NFC Unicode. pdf also repairs hard wraps/hyphens and removes detected page numbers/edges. ai strips Markdown artifacts, not AI authorship. html removes HTML tags/scripts/styles and decodes entities. list removes blank/duplicate lines and sorts lines. Explicit flags override preset settings."
    • addedInput schema / properties / removeCitations / description
      Added value: +"Remove recognized numbered brackets, footnote markers, and compact author-year citations. Default false for every preset. May remove meaningful references; enable only when requested."
    • addedInput schema / properties / replaceLongDashes / description
      Added value: +"Replace em/en dashes with the selected punctuation or space. Default preserve. Replacement normalizes surrounding whitespace and may join adjacent line breaks."
    • addedInput schema / properties / stripMarkdown / description
      Added value: +"Override Markdown artifact removal, including headings/list markers, emphasis, link markup, and code fences. Omit to use the preset: true for ai, false otherwise. May remove structure; false does not disable destination rendering of Markdown."
    • addedInput schema / properties / text / description
      Added value: +"Required nonblank source text, not a URL or file path. Length is measured in UTF-16 code units. Send only text you intend this remote service to process."
    • addedInput schema / properties / text / pattern
      Added value: +"\\S"
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "https://json-schema.org/draft/2020-12/schema",
      +  "additionalProperties": false,
      +  "properties": {
      +    "changes": {
      +      "description": "Applied transformations; empty when no cleanup changed the source.",
      +      "items": {
      +        "additionalProperties": false,
      +        "properties": {
      +          "count": {
      +            "description": "Number of changes reported for this transformation.",
      +            "type": "number"
      +          },
      +          "label": {
      +            "description": "Human-readable transformation name.",
      +            "type": "string"
      +          }
      +        },
      +        "required": [
      +          "label",
      +          "count"
      +        ],
      +        "type": "object"
      +      },
      +      "type": "array"
      +    },
      +    "cleanedText": {
      +      "description": "Text after selected cleanup, before destination rendering.",
      +      "type": "string"
      +    },
      +    "destination": {
      +      "description": "Selected rendering destination.",
      +      "enum": [
      +        "preserve",
      +        "email",
      +        "message",
      +        "blog",
      +        "document",
      +        "plain"
      +      ],
      +      "type": "string"
      +    },
      +    "html": {
      +      "description": "Rendered semantic HTML. Omitted for plain destination.",
      +      "type": "string"
      +    },
      +    "text": {
      +      "description": "Destination-rendered text suitable for copying.",
      +      "type": "string"
      +    },
      +    "usage": {
      +      "additionalProperties": false,
      +      "description": "Aggregate quota counters only; contains no API key or network address.",
      +      "properties": {
      +        "calls": {
      +          "description": "Calls consumed in the current allowance window, including this call.",
      +          "maximum": 9007199254740991,
      +          "minimum": 0,
      +          "type": "integer"
      +        },
      +        "plan": {
      +          "const": "free",
      +          "description": "Present as free on the anonymous endpoint; omitted on the Pro endpoint.",
      +          "type": "string"
      +        },
      +        "remaining": {
      +          "description": "Calls remaining in the current allowance window.",
      +          "maximum": 9007199254740991,
      +          "minimum": 0,
      +          "type": "integer"
      +        }
      +      },
      +      "required": [
      +        "calls",
      +        "remaining"
      +      ],
      +      "type": "object"
      +    }
      +  },
      +  "required": [
      +    "destination",
      +    "cleanedText",
      +    "text",
      +    "changes",
      +    "usage"
      +  ],
      +  "type": "object"
      +}
  2. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Goes well beyond the sparse annotations: 20 calls/UTC day per network address with shared allowance, HTTP 429 with Retry-After, 20000 UTF-16 code unit cap, quota consumed on accepted attempts including repeats, remote in-memory processing with no storage/logging, and error behavior on validation/quota failures. This is exactly the operational context an agent needs before invoking a quota-metered remote service.

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?

Front-loaded with purpose and scope, then constraints and limits, then a concrete call example. Despite its length, almost every sentence carries distinct information (limits, quota, privacy, error modes) rather than restating the schema or title.

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?

An output schema exists so return values need not be enumerated, yet the description still summarizes the return shape and adds the quota, size, privacy, and error context that structured fields do not cover. Nothing material for correct invocation is missing.

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 the enum semantics for preset, destination, stripMarkdown, removeCitations, and replaceLongDashes are already fully documented in the schema. The description reaches parity but adds little parameter-level meaning beyond the worked example, so the 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 ('Clean supplied text deterministically without rewriting its meaning') and immediately bounds the domain with a use/do-not-use list. There are no sibling tools, but the description still distinguishes the tool sharply from adjacent operations (OCR, grammar correction, AI detection).

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?

Explicit positive cases ('copied PDF text, Markdown/HTML artifacts, citations, spacing, or destination formatting') and explicit exclusions ('not OCR, file uploads, grammar correction, or AI-authorship detection'). Nothing about when to reach for this tool is left to inference.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources