@aiquants/html-to-markdown 0.2.6 → 0.4.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/README.md +90 -9
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/mcp-server-Co1kuNGX.cjs +1 -0
- package/dist/mcp-server-DzB_5cTs.js +267 -0
- package/dist/mcp-server-streamable-BNn6Kd9b.cjs +1 -0
- package/dist/{mcp-server-streamable-3B3B1fuS.js → mcp-server-streamable-CcZ7Lsel.js} +223 -142
- package/dist/mcp-streamable.cjs +1 -1
- package/dist/mcp-streamable.js +1 -1
- package/dist/mcp.cjs +1 -1
- package/dist/mcp.js +1 -1
- package/dist/src/mcp-common.d.ts +164 -0
- package/dist/src/mcp-server-streamable.d.ts +23 -13
- package/dist/src/mcp-server.d.ts +216 -22
- package/dist/{version-PCzxchJe.js → version-BSh9aXhF.js} +229 -8
- package/dist/version-dpS3SSul.cjs +1 -0
- package/mcp.json +4 -4
- package/package.json +1 -1
- package/dist/mcp-server-B8hz3lXI.js +0 -364
- package/dist/mcp-server-Bo_mCvzz.cjs +0 -1
- package/dist/mcp-server-streamable-Cc4QsZQe.cjs +0 -1
- package/dist/version-DTaUKNBS.cjs +0 -1
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { J as JSONRPCMessageSchema, i as isInitializeRequest,
|
|
1
|
+
import { J as JSONRPCMessageSchema, i as isInitializeRequest, e as isJSONRPCRequest, D as DEFAULT_NEGOTIATED_PROTOCOL_VERSION, f as SUPPORTED_PROTOCOL_VERSIONS, h as isJSONRPCResponse, j as isJSONRPCError, g as getPackageVersion, S as Server, I as InitializeRequestSchema, L as ListToolsRequestSchema, C as CallToolRequestSchema, p as parseHtmlToMarkdownArgs, b as parseSaveContentArgs, s as saveContentToFile, d as parseUrlToMarkdownFileArgs } from "./version-BSh9aXhF.js";
|
|
2
2
|
import { a as getAugmentedNamespace, c as commonjsGlobal, b as getDefaultExportFromCjs, h as htmlToMarkdown } from "./core-CouDTni-.js";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import cors from "cors";
|
|
5
5
|
import express from "express";
|
|
6
|
-
import { promises } from "fs";
|
|
7
|
-
import { join, resolve, dirname } from "path";
|
|
8
6
|
import yargsParser from "yargs-parser";
|
|
9
7
|
var bytes = { exports: {} };
|
|
10
8
|
/*!
|
|
@@ -6418,10 +6416,10 @@ function requireRawBody() {
|
|
|
6418
6416
|
if (done) {
|
|
6419
6417
|
return readStream(stream, encoding, length, limit, wrap(done));
|
|
6420
6418
|
}
|
|
6421
|
-
return new Promise(function executor(
|
|
6419
|
+
return new Promise(function executor(resolve, reject) {
|
|
6422
6420
|
readStream(stream, encoding, length, limit, function onRead(err, buf) {
|
|
6423
6421
|
if (err) return reject(err);
|
|
6424
|
-
|
|
6422
|
+
resolve(buf);
|
|
6425
6423
|
});
|
|
6426
6424
|
});
|
|
6427
6425
|
}
|
|
@@ -7159,41 +7157,6 @@ class StreamableHTTPServerTransport {
|
|
|
7159
7157
|
}
|
|
7160
7158
|
}
|
|
7161
7159
|
}
|
|
7162
|
-
function generateFilename(url, outputFormat) {
|
|
7163
|
-
if (url && url !== "direct-html-input") {
|
|
7164
|
-
try {
|
|
7165
|
-
const urlObj = new URL(url);
|
|
7166
|
-
let filename = urlObj.pathname.split("/").pop() || "page";
|
|
7167
|
-
filename = filename.replace(/\.[^.]*$/, "");
|
|
7168
|
-
filename = filename.replace(/[<>:"/\\|?*]/g, "_");
|
|
7169
|
-
if (!filename || filename.match(/^\.+$/)) {
|
|
7170
|
-
filename = "page";
|
|
7171
|
-
}
|
|
7172
|
-
return filename;
|
|
7173
|
-
} catch {
|
|
7174
|
-
return "page";
|
|
7175
|
-
}
|
|
7176
|
-
}
|
|
7177
|
-
return "page";
|
|
7178
|
-
}
|
|
7179
|
-
async function saveContentToFile(content, savePath, saveDirectory, url, outputFormat) {
|
|
7180
|
-
if (!savePath && !saveDirectory) {
|
|
7181
|
-
return null;
|
|
7182
|
-
}
|
|
7183
|
-
let finalPath;
|
|
7184
|
-
if (savePath) {
|
|
7185
|
-
finalPath = resolve(savePath);
|
|
7186
|
-
} else if (saveDirectory) {
|
|
7187
|
-
const filename = generateFilename(url);
|
|
7188
|
-
const extension = outputFormat === "html" ? ".html" : ".md";
|
|
7189
|
-
finalPath = resolve(saveDirectory, `${filename}${extension}`);
|
|
7190
|
-
} else {
|
|
7191
|
-
return null;
|
|
7192
|
-
}
|
|
7193
|
-
await promises.mkdir(dirname(finalPath), { recursive: true });
|
|
7194
|
-
await promises.writeFile(finalPath, content, "utf-8");
|
|
7195
|
-
return finalPath;
|
|
7196
|
-
}
|
|
7197
7160
|
class StreamableHtmlToMarkdownMcpServer {
|
|
7198
7161
|
constructor() {
|
|
7199
7162
|
this.version = getPackageVersion();
|
|
@@ -7213,46 +7176,96 @@ class StreamableHtmlToMarkdownMcpServer {
|
|
|
7213
7176
|
sessionIdGenerator: void 0
|
|
7214
7177
|
// Stateless server
|
|
7215
7178
|
});
|
|
7216
|
-
const toolParameters = {
|
|
7217
|
-
type: "object",
|
|
7218
|
-
properties: {
|
|
7219
|
-
url: {
|
|
7220
|
-
type: "string",
|
|
7221
|
-
description: "URL of the web page to convert (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively."
|
|
7222
|
-
},
|
|
7223
|
-
html_content: {
|
|
7224
|
-
type: "string",
|
|
7225
|
-
description: "HTML string to convert directly. Use instead of URL for local files or API response HTML content."
|
|
7226
|
-
},
|
|
7227
|
-
locale: {
|
|
7228
|
-
type: "string",
|
|
7229
|
-
description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.",
|
|
7230
|
-
enum: ["en-US", "ja-JP"],
|
|
7231
|
-
default: "en-US"
|
|
7232
|
-
},
|
|
7233
|
-
output_format: {
|
|
7234
|
-
type: "string",
|
|
7235
|
-
description: "Output format: 'markdown' (Markdown only), 'html' (original HTML only), 'both' (returns both formats).",
|
|
7236
|
-
enum: ["markdown", "html", "both"],
|
|
7237
|
-
default: "markdown"
|
|
7238
|
-
},
|
|
7239
|
-
save_path: {
|
|
7240
|
-
type: "string",
|
|
7241
|
-
description: "Complete file path including filename to save converted content (e.g., '/home/user/output.md'). Cannot be used with save_directory."
|
|
7242
|
-
},
|
|
7243
|
-
save_directory: {
|
|
7244
|
-
type: "string",
|
|
7245
|
-
description: "Directory path to save converted content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path."
|
|
7246
|
-
}
|
|
7247
|
-
},
|
|
7248
|
-
anyOf: [{ required: ["url"] }, { required: ["html_content"] }]
|
|
7249
|
-
};
|
|
7250
7179
|
this.tools = [
|
|
7251
7180
|
{
|
|
7252
7181
|
name: "html_to_markdown_streamable",
|
|
7253
7182
|
description: "Streamable HTML to Markdown converter with real-time progress updates. Ideal for large pages and time-consuming conversions with JavaScript dynamic content support.",
|
|
7254
|
-
inputSchema:
|
|
7183
|
+
inputSchema: {
|
|
7184
|
+
type: "object",
|
|
7185
|
+
properties: {
|
|
7186
|
+
url: {
|
|
7187
|
+
type: "string",
|
|
7188
|
+
description: "URL of the web page to convert (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively."
|
|
7189
|
+
},
|
|
7190
|
+
html_content: {
|
|
7191
|
+
type: "string",
|
|
7192
|
+
description: "HTML string to convert directly. Use instead of URL for local files or API response HTML content."
|
|
7193
|
+
},
|
|
7194
|
+
locale: {
|
|
7195
|
+
type: "string",
|
|
7196
|
+
description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.",
|
|
7197
|
+
enum: ["en-US", "ja-JP"],
|
|
7198
|
+
default: "en-US"
|
|
7199
|
+
}
|
|
7200
|
+
},
|
|
7201
|
+
anyOf: [{ required: ["url"] }, { required: ["html_content"] }]
|
|
7202
|
+
},
|
|
7255
7203
|
handler: (args, context) => this.handleHtmlToMarkdown(args, context)
|
|
7204
|
+
},
|
|
7205
|
+
{
|
|
7206
|
+
name: "save_content_to_file",
|
|
7207
|
+
description: "Save text content to a file with specified path or directory. Supports automatic filename generation. Content will be saved as Markdown format.",
|
|
7208
|
+
inputSchema: {
|
|
7209
|
+
type: "object",
|
|
7210
|
+
properties: {
|
|
7211
|
+
content: {
|
|
7212
|
+
type: "string",
|
|
7213
|
+
description: "Text content to save to file. Will be saved as Markdown format."
|
|
7214
|
+
},
|
|
7215
|
+
save_path: {
|
|
7216
|
+
type: "string",
|
|
7217
|
+
description: "Complete file path including filename to save content (e.g., '/home/user/output.md'). Cannot be used with save_directory."
|
|
7218
|
+
},
|
|
7219
|
+
save_directory: {
|
|
7220
|
+
type: "string",
|
|
7221
|
+
description: "Directory path to save content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path."
|
|
7222
|
+
},
|
|
7223
|
+
filename: {
|
|
7224
|
+
type: "string",
|
|
7225
|
+
description: "Base filename to use when save_directory is specified (e.g., 'my-document'). Extension .md will be added automatically."
|
|
7226
|
+
}
|
|
7227
|
+
},
|
|
7228
|
+
required: ["content"],
|
|
7229
|
+
anyOf: [{ required: ["save_path"] }, { required: ["save_directory"] }]
|
|
7230
|
+
},
|
|
7231
|
+
handler: (args, context) => this.handleSaveContentToFile(args, context)
|
|
7232
|
+
},
|
|
7233
|
+
{
|
|
7234
|
+
name: "url_to_markdown_file_streamable",
|
|
7235
|
+
description: "Streamable URL to Markdown file converter with real-time progress updates. Combines HTML-to-Markdown conversion and file saving in one step. Ideal for large pages with JavaScript dynamic content support.",
|
|
7236
|
+
inputSchema: {
|
|
7237
|
+
type: "object",
|
|
7238
|
+
properties: {
|
|
7239
|
+
url: {
|
|
7240
|
+
type: "string",
|
|
7241
|
+
description: "URL of the web page to convert and save as Markdown file (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively."
|
|
7242
|
+
},
|
|
7243
|
+
html_content: {
|
|
7244
|
+
type: "string",
|
|
7245
|
+
description: "HTML string to convert directly and save as Markdown file. Use instead of URL for local files or API response HTML content."
|
|
7246
|
+
},
|
|
7247
|
+
locale: {
|
|
7248
|
+
type: "string",
|
|
7249
|
+
description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.",
|
|
7250
|
+
enum: ["en-US", "ja-JP"],
|
|
7251
|
+
default: "en-US"
|
|
7252
|
+
},
|
|
7253
|
+
save_path: {
|
|
7254
|
+
type: "string",
|
|
7255
|
+
description: "Complete file path including filename to save the converted Markdown content (e.g., '/home/user/output.md'). Cannot be used with save_directory."
|
|
7256
|
+
},
|
|
7257
|
+
save_directory: {
|
|
7258
|
+
type: "string",
|
|
7259
|
+
description: "Directory path to save the converted Markdown content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path."
|
|
7260
|
+
},
|
|
7261
|
+
filename: {
|
|
7262
|
+
type: "string",
|
|
7263
|
+
description: "Base filename to use when save_directory is specified (e.g., 'my-document'). Extension .md will be added automatically."
|
|
7264
|
+
}
|
|
7265
|
+
},
|
|
7266
|
+
anyOf: [{ required: ["url", "save_path"] }, { required: ["url", "save_directory"] }, { required: ["html_content", "save_path"] }, { required: ["html_content", "save_directory"] }]
|
|
7267
|
+
},
|
|
7268
|
+
handler: (args, context) => this.handleUrlToMarkdownFile(args, context)
|
|
7256
7269
|
}
|
|
7257
7270
|
];
|
|
7258
7271
|
this.setupRequestHandlers();
|
|
@@ -7339,19 +7352,8 @@ class StreamableHtmlToMarkdownMcpServer {
|
|
|
7339
7352
|
*/
|
|
7340
7353
|
async *handleHtmlToMarkdown(args, _context) {
|
|
7341
7354
|
try {
|
|
7342
|
-
const
|
|
7343
|
-
|
|
7344
|
-
throw new Error("url または html_content のいずれかを提供する必要があります。");
|
|
7345
|
-
}
|
|
7346
|
-
if (save_path && typeof save_path !== "string") {
|
|
7347
|
-
throw new Error("'save_path' must be a string");
|
|
7348
|
-
}
|
|
7349
|
-
if (save_directory && typeof save_directory !== "string") {
|
|
7350
|
-
throw new Error("'save_directory' must be a string");
|
|
7351
|
-
}
|
|
7352
|
-
if (save_path && save_directory) {
|
|
7353
|
-
throw new Error("Cannot specify both 'save_path' and 'save_directory'");
|
|
7354
|
-
}
|
|
7355
|
+
const validatedArgs = parseHtmlToMarkdownArgs(args);
|
|
7356
|
+
const { url, html_content, locale = "en-US" } = validatedArgs;
|
|
7355
7357
|
if (url) {
|
|
7356
7358
|
try {
|
|
7357
7359
|
new URL(url);
|
|
@@ -7370,70 +7372,130 @@ class StreamableHtmlToMarkdownMcpServer {
|
|
|
7370
7372
|
});
|
|
7371
7373
|
yield {
|
|
7372
7374
|
type: "progress",
|
|
7373
|
-
progress:
|
|
7374
|
-
message: "
|
|
7375
|
+
progress: 100,
|
|
7376
|
+
message: "変換が完了しました。"
|
|
7375
7377
|
};
|
|
7376
|
-
const
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
if (markdownPath) {
|
|
7392
|
-
const savedMarkdownPath = await saveContentToFile(result.markdown, markdownPath, void 0, url, "markdown");
|
|
7393
|
-
if (savedMarkdownPath) savedPaths.push(savedMarkdownPath);
|
|
7394
|
-
}
|
|
7395
|
-
const htmlPath = save_path ? save_path.endsWith(".html") ? save_path : `${save_path}.html` : save_directory ? join(save_directory, `${generateFilename(url)}.html`) : void 0;
|
|
7396
|
-
if (htmlPath) {
|
|
7397
|
-
const savedHtmlPath = await saveContentToFile(result.html, htmlPath, void 0, url, "html");
|
|
7398
|
-
if (savedHtmlPath) savedPaths.push(savedHtmlPath);
|
|
7378
|
+
const responseText = result.markdown;
|
|
7379
|
+
const content = [{ type: "text", text: responseText }];
|
|
7380
|
+
yield {
|
|
7381
|
+
type: "result",
|
|
7382
|
+
result: { content }
|
|
7383
|
+
};
|
|
7384
|
+
} catch (error) {
|
|
7385
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
7386
|
+
yield {
|
|
7387
|
+
type: "result",
|
|
7388
|
+
result: {
|
|
7389
|
+
content: [
|
|
7390
|
+
{
|
|
7391
|
+
type: "text",
|
|
7392
|
+
text: `エラーが発生しました: ${errorMessage}`
|
|
7399
7393
|
}
|
|
7400
|
-
|
|
7401
|
-
}
|
|
7394
|
+
]
|
|
7402
7395
|
}
|
|
7403
|
-
}
|
|
7396
|
+
};
|
|
7397
|
+
}
|
|
7398
|
+
}
|
|
7399
|
+
/**
|
|
7400
|
+
* Handle save content to file tool call with streamable support.
|
|
7401
|
+
* streamable サポート付きのファイル保存ツール呼び出しを処理
|
|
7402
|
+
*/
|
|
7403
|
+
async *handleSaveContentToFile(args, _context) {
|
|
7404
|
+
try {
|
|
7405
|
+
const validatedArgs = parseSaveContentArgs(args);
|
|
7406
|
+
const { content, save_path, save_directory, filename } = validatedArgs;
|
|
7407
|
+
yield {
|
|
7408
|
+
type: "progress",
|
|
7409
|
+
progress: 20,
|
|
7410
|
+
message: "ファイル保存の準備中..."
|
|
7411
|
+
};
|
|
7412
|
+
const savedPath = await saveContentToFile(content, save_path, save_directory, filename);
|
|
7404
7413
|
yield {
|
|
7405
7414
|
type: "progress",
|
|
7406
7415
|
progress: 100,
|
|
7407
|
-
message: "
|
|
7416
|
+
message: "ファイル保存が完了しました。"
|
|
7408
7417
|
};
|
|
7409
|
-
|
|
7410
|
-
|
|
7411
|
-
|
|
7412
|
-
|
|
7413
|
-
|
|
7414
|
-
|
|
7415
|
-
|
|
7416
|
-
|
|
7417
|
-
|
|
7418
|
-
|
|
7419
|
-
|
|
7420
|
-
|
|
7421
|
-
|
|
7422
|
-
|
|
7423
|
-
|
|
7424
|
-
|
|
7425
|
-
|
|
7418
|
+
const responseText = `Content saved successfully to: ${savedPath}`;
|
|
7419
|
+
yield {
|
|
7420
|
+
type: "result",
|
|
7421
|
+
result: {
|
|
7422
|
+
content: [
|
|
7423
|
+
{
|
|
7424
|
+
type: "text",
|
|
7425
|
+
text: responseText
|
|
7426
|
+
}
|
|
7427
|
+
],
|
|
7428
|
+
isError: false
|
|
7429
|
+
}
|
|
7430
|
+
};
|
|
7431
|
+
} catch (error) {
|
|
7432
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
7433
|
+
yield {
|
|
7434
|
+
type: "result",
|
|
7435
|
+
result: {
|
|
7436
|
+
content: [
|
|
7437
|
+
{
|
|
7438
|
+
type: "text",
|
|
7439
|
+
text: `エラーが発生しました: ${errorMessage}`
|
|
7440
|
+
}
|
|
7441
|
+
],
|
|
7442
|
+
isError: true
|
|
7443
|
+
}
|
|
7444
|
+
};
|
|
7445
|
+
}
|
|
7446
|
+
}
|
|
7447
|
+
/**
|
|
7448
|
+
* Handle URL to Markdown file conversion tool call with streamable support.
|
|
7449
|
+
* streamable サポート付きの URL から Markdown ファイルへの変換ツール呼び出しを処理
|
|
7450
|
+
*/
|
|
7451
|
+
async *handleUrlToMarkdownFile(args, _context) {
|
|
7452
|
+
try {
|
|
7453
|
+
const validatedArgs = parseUrlToMarkdownFileArgs(args);
|
|
7454
|
+
const { url, html_content, locale = "en-US", save_path, save_directory, filename } = validatedArgs;
|
|
7455
|
+
if (url) {
|
|
7456
|
+
try {
|
|
7457
|
+
new URL(url);
|
|
7458
|
+
} catch {
|
|
7459
|
+
throw new Error(`Invalid URL: ${url}`);
|
|
7460
|
+
}
|
|
7426
7461
|
}
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7462
|
+
yield {
|
|
7463
|
+
type: "progress",
|
|
7464
|
+
progress: 0,
|
|
7465
|
+
message: "Web ページの内容を取得して Markdown に変換します。"
|
|
7466
|
+
};
|
|
7467
|
+
const result = await htmlToMarkdown(url || "direct-html-input", {
|
|
7468
|
+
locale,
|
|
7469
|
+
htmlContent: html_content
|
|
7470
|
+
});
|
|
7471
|
+
yield {
|
|
7472
|
+
type: "progress",
|
|
7473
|
+
progress: 70,
|
|
7474
|
+
message: "Markdown への変換が完了しました。ファイルに保存しています。"
|
|
7475
|
+
};
|
|
7476
|
+
const markdownContent = result.markdown;
|
|
7477
|
+
let finalFilename = filename;
|
|
7478
|
+
if (!finalFilename && url) {
|
|
7479
|
+
finalFilename = this.generateFilenameFromUrl(url);
|
|
7432
7480
|
}
|
|
7433
|
-
const
|
|
7481
|
+
const savedPath = await saveContentToFile(markdownContent, save_path, save_directory, finalFilename);
|
|
7482
|
+
yield {
|
|
7483
|
+
type: "progress",
|
|
7484
|
+
progress: 100,
|
|
7485
|
+
message: "ファイルの保存が完了しました。"
|
|
7486
|
+
};
|
|
7487
|
+
const responseText = `URL successfully converted to Markdown and saved to: ${savedPath}`;
|
|
7434
7488
|
yield {
|
|
7435
7489
|
type: "result",
|
|
7436
|
-
result: {
|
|
7490
|
+
result: {
|
|
7491
|
+
content: [
|
|
7492
|
+
{
|
|
7493
|
+
type: "text",
|
|
7494
|
+
text: responseText
|
|
7495
|
+
}
|
|
7496
|
+
],
|
|
7497
|
+
isError: false
|
|
7498
|
+
}
|
|
7437
7499
|
};
|
|
7438
7500
|
} catch (error) {
|
|
7439
7501
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -7445,11 +7507,30 @@ ${savedPaths.map((path) => `- ${path}`).join("\n")}`;
|
|
|
7445
7507
|
type: "text",
|
|
7446
7508
|
text: `エラーが発生しました: ${errorMessage}`
|
|
7447
7509
|
}
|
|
7448
|
-
]
|
|
7510
|
+
],
|
|
7511
|
+
isError: true
|
|
7449
7512
|
}
|
|
7450
7513
|
};
|
|
7451
7514
|
}
|
|
7452
7515
|
}
|
|
7516
|
+
/**
|
|
7517
|
+
* Generate filename from URL.
|
|
7518
|
+
* URL からファイル名を生成
|
|
7519
|
+
*/
|
|
7520
|
+
generateFilenameFromUrl(url) {
|
|
7521
|
+
try {
|
|
7522
|
+
const urlObj = new URL(url);
|
|
7523
|
+
let filename = urlObj.pathname.split("/").pop() || "page";
|
|
7524
|
+
filename = filename.replace(/\.[^.]*$/, "");
|
|
7525
|
+
filename = filename.replace(/[<>:"/\\|?*]/g, "_");
|
|
7526
|
+
if (!filename || filename.match(/^\.+$/)) {
|
|
7527
|
+
filename = "page";
|
|
7528
|
+
}
|
|
7529
|
+
return filename;
|
|
7530
|
+
} catch {
|
|
7531
|
+
return "page";
|
|
7532
|
+
}
|
|
7533
|
+
}
|
|
7453
7534
|
/**
|
|
7454
7535
|
* Start the streamable MCP server.
|
|
7455
7536
|
* streamable MCP サーバーを開始
|
package/dist/mcp-streamable.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";require("./mcp-server-streamable-
|
|
2
|
+
"use strict";require("./mcp-server-streamable-BNn6Kd9b.cjs").runStreamableMcpServer().catch(e=>{process.exit(1)});
|
package/dist/mcp-streamable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { r as runStreamableMcpServer } from "./mcp-server-streamable-
|
|
2
|
+
import { r as runStreamableMcpServer } from "./mcp-server-streamable-CcZ7Lsel.js";
|
|
3
3
|
runStreamableMcpServer().catch((error) => {
|
|
4
4
|
console.error("Failed to start streamable MCP server:", error);
|
|
5
5
|
process.exit(1);
|
package/dist/mcp.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const e=new(require("happy-dom").Window);Object.assign(global,{document:e.document,window:e,self:e});require("./mcp-server-
|
|
2
|
+
const e=new(require("happy-dom").Window);Object.assign(global,{document:e.document,window:e,self:e});require("./mcp-server-Co1kuNGX.cjs").runMcpServer().catch(e=>{process.exit(1)});
|
package/dist/mcp.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.assign(global, {
|
|
|
6
6
|
window,
|
|
7
7
|
self: window
|
|
8
8
|
});
|
|
9
|
-
import { r as runMcpServer } from "./mcp-server-
|
|
9
|
+
import { r as runMcpServer } from "./mcp-server-DzB_5cTs.js";
|
|
10
10
|
runMcpServer().catch((error) => {
|
|
11
11
|
console.error("Failed to start MCP server:", error);
|
|
12
12
|
process.exit(1);
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Arguments for HTML to Markdown conversion tool.
|
|
4
|
+
* HTML から Markdown への変換ツールの引数
|
|
5
|
+
*/
|
|
6
|
+
export interface HtmlToMarkdownArgs {
|
|
7
|
+
url?: string;
|
|
8
|
+
html_content?: string;
|
|
9
|
+
locale?: "en-US" | "ja-JP";
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Arguments for file saving tool.
|
|
13
|
+
* ファイル保存ツールの引数
|
|
14
|
+
*/
|
|
15
|
+
export interface SaveContentArgs {
|
|
16
|
+
content: string;
|
|
17
|
+
save_path?: string;
|
|
18
|
+
save_directory?: string;
|
|
19
|
+
filename?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Arguments for URL to Markdown file conversion tool.
|
|
23
|
+
* URL から Markdown ファイルへの変換ツールの引数
|
|
24
|
+
*/
|
|
25
|
+
export interface UrlToMarkdownFileArgs {
|
|
26
|
+
url?: string;
|
|
27
|
+
html_content?: string;
|
|
28
|
+
locale?: "en-US" | "ja-JP";
|
|
29
|
+
save_path?: string;
|
|
30
|
+
save_directory?: string;
|
|
31
|
+
filename?: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Validate and parse arguments for HTML to Markdown conversion.
|
|
35
|
+
* HTML から Markdown への変換の引数を検証・解析
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseHtmlToMarkdownArgs(args: HtmlToMarkdownArgs | undefined): HtmlToMarkdownArgs;
|
|
38
|
+
/**
|
|
39
|
+
* Validate and parse arguments for content saving.
|
|
40
|
+
* コンテンツ保存の引数を検証・解析
|
|
41
|
+
*/
|
|
42
|
+
export declare function parseSaveContentArgs(args: SaveContentArgs | undefined): SaveContentArgs;
|
|
43
|
+
/**
|
|
44
|
+
* Validate and parse arguments for URL to Markdown file conversion.
|
|
45
|
+
* URL から Markdown ファイルへの変換の引数を検証・解析
|
|
46
|
+
*/
|
|
47
|
+
export declare function parseUrlToMarkdownFileArgs(args: UrlToMarkdownFileArgs | undefined): UrlToMarkdownFileArgs;
|
|
48
|
+
/**
|
|
49
|
+
* Generate filename from URL or use default.
|
|
50
|
+
* URL からファイル名を生成または既定値を使用
|
|
51
|
+
*/
|
|
52
|
+
export declare function generateFilename(url?: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Save content to file and return the saved path.
|
|
55
|
+
* コンテンツをファイルに保存し、保存したパスを返す
|
|
56
|
+
*/
|
|
57
|
+
export declare function saveContentToFile(content: string, savePath?: string, saveDirectory?: string, filename?: string): Promise<string>;
|
|
58
|
+
/**
|
|
59
|
+
* Tool schema definitions for MCP servers.
|
|
60
|
+
* MCP サーバー用のツールスキーマ定義
|
|
61
|
+
*/
|
|
62
|
+
export declare const MCP_TOOL_SCHEMAS: {
|
|
63
|
+
htmlToMarkdown: {
|
|
64
|
+
readonly type: "object";
|
|
65
|
+
readonly properties: {
|
|
66
|
+
readonly url: {
|
|
67
|
+
readonly type: "string";
|
|
68
|
+
readonly description: "URL of the web page to convert (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively.";
|
|
69
|
+
};
|
|
70
|
+
readonly html_content: {
|
|
71
|
+
readonly type: "string";
|
|
72
|
+
readonly description: "HTML string to convert directly. Use instead of URL for local files or API response HTML content.";
|
|
73
|
+
};
|
|
74
|
+
readonly locale: {
|
|
75
|
+
readonly type: "string";
|
|
76
|
+
readonly description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.";
|
|
77
|
+
readonly enum: readonly ["en-US", "ja-JP"];
|
|
78
|
+
readonly default: "en-US";
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
readonly anyOf: readonly [{
|
|
82
|
+
readonly required: readonly ["url"];
|
|
83
|
+
}, {
|
|
84
|
+
readonly required: readonly ["html_content"];
|
|
85
|
+
}];
|
|
86
|
+
};
|
|
87
|
+
saveContentToFile: {
|
|
88
|
+
readonly type: "object";
|
|
89
|
+
readonly properties: {
|
|
90
|
+
readonly content: {
|
|
91
|
+
readonly type: "string";
|
|
92
|
+
readonly description: "Text content to save to file. Will be saved as Markdown format.";
|
|
93
|
+
};
|
|
94
|
+
readonly save_path: {
|
|
95
|
+
readonly type: "string";
|
|
96
|
+
readonly description: "Complete file path including filename to save content (e.g., '/home/user/output.md'). Cannot be used with save_directory.";
|
|
97
|
+
};
|
|
98
|
+
readonly save_directory: {
|
|
99
|
+
readonly type: "string";
|
|
100
|
+
readonly description: "Directory path to save content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path.";
|
|
101
|
+
};
|
|
102
|
+
readonly filename: {
|
|
103
|
+
readonly type: "string";
|
|
104
|
+
readonly description: "Base filename to use when save_directory is specified (e.g., 'my-document'). Extension .md will be added automatically.";
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
readonly required: readonly ["content"];
|
|
108
|
+
readonly anyOf: readonly [{
|
|
109
|
+
readonly required: readonly ["save_path"];
|
|
110
|
+
}, {
|
|
111
|
+
readonly required: readonly ["save_directory"];
|
|
112
|
+
}];
|
|
113
|
+
};
|
|
114
|
+
urlToMarkdownFile: {
|
|
115
|
+
readonly type: "object";
|
|
116
|
+
readonly properties: {
|
|
117
|
+
readonly url: {
|
|
118
|
+
readonly type: "string";
|
|
119
|
+
readonly description: "URL of the web page to convert and save as Markdown file (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively.";
|
|
120
|
+
};
|
|
121
|
+
readonly html_content: {
|
|
122
|
+
readonly type: "string";
|
|
123
|
+
readonly description: "HTML string to convert directly and save as Markdown file. Use instead of URL for local files or API response HTML content.";
|
|
124
|
+
};
|
|
125
|
+
readonly locale: {
|
|
126
|
+
readonly type: "string";
|
|
127
|
+
readonly description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.";
|
|
128
|
+
readonly enum: readonly ["en-US", "ja-JP"];
|
|
129
|
+
readonly default: "en-US";
|
|
130
|
+
};
|
|
131
|
+
readonly save_path: {
|
|
132
|
+
readonly type: "string";
|
|
133
|
+
readonly description: "Complete file path including filename to save the converted Markdown content (e.g., '/home/user/output.md'). Cannot be used with save_directory.";
|
|
134
|
+
};
|
|
135
|
+
readonly save_directory: {
|
|
136
|
+
readonly type: "string";
|
|
137
|
+
readonly description: "Directory path to save the converted Markdown content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path.";
|
|
138
|
+
};
|
|
139
|
+
readonly filename: {
|
|
140
|
+
readonly type: "string";
|
|
141
|
+
readonly description: "Base filename to use when save_directory is specified (e.g., 'my-document'). Extension .md will be added automatically.";
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
readonly anyOf: readonly [{
|
|
145
|
+
readonly required: readonly ["url", "save_path"];
|
|
146
|
+
}, {
|
|
147
|
+
readonly required: readonly ["url", "save_directory"];
|
|
148
|
+
}, {
|
|
149
|
+
readonly required: readonly ["html_content", "save_path"];
|
|
150
|
+
}, {
|
|
151
|
+
readonly required: readonly ["html_content", "save_directory"];
|
|
152
|
+
}];
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Common error handling utility for MCP tools.
|
|
157
|
+
* MCP ツール用の共通エラーハンドリングユーティリティ
|
|
158
|
+
*/
|
|
159
|
+
export declare function createErrorResult(error: unknown): CallToolResult;
|
|
160
|
+
/**
|
|
161
|
+
* Common success result utility for MCP tools.
|
|
162
|
+
* MCP ツール用の共通成功結果ユーティリティ
|
|
163
|
+
*/
|
|
164
|
+
export declare function createSuccessResult(text: string): CallToolResult;
|