cleanpastedtext-mcp 0.1.0 → 0.3.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 +78 -13
- 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.3.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
|
-
import { cleanText, DEFAULT_PRESET, PRESET_DESCRIPTIONS, PRESETS, } from "cleanpastedtext";
|
|
4
|
-
export const VERSION = "0.
|
|
3
|
+
import { analyzeAiSignals, cleanText, FAMILY_LABELS, SIGNAL_GENRES, DEFAULT_PRESET, PRESET_DESCRIPTIONS, PRESETS, } from "cleanpastedtext";
|
|
4
|
+
export const VERSION = "0.3.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,70 @@ 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 },
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
const genreNames = Object.keys(SIGNAL_GENRES);
|
|
115
|
+
server.registerTool("ai_signals", {
|
|
116
|
+
title: "AI-style writing signals",
|
|
117
|
+
description: "Report published AI-writing patterns in a text as explainable evidence, never a verdict: chatbot-interface residue (citation tokens, placeholders, assistant openers and sign-offs) and a Low/Medium/High style strength from overused vocabulary, phrase templates, chat formatting, em-dash rate and participial clauses. Every signal lists the matched text, its source and the human writing it also appears in. Run it on the original paste, before cleaning. Under 150 words the style is not assessed. Do not present the result as proof of AI authorship; non-native and formal human writing can score Medium or High.",
|
|
118
|
+
inputSchema: {
|
|
119
|
+
text: textInput,
|
|
120
|
+
genre: z.enum(genreNames).optional().describe(`Kind of writing; changes weights. ${genreNames.map((g) => `${g} (${SIGNAL_GENRES[g]})`).join(", ")}. Defaults to general.`),
|
|
121
|
+
},
|
|
122
|
+
outputSchema: {
|
|
123
|
+
level: z.enum(["not-enough-text", "low", "medium", "high"]),
|
|
124
|
+
points: z.number(),
|
|
125
|
+
words: z.number(),
|
|
126
|
+
genre: z.string(),
|
|
127
|
+
families: z.array(z.object({ family: z.string(), points: z.number(), cap: z.number() })),
|
|
128
|
+
signals: z.array(z.object({
|
|
129
|
+
id: z.string(),
|
|
130
|
+
family: z.string(),
|
|
131
|
+
label: z.string(),
|
|
132
|
+
matches: z.array(z.string()),
|
|
133
|
+
count: z.number(),
|
|
134
|
+
points: z.number(),
|
|
135
|
+
note: z.string(),
|
|
136
|
+
falsePositives: z.string(),
|
|
137
|
+
source: z.object({ title: z.string(), url: z.string() }),
|
|
138
|
+
})),
|
|
139
|
+
residue: z.array(z.object({
|
|
140
|
+
id: z.string(),
|
|
141
|
+
label: z.string(),
|
|
142
|
+
matches: z.array(z.string()),
|
|
143
|
+
count: z.number(),
|
|
144
|
+
strength: z.enum(["definitive", "strong"]),
|
|
145
|
+
note: z.string(),
|
|
146
|
+
source: z.object({ title: z.string(), url: z.string() }),
|
|
147
|
+
})),
|
|
148
|
+
notes: z.array(z.string()),
|
|
149
|
+
lexiconVersion: z.string(),
|
|
150
|
+
},
|
|
151
|
+
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false },
|
|
152
|
+
}, async ({ text, genre }) => {
|
|
153
|
+
const report = analyzeAiSignals(text, genre ?? "general");
|
|
154
|
+
const lines = [
|
|
155
|
+
`AI-style signals: ${report.level} (${report.points} points across ${report.families.length} families, ${report.words} words). Evidence, not a verdict.`,
|
|
156
|
+
...report.residue.map((r) => `CHATBOT RESIDUE: ${r.label} ×${r.count} (${r.strength})`),
|
|
157
|
+
...report.signals.map((sig) => `- ${sig.label} [${FAMILY_LABELS[sig.family]}] +${sig.points}: ${sig.matches.slice(0, 2).join(" / ")}`),
|
|
158
|
+
...report.notes.map((n) => `Note: ${n}`),
|
|
159
|
+
];
|
|
160
|
+
return {
|
|
161
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
162
|
+
structuredContent: report,
|
|
98
163
|
};
|
|
99
164
|
});
|
|
100
165
|
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.3.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.3.0",
|
|
29
29
|
"zod": "^4.6.7"
|
|
30
30
|
},
|
|
31
31
|
"keywords": [
|