@v1nvn/readability-mcp 0.15.0 → 0.16.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/assets/{cli-B5p52u-S.js → cli-CCcnfTRC.js} +30 -28
- package/dist/assets/cli-CCcnfTRC.js.map +1 -0
- package/dist/assets/{extract-CnKZr8QG.js → extract-C55iDWx1.js} +4 -2
- package/dist/assets/extract-C55iDWx1.js.map +1 -0
- package/dist/index.js +2 -2
- package/package.json +3 -1
- package/dist/assets/cli-B5p52u-S.js.map +0 -1
- package/dist/assets/extract-CnKZr8QG.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as outlineInputShape, A as extractListOutputShape, B as extractLinksInputShape, C as resolveLazyImages, D as chunkTextOutputShape, E as isElement, F as chunkTextInputSchema, G as extractSectionInputSchema, H as extractListInputShape, I as chunkTextInputShape, J as extractTablesInputShape, K as extractSectionInputShape, L as extractGridInputSchema, M as extractTablesOutputShape, N as outlineOutputShape, O as extractGridOutputShape, P as outputSchemaShape, Q as outlineInputSchema, R as extractGridInputShape, S as normalizeDocument, T as buildDocument, U as extractMetadataInputSchema, V as extractListInputSchema, W as extractMetadataInputShape, X as htmlToMarkdownInputShape, Y as htmlToMarkdownInputSchema, Z as localPathField, _ as detectGating, a as sanitizeHtml, at as registerResources, b as isReaderable, c as computeTextMetrics, d as renderTable, et as selectorsSchema, f as resolveHeaderKeys, g as absolutize, h as detectPagination, i as toMarkdown, it as toErrorResult, j as extractMetadataOutputShape, k as extractLinksOutputShape, l as nonEmpty, m as readHtmlFile, n as registerExtractTool, nt as logger, o as formatPayload, ot as loadConfig, p as resolveCellText, q as extractTablesInputSchema, r as truncateMarkdown, rt as ExtractionError, s as resolveMetadata, t as extractArticleFromHtml, tt as chunkMarkdown, u as parseTableMatrix, v as TraceCollector, w as resolveReadabilityOptions, x as applySelectors, y as assembleDiagnostics, z as extractLinksInputSchema } from "./assets/extract-
|
|
2
|
+
import { $ as outlineInputShape, A as extractListOutputShape, B as extractLinksInputShape, C as resolveLazyImages, D as chunkTextOutputShape, E as isElement, F as chunkTextInputSchema, G as extractSectionInputSchema, H as extractListInputShape, I as chunkTextInputShape, J as extractTablesInputShape, K as extractSectionInputShape, L as extractGridInputSchema, M as extractTablesOutputShape, N as outlineOutputShape, O as extractGridOutputShape, P as outputSchemaShape, Q as outlineInputSchema, R as extractGridInputShape, S as normalizeDocument, T as buildDocument, U as extractMetadataInputSchema, V as extractListInputSchema, W as extractMetadataInputShape, X as htmlToMarkdownInputShape, Y as htmlToMarkdownInputSchema, Z as localPathField, _ as detectGating, a as sanitizeHtml, at as registerResources, b as isReaderable, c as computeTextMetrics, d as renderTable, et as selectorsSchema, f as resolveHeaderKeys, g as absolutize, h as detectPagination, i as toMarkdown, it as toErrorResult, j as extractMetadataOutputShape, k as extractLinksOutputShape, l as nonEmpty, m as readHtmlFile, n as registerExtractTool, nt as logger, o as formatPayload, ot as loadConfig, p as resolveCellText, q as extractTablesInputSchema, r as truncateMarkdown, rt as ExtractionError, s as resolveMetadata, t as extractArticleFromHtml, tt as chunkMarkdown, u as parseTableMatrix, v as TraceCollector, w as resolveReadabilityOptions, x as applySelectors, y as assembleDiagnostics, z as extractLinksInputSchema } from "./assets/extract-C55iDWx1.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
5
|
import { z } from "zod";
|
|
@@ -1401,7 +1401,7 @@ function createServer() {
|
|
|
1401
1401
|
}
|
|
1402
1402
|
//#endregion
|
|
1403
1403
|
//#region src/index.ts
|
|
1404
|
-
if (process.argv[2] === "extract") import("./assets/cli-
|
|
1404
|
+
if (process.argv[2] === "extract") import("./assets/cli-CCcnfTRC.js").then((m) => m.runCli(process.argv.slice(2))).then((code) => {
|
|
1405
1405
|
process.exit(code);
|
|
1406
1406
|
}).catch((err) => {
|
|
1407
1407
|
process.stderr.write(`${err instanceof Error ? err.message : String(err)}\n`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v1nvn/readability-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "MCP server that turns rendered (post-JS) HTML into clean Markdown + metadata via Readability, Turndown, and DOMPurify.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -41,6 +41,8 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
43
43
|
"@mozilla/readability": "^0.6.0",
|
|
44
|
+
"@v1nvn/agentic-core": "^0.16.0",
|
|
45
|
+
"commander": "^15.0.0",
|
|
44
46
|
"dompurify": "^3.4.12",
|
|
45
47
|
"jsdom": "^30.0.1",
|
|
46
48
|
"remark-gfm": "^4.0.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli-B5p52u-S.js","names":[],"sources":["../../src/cli.ts"],"sourcesContent":["import { extractArticleFromHtml } from './tools/extract.js';\nimport { readHtmlFile } from './tools/html-source.js';\n\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport type { Readable } from 'node:stream';\n\ntype CliFormat = 'html' | 'json' | 'md';\n\nexport interface ParsedArgs {\n readonly file: string | undefined;\n readonly format: CliFormat;\n readonly maxChars: number | undefined;\n}\n\nconst USAGE =\n 'Usage: readability-mcp extract [file.html] [--format md|json|html] [--max-chars N]';\n\nconst FORMATS: readonly CliFormat[] = ['html', 'json', 'md'];\n\nfunction isCliFormat(value: string | undefined): value is CliFormat {\n return value !== undefined && (FORMATS as readonly string[]).includes(value);\n}\n\n// `extract` is consumed by the caller; everything after it is parsed here.\n// Flag values are read with `.at()` (not `[]`) because the peek may advance\n// past the end for a trailing flag with no value; `.at()` surfaces that as\n// undefined where bracket indexing would not (noUncheckedIndexedAccess is off).\nexport function parseArgs(argv: readonly string[]): ParsedArgs | undefined {\n let file: string | undefined;\n let format: CliFormat = 'md';\n let maxChars: number | undefined;\n\n const rest = argv.slice(1);\n for (let i = 0; i < rest.length; i++) {\n const arg = rest[i];\n if (arg === '--format') {\n const value = rest.at(++i);\n if (!isCliFormat(value)) {\n return undefined;\n }\n format = value;\n } else if (arg === '--max-chars') {\n const value = rest.at(++i);\n if (value === undefined) {\n return undefined;\n }\n const n = Number(value);\n if (!Number.isInteger(n)) {\n return undefined;\n }\n maxChars = n;\n } else if (arg.startsWith('--')) {\n return undefined;\n } else if (file === undefined) {\n file = arg;\n } else {\n return undefined;\n }\n }\n\n return { file, format, maxChars };\n}\n\n// The stream is injected rather than reading process.stdin directly so the\n// path is testable. Chunks may be Buffer (process.stdin) or string\n// (Readable.from), so both are handled.\nexport async function readHtml(\n file: string | undefined,\n stream: Readable,\n): Promise<string> {\n if (file !== undefined) {\n return readHtmlFile(file);\n }\n const chunks: string[] = [];\n for await (const chunk of stream) {\n if (typeof chunk === 'string') {\n chunks.push(chunk);\n } else {\n chunks.push(Buffer.from(chunk as Uint8Array).toString('utf8'));\n }\n }\n return chunks.join('');\n}\n\nfunction payloadText(result: CallToolResult): string {\n const first = result.content.at(0);\n return first !== undefined && 'text' in first ? first.text : '';\n}\n\nexport async function runCli(argv: readonly string[]): Promise<number> {\n if (argv[0] !== 'extract') {\n process.stderr.write(`${USAGE}\\n`);\n return 2;\n }\n\n const parsed = parseArgs(argv);\n if (parsed === undefined) {\n process.stderr.write(`${USAGE}\\n`);\n return 2;\n }\n\n try {\n const html = await readHtml(parsed.file, process.stdin);\n // json reuses the markdown pipeline; the structured object is serialized below.\n const pipelineFormat = parsed.format === 'html' ? 'html' : 'markdown';\n const result = extractArticleFromHtml({\n html,\n format: pipelineFormat,\n ...(parsed.maxChars !== undefined ? { maxChars: parsed.maxChars } : {}),\n });\n\n if (result.isError) {\n process.stderr.write(`${payloadText(result)}\\n`);\n return 1;\n }\n\n if (parsed.format === 'json') {\n process.stdout.write(\n `${JSON.stringify(result.structuredContent, null, 2)}\\n`,\n );\n } else {\n process.stdout.write(`${payloadText(result)}\\n`);\n }\n return 0;\n } catch (err) {\n process.stderr.write(\n `${err instanceof Error ? err.message : String(err)}\\n`,\n );\n return 1;\n }\n}\n"],"mappings":";;AAcA,IAAM,QACJ;AAEF,IAAM,UAAgC;CAAC;CAAQ;CAAQ;AAAI;AAE3D,SAAS,YAAY,OAA+C;CAClE,OAAO,UAAU,KAAA,KAAc,QAA8B,SAAS,KAAK;AAC7E;AAMA,SAAgB,UAAU,MAAiD;CACzE,IAAI;CACJ,IAAI,SAAoB;CACxB,IAAI;CAEJ,MAAM,OAAO,KAAK,MAAM,CAAC;CACzB,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACpC,MAAM,MAAM,KAAK;EACjB,IAAI,QAAQ,YAAY;GACtB,MAAM,QAAQ,KAAK,GAAG,EAAE,CAAC;GACzB,IAAI,CAAC,YAAY,KAAK,GACpB;GAEF,SAAS;EACX,OAAO,IAAI,QAAQ,eAAe;GAChC,MAAM,QAAQ,KAAK,GAAG,EAAE,CAAC;GACzB,IAAI,UAAU,KAAA,GACZ;GAEF,MAAM,IAAI,OAAO,KAAK;GACtB,IAAI,CAAC,OAAO,UAAU,CAAC,GACrB;GAEF,WAAW;EACb,OAAO,IAAI,IAAI,WAAW,IAAI,GAC5B;OACK,IAAI,SAAS,KAAA,GAClB,OAAO;OAEP;CAEJ;CAEA,OAAO;EAAE;EAAM;EAAQ;CAAS;AAClC;AAKA,eAAsB,SACpB,MACA,QACiB;CACjB,IAAI,SAAS,KAAA,GACX,OAAO,aAAa,IAAI;CAE1B,MAAM,SAAmB,CAAC;CAC1B,WAAW,MAAM,SAAS,QACxB,IAAI,OAAO,UAAU,UACnB,OAAO,KAAK,KAAK;MAEjB,OAAO,KAAK,OAAO,KAAK,KAAm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