cleanpastedtext-mcp 0.1.0 → 0.2.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/dist/server.d.ts +1 -1
- package/dist/server.js +26 -12
- package/package.json +2 -2
package/dist/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
export declare const VERSION = "0.
|
|
2
|
+
export declare const VERSION = "0.2.0";
|
|
3
3
|
/** Inputs above this size are refused so one call cannot stall the host. */
|
|
4
4
|
export declare const MAX_INPUT_CHARS = 1000000;
|
|
5
5
|
/**
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { cleanText, DEFAULT_PRESET, PRESET_DESCRIPTIONS, PRESETS, } from "cleanpastedtext";
|
|
4
|
-
export const VERSION = "0.
|
|
4
|
+
export const VERSION = "0.2.0";
|
|
5
5
|
/** Inputs above this size are refused so one call cannot stall the host. */
|
|
6
6
|
export const MAX_INPUT_CHARS = 1_000_000;
|
|
7
7
|
const PRESET_NAMES = Object.keys(PRESETS);
|
|
@@ -29,10 +29,16 @@ const optionsInput = z
|
|
|
29
29
|
removeJoinControls: z.boolean(),
|
|
30
30
|
stripMarkdown: z.boolean(),
|
|
31
31
|
joinLines: z.boolean(),
|
|
32
|
+
removeChatArtifacts: z.boolean(),
|
|
32
33
|
})
|
|
33
34
|
.partial()
|
|
34
35
|
.optional()
|
|
35
36
|
.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.");
|
|
37
|
+
const hiddenMessageOutput = z.object({
|
|
38
|
+
kind: z.enum(["tag", "variation-selector"]),
|
|
39
|
+
text: z.string(),
|
|
40
|
+
carriers: z.number(),
|
|
41
|
+
});
|
|
36
42
|
const detectionOutput = z.object({
|
|
37
43
|
codepoint: z.string(),
|
|
38
44
|
name: z.string(),
|
|
@@ -45,13 +51,15 @@ function resolveOptions(preset, overrides) {
|
|
|
45
51
|
const name = preset ?? DEFAULT_PRESET;
|
|
46
52
|
return { name, options: { ...PRESETS[name], ...overrides } };
|
|
47
53
|
}
|
|
48
|
-
function summarize(detections) {
|
|
54
|
+
function summarize(detections, hiddenMessages) {
|
|
55
|
+
const messages = hiddenMessages.map((m) => `HIDDEN MESSAGE (${m.kind === "tag" ? "tag characters" : "variation selectors"}, ${m.carriers} invisible characters): ${JSON.stringify(m.text)}`);
|
|
56
|
+
const prefix = messages.length > 0 ? messages.join("\n") + "\n" : "";
|
|
49
57
|
const changed = detections.filter((d) => d.action !== "kept");
|
|
50
58
|
if (changed.length === 0)
|
|
51
|
-
return "No supported hidden characters or other changes found.";
|
|
59
|
+
return prefix + "No supported hidden characters or other changes found.";
|
|
52
60
|
const total = changed.reduce((sum, d) => sum + d.count, 0);
|
|
53
61
|
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")}`;
|
|
62
|
+
return `${prefix}${total} change${total === 1 ? "" : "s"} across ${changed.length} character type${changed.length === 1 ? "" : "s"}:\n${lines.join("\n")}`;
|
|
55
63
|
}
|
|
56
64
|
/**
|
|
57
65
|
* Builds the MCP server. Every tool is a pure function of its input: nothing
|
|
@@ -61,17 +69,22 @@ export function createServer() {
|
|
|
61
69
|
const server = new McpServer({ name: "cleanpastedtext", version: VERSION });
|
|
62
70
|
server.registerTool("inspect_text", {
|
|
63
71
|
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.",
|
|
72
|
+
description: "Report the hidden Unicode characters (zero-width spaces, BiDi controls, tag characters, variation selectors, odd spaces), AI chat citation markers and typography that a preset would change, by name, code point and count, and decode any message hidden in tag characters or variation selectors. 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
73
|
inputSchema: { text: textInput, preset: presetInput, options: optionsInput },
|
|
66
|
-
outputSchema: {
|
|
74
|
+
outputSchema: {
|
|
75
|
+
preset: z.string(),
|
|
76
|
+
changeCount: z.number(),
|
|
77
|
+
detections: z.array(detectionOutput),
|
|
78
|
+
hiddenMessages: z.array(hiddenMessageOutput),
|
|
79
|
+
},
|
|
67
80
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
68
81
|
}, async ({ text, preset, options }) => {
|
|
69
82
|
const resolved = resolveOptions(preset, options);
|
|
70
|
-
const { detections } = cleanText(text, resolved.options);
|
|
83
|
+
const { detections, hiddenMessages } = cleanText(text, resolved.options);
|
|
71
84
|
const changeCount = detections.filter((d) => d.action !== "kept").reduce((sum, d) => sum + d.count, 0);
|
|
72
85
|
return {
|
|
73
|
-
content: [{ type: "text", text: summarize(detections) }],
|
|
74
|
-
structuredContent: { preset: resolved.name, changeCount, detections },
|
|
86
|
+
content: [{ type: "text", text: summarize(detections, hiddenMessages) }],
|
|
87
|
+
structuredContent: { preset: resolved.name, changeCount, detections, hiddenMessages },
|
|
75
88
|
};
|
|
76
89
|
});
|
|
77
90
|
server.registerTool("clean_text", {
|
|
@@ -83,18 +96,19 @@ export function createServer() {
|
|
|
83
96
|
cleanedText: z.string(),
|
|
84
97
|
changeCount: z.number(),
|
|
85
98
|
detections: z.array(detectionOutput),
|
|
99
|
+
hiddenMessages: z.array(hiddenMessageOutput),
|
|
86
100
|
},
|
|
87
101
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
88
102
|
}, async ({ text, preset, options }) => {
|
|
89
103
|
const resolved = resolveOptions(preset, options);
|
|
90
|
-
const { cleanedText, detections } = cleanText(text, resolved.options);
|
|
104
|
+
const { cleanedText, detections, hiddenMessages } = cleanText(text, resolved.options);
|
|
91
105
|
const changeCount = detections.filter((d) => d.action !== "kept").reduce((sum, d) => sum + d.count, 0);
|
|
92
106
|
return {
|
|
93
107
|
content: [
|
|
94
108
|
{ type: "text", text: cleanedText },
|
|
95
|
-
{ type: "text", text: summarize(detections) },
|
|
109
|
+
{ type: "text", text: summarize(detections, hiddenMessages) },
|
|
96
110
|
],
|
|
97
|
-
structuredContent: { preset: resolved.name, cleanedText, changeCount, detections },
|
|
111
|
+
structuredContent: { preset: resolved.name, cleanedText, changeCount, detections, hiddenMessages },
|
|
98
112
|
};
|
|
99
113
|
});
|
|
100
114
|
server.registerTool("list_presets", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cleanpastedtext-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
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
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
28
|
-
"cleanpastedtext": "^0.
|
|
28
|
+
"cleanpastedtext": "^0.2.0",
|
|
29
29
|
"zod": "^4.6.7"
|
|
30
30
|
},
|
|
31
31
|
"keywords": [
|