@v1nvn/readability-mcp 0.14.0 → 0.14.1
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-BwKCixh6.js → cli-CYsWq1_a.js} +2 -2
- package/dist/assets/{cli-BwKCixh6.js.map → cli-CYsWq1_a.js.map} +1 -1
- package/dist/assets/{extract-BKl4PzEI.js → extract-CZgSOqXG.js} +2 -2
- package/dist/assets/{extract-BKl4PzEI.js.map → extract-CZgSOqXG.js.map} +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as readHtmlFile, t as extractArticleFromHtml } from "./extract-
|
|
1
|
+
import { m as readHtmlFile, t as extractArticleFromHtml } from "./extract-CZgSOqXG.js";
|
|
2
2
|
//#region src/cli.ts
|
|
3
3
|
var USAGE = "Usage: readability-mcp extract [file.html] [--format md|json|html] [--max-chars N]";
|
|
4
4
|
var FORMATS = [
|
|
@@ -80,4 +80,4 @@ async function runCli(argv) {
|
|
|
80
80
|
//#endregion
|
|
81
81
|
export { runCli };
|
|
82
82
|
|
|
83
|
-
//# sourceMappingURL=cli-
|
|
83
|
+
//# sourceMappingURL=cli-CYsWq1_a.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-
|
|
1
|
+
{"version":3,"file":"cli-CYsWq1_a.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,IAA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ACT;AACF"}
|
|
@@ -13,7 +13,7 @@ import TurndownService from "turndown";
|
|
|
13
13
|
import { gfm } from "turndown-plugin-gfm";
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "@v1nvn/readability-mcp",
|
|
16
|
-
version: "0.14.
|
|
16
|
+
version: "0.14.1",
|
|
17
17
|
description: "MCP server that turns rendered (post-JS) HTML into clean Markdown + metadata via Readability, Turndown, and DOMPurify.",
|
|
18
18
|
type: "module",
|
|
19
19
|
main: "dist/index.js",
|
|
@@ -2731,4 +2731,4 @@ function registerExtractTool(server) {
|
|
|
2731
2731
|
//#endregion
|
|
2732
2732
|
export { outlineInputShape as $, extractListOutputShape as A, extractLinksInputShape as B, resolveLazyImages as C, chunkTextOutputShape as D, isElement as E, chunkTextInputSchema as F, extractSectionInputSchema as G, extractListInputShape as H, chunkTextInputShape as I, extractTablesInputShape as J, extractSectionInputShape as K, extractGridInputSchema as L, extractTablesOutputShape as M, outlineOutputShape as N, extractGridOutputShape as O, outputSchemaShape as P, outlineInputSchema as Q, extractGridInputShape as R, normalizeDocument as S, buildDocument as T, extractMetadataInputSchema as U, extractListInputSchema as V, extractMetadataInputShape as W, htmlToMarkdownInputShape as X, htmlToMarkdownInputSchema as Y, localPathField as Z, detectGating as _, sanitizeHtml as a, registerResources as at, isReaderable as b, computeTextMetrics as c, renderTable as d, selectorsSchema as et, resolveHeaderKeys as f, absolutize as g, detectPagination as h, toMarkdown as i, toErrorResult as it, extractMetadataOutputShape as j, extractLinksOutputShape as k, nonEmpty as l, readHtmlFile as m, registerExtractTool as n, logger as nt, formatPayload as o, loadConfig as ot, resolveCellText as p, extractTablesInputSchema as q, truncateMarkdown as r, ExtractionError as rt, resolveMetadata as s, extractArticleFromHtml as t, chunkMarkdown as tt, parseTableMatrix as u, TraceCollector as v, resolveReadabilityOptions as w, applySelectors as x, assembleDiagnostics as y, extractLinksInputSchema as z };
|
|
2733
2733
|
|
|
2734
|
-
//# sourceMappingURL=extract-
|
|
2734
|
+
//# sourceMappingURL=extract-CZgSOqXG.js.map
|