MCP · diff_text
Diff text
Computes a deterministic line- or word-level diff and returns typed add/remove/equal parts. Use this when an agent needs structured change data. Split highly divergent large documents if the computation limit is reached. Limit: 200k combined characters, 2,000 result parts, 8 ms diff budget.
When to use it
Computes a deterministic line- or word-level diff and returns typed add/remove/equal parts. Use this when an agent needs structured change data. Split highly divergent large documents if the computation limit is reached.
Input schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"before": {
"type": "string",
"maxLength": 200000
},
"after": {
"type": "string",
"maxLength": 200000
},
"granularity": {
"default": "lines",
"type": "string",
"enum": [
"lines",
"words"
]
},
"ignore_whitespace": {
"default": false,
"type": "boolean"
}
},
"required": [
"before",
"after",
"granularity",
"ignore_whitespace"
],
"additionalProperties": false
}Output schema
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"ok": {
"const": true
},
"data": {
"type": "object",
"properties": {
"equal": {
"type": "boolean"
},
"granularity": {
"enum": [
"lines",
"words"
]
},
"parts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"operation": {
"enum": [
"add",
"remove",
"equal"
]
},
"value": {
"type": "string"
},
"count": {
"type": "integer"
}
},
"required": [
"operation",
"value",
"count"
]
}
},
"truncated": {
"type": "boolean"
},
"before_chars": {
"type": "integer"
},
"after_chars": {
"type": "integer"
}
},
"required": [
"equal",
"granularity",
"parts",
"truncated",
"before_chars",
"after_chars"
]
},
"meta": {
"type": "object",
"properties": {
"request_id": {
"type": "string"
},
"duration_ms": {
"type": "integer"
},
"limits": {
"type": "object"
}
},
"required": [
"request_id",
"duration_ms"
]
}
},
"required": [
"ok",
"data",
"meta"
],
"additionalProperties": false
}REST example
curl -X POST https://plainport.exportitnow.workers.dev/api/v1/diff-text \
-H "content-type: application/json" \
-d '{"before":"alpha\nbeta","after":"alpha\ngamma"}'Example result
{
"ok": true,
"data": {
"equal": false,
"granularity": "lines",
"parts": [
{
"operation": "remove",
"value": "beta",
"count": 1
},
{
"operation": "add",
"value": "gamma",
"count": 1
}
]
},
"meta": {
"request_id": "018f…",
"duration_ms": 12
}
}Limit
200k combined characters, 2,000 result parts, 8 ms diff budget