cleanpastedtext-mcp 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +43 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +5 -0
- package/dist/server.d.ts +9 -0
- package/dist/server.js +119 -0
- package/package.json +44 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Issaaf Kattan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# cleanpastedtext-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A local [MCP](https://modelcontextprotocol.io) server that lets AI agents find and remove hidden Unicode characters, odd spaces and AI-style typography in text. Built on the [`cleanpastedtext`](https://www.npmjs.com/package/cleanpastedtext) engine behind [cleanpastedtext.com](https://cleanpastedtext.com).
|
|
4
|
+
|
|
5
|
+
It runs on your machine over stdio. Text is never written to disk, logged or sent over the network.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | What it does |
|
|
10
|
+
| --- | --- |
|
|
11
|
+
| `inspect_text` | Reports hidden characters and typography a preset would change, by name, code point and count. Doesn't change the text. |
|
|
12
|
+
| `clean_text` | Returns the cleaned text plus the same report. |
|
|
13
|
+
| `list_presets` | Lists the presets, what each does, and the exact options it turns on. |
|
|
14
|
+
|
|
15
|
+
`inspect_text` and `clean_text` take `text`, an optional `preset` (`AI Clean` by default; also `Safe Clean`, `Keep Typography`, `Plain ASCII`, `Markdown to Text`, `Join Lines`) and optional `options` overrides. Set `removeJoinControls: false` for Persian, Hindi and other scripts that use ZWNJ/ZWJ inside words, or `normalizeTypography: false` to keep curly quotes and dashes. Inputs are limited to 1,000,000 characters.
|
|
16
|
+
|
|
17
|
+
## Set up
|
|
18
|
+
|
|
19
|
+
**Claude Code**
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
claude mcp add cleanpastedtext -- npx -y cleanpastedtext-mcp
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Claude Desktop** and other clients that use a JSON config:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"mcpServers": {
|
|
30
|
+
"cleanpastedtext": {
|
|
31
|
+
"command": "npx",
|
|
32
|
+
"args": ["-y", "cleanpastedtext-mcp"]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then ask, for example: "Check this draft for hidden characters before I paste it into our CMS."
|
|
39
|
+
|
|
40
|
+
## Limits
|
|
41
|
+
|
|
42
|
+
The tools find the characters their rules cover. A clean report doesn't prove who wrote a text, and statistical AI watermarks (patterns in word choice) can't be seen or removed by character cleaning. See the [methodology](https://cleanpastedtext.com/how-it-works).
|
|
43
|
+
|
|
44
|
+
MIT © Issaaf Kattan
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
export declare const VERSION = "0.1.0";
|
|
3
|
+
/** Inputs above this size are refused so one call cannot stall the host. */
|
|
4
|
+
export declare const MAX_INPUT_CHARS = 1000000;
|
|
5
|
+
/**
|
|
6
|
+
* Builds the MCP server. Every tool is a pure function of its input: nothing
|
|
7
|
+
* is written to disk, logged, or sent over the network.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createServer(): McpServer;
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { cleanText, DEFAULT_PRESET, PRESET_DESCRIPTIONS, PRESETS, } from "cleanpastedtext";
|
|
4
|
+
export const VERSION = "0.1.0";
|
|
5
|
+
/** Inputs above this size are refused so one call cannot stall the host. */
|
|
6
|
+
export const MAX_INPUT_CHARS = 1_000_000;
|
|
7
|
+
const PRESET_NAMES = Object.keys(PRESETS);
|
|
8
|
+
const presetList = PRESET_NAMES.map((name) => `- ${name}: ${PRESET_DESCRIPTIONS[name] ?? ""}`).join("\n");
|
|
9
|
+
const textInput = z
|
|
10
|
+
.string()
|
|
11
|
+
.max(MAX_INPUT_CHARS, `Text longer than ${MAX_INPUT_CHARS} characters is not accepted.`)
|
|
12
|
+
.describe("The text to check or clean, exactly as copied.");
|
|
13
|
+
const presetInput = z
|
|
14
|
+
.enum(PRESET_NAMES)
|
|
15
|
+
.optional()
|
|
16
|
+
.describe(`Cleaning preset. Defaults to "${DEFAULT_PRESET}".\n${presetList}`);
|
|
17
|
+
const optionsInput = z
|
|
18
|
+
.object({
|
|
19
|
+
normalizeUnicode: z.boolean(),
|
|
20
|
+
removeInvisibleChars: z.boolean(),
|
|
21
|
+
removeBiDi: z.boolean(),
|
|
22
|
+
normalizeWhitespace: z.boolean(),
|
|
23
|
+
normalizeTypography: z.boolean(),
|
|
24
|
+
plainAscii: z.boolean(),
|
|
25
|
+
removeTagChars: z.boolean(),
|
|
26
|
+
removeVariationSelectors: z.boolean(),
|
|
27
|
+
removeControlChars: z.boolean(),
|
|
28
|
+
normalizeSpaces: z.boolean(),
|
|
29
|
+
removeJoinControls: z.boolean(),
|
|
30
|
+
stripMarkdown: z.boolean(),
|
|
31
|
+
joinLines: z.boolean(),
|
|
32
|
+
})
|
|
33
|
+
.partial()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe("Overrides applied on top of the preset. Set removeJoinControls: false for Persian, Hindi and other scripts that use ZWNJ/ZWJ inside words; set normalizeTypography: false to keep curly quotes and dashes.");
|
|
36
|
+
const detectionOutput = z.object({
|
|
37
|
+
codepoint: z.string(),
|
|
38
|
+
name: z.string(),
|
|
39
|
+
count: z.number(),
|
|
40
|
+
category: z.string(),
|
|
41
|
+
action: z.enum(["removed", "replaced", "kept"]),
|
|
42
|
+
note: z.string().optional(),
|
|
43
|
+
});
|
|
44
|
+
function resolveOptions(preset, overrides) {
|
|
45
|
+
const name = preset ?? DEFAULT_PRESET;
|
|
46
|
+
return { name, options: { ...PRESETS[name], ...overrides } };
|
|
47
|
+
}
|
|
48
|
+
function summarize(detections) {
|
|
49
|
+
const changed = detections.filter((d) => d.action !== "kept");
|
|
50
|
+
if (changed.length === 0)
|
|
51
|
+
return "No supported hidden characters or other changes found.";
|
|
52
|
+
const total = changed.reduce((sum, d) => sum + d.count, 0);
|
|
53
|
+
const lines = changed.map((d) => `- ${d.name} (${d.codepoint}) ×${d.count}: ${d.action}`);
|
|
54
|
+
return `${total} change${total === 1 ? "" : "s"} across ${changed.length} character type${changed.length === 1 ? "" : "s"}:\n${lines.join("\n")}`;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Builds the MCP server. Every tool is a pure function of its input: nothing
|
|
58
|
+
* is written to disk, logged, or sent over the network.
|
|
59
|
+
*/
|
|
60
|
+
export function createServer() {
|
|
61
|
+
const server = new McpServer({ name: "cleanpastedtext", version: VERSION });
|
|
62
|
+
server.registerTool("inspect_text", {
|
|
63
|
+
title: "Inspect text for hidden characters",
|
|
64
|
+
description: "Report the hidden Unicode characters (zero-width spaces, BiDi controls, tag characters, variation selectors, odd spaces) and typography that a preset would change, by name, code point and count. Does not modify the text. A clean report means the supported checks found nothing; it is not proof of authorship or of the absence of statistical watermarks.",
|
|
65
|
+
inputSchema: { text: textInput, preset: presetInput, options: optionsInput },
|
|
66
|
+
outputSchema: { preset: z.string(), changeCount: z.number(), detections: z.array(detectionOutput) },
|
|
67
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
68
|
+
}, async ({ text, preset, options }) => {
|
|
69
|
+
const resolved = resolveOptions(preset, options);
|
|
70
|
+
const { detections } = cleanText(text, resolved.options);
|
|
71
|
+
const changeCount = detections.filter((d) => d.action !== "kept").reduce((sum, d) => sum + d.count, 0);
|
|
72
|
+
return {
|
|
73
|
+
content: [{ type: "text", text: summarize(detections) }],
|
|
74
|
+
structuredContent: { preset: resolved.name, changeCount, detections },
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
server.registerTool("clean_text", {
|
|
78
|
+
title: "Clean text",
|
|
79
|
+
description: "Remove hidden Unicode characters and normalize spaces, typography or Markdown according to a preset, and return the cleaned text with a report of every change. Deterministic rules; words are never rewritten.",
|
|
80
|
+
inputSchema: { text: textInput, preset: presetInput, options: optionsInput },
|
|
81
|
+
outputSchema: {
|
|
82
|
+
preset: z.string(),
|
|
83
|
+
cleanedText: z.string(),
|
|
84
|
+
changeCount: z.number(),
|
|
85
|
+
detections: z.array(detectionOutput),
|
|
86
|
+
},
|
|
87
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
88
|
+
}, async ({ text, preset, options }) => {
|
|
89
|
+
const resolved = resolveOptions(preset, options);
|
|
90
|
+
const { cleanedText, detections } = cleanText(text, resolved.options);
|
|
91
|
+
const changeCount = detections.filter((d) => d.action !== "kept").reduce((sum, d) => sum + d.count, 0);
|
|
92
|
+
return {
|
|
93
|
+
content: [
|
|
94
|
+
{ type: "text", text: cleanedText },
|
|
95
|
+
{ type: "text", text: summarize(detections) },
|
|
96
|
+
],
|
|
97
|
+
structuredContent: { preset: resolved.name, cleanedText, changeCount, detections },
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
server.registerTool("list_presets", {
|
|
101
|
+
title: "List cleaning presets",
|
|
102
|
+
description: "List the available cleaning presets with a description and the exact options each one turns on.",
|
|
103
|
+
outputSchema: {
|
|
104
|
+
presets: z.array(z.object({ name: z.string(), description: z.string(), options: z.record(z.string(), z.boolean()) })),
|
|
105
|
+
},
|
|
106
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
107
|
+
}, async () => {
|
|
108
|
+
const presets = PRESET_NAMES.map((name) => ({
|
|
109
|
+
name,
|
|
110
|
+
description: PRESET_DESCRIPTIONS[name] ?? "",
|
|
111
|
+
options: PRESETS[name],
|
|
112
|
+
}));
|
|
113
|
+
return {
|
|
114
|
+
content: [{ type: "text", text: presetList }],
|
|
115
|
+
structuredContent: { presets },
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
return server;
|
|
119
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cleanpastedtext-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Local MCP server that lets AI agents inspect and clean hidden Unicode, odd spaces and AI-style typography in text. Runs on your machine; text is never sent anywhere.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"cleanpastedtext-mcp": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/server.js",
|
|
10
|
+
"types": "./dist/server.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/server.d.ts",
|
|
14
|
+
"default": "./dist/server.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist",
|
|
19
|
+
"README.md",
|
|
20
|
+
"LICENSE"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.build.json",
|
|
24
|
+
"prepublishOnly": "npm run build"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
28
|
+
"cleanpastedtext": "^0.1.0",
|
|
29
|
+
"zod": "^4.6.7"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"mcp",
|
|
33
|
+
"model-context-protocol",
|
|
34
|
+
"unicode",
|
|
35
|
+
"invisible-characters",
|
|
36
|
+
"text-cleaner",
|
|
37
|
+
"ai-agents",
|
|
38
|
+
"claude"
|
|
39
|
+
],
|
|
40
|
+
"homepage": "https://cleanpastedtext.com/how-it-works",
|
|
41
|
+
"author": "Issaaf Kattan",
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=18"
|
|
45
|
+
}
|
|
46
|
+
}
|