@aiquants/html-to-markdown 0.2.6 → 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/README.md +10 -8
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/dist/mcp-server-BAmy7d8r.js +210 -0
- package/dist/mcp-server-CCu0Pcm3.cjs +1 -0
- package/dist/{mcp-server-streamable-3B3B1fuS.js → mcp-server-streamable-CVDJHcWu.js} +101 -144
- package/dist/mcp-server-streamable-mF26pg3E.cjs +1 -0
- 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 +107 -0
- package/dist/src/mcp-server-streamable.d.ts +10 -13
- package/dist/src/mcp-server.d.ts +139 -22
- package/dist/{version-PCzxchJe.js → version-BF9-U8Ef.js} +155 -8
- package/dist/version-Cg6D6H9g.cjs +1 -0
- package/mcp.json +3 -3
- 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
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-mF26pg3E.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-CVDJHcWu.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-CCu0Pcm3.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-BAmy7d8r.js";
|
|
10
10
|
runMcpServer().catch((error) => {
|
|
11
11
|
console.error("Failed to start MCP server:", error);
|
|
12
12
|
process.exit(1);
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
* Validate and parse arguments for HTML to Markdown conversion.
|
|
23
|
+
* HTML から Markdown への変換の引数を検証・解析
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseHtmlToMarkdownArgs(args: HtmlToMarkdownArgs | undefined): HtmlToMarkdownArgs;
|
|
26
|
+
/**
|
|
27
|
+
* Validate and parse arguments for content saving.
|
|
28
|
+
* コンテンツ保存の引数を検証・解析
|
|
29
|
+
*/
|
|
30
|
+
export declare function parseSaveContentArgs(args: SaveContentArgs | undefined): SaveContentArgs;
|
|
31
|
+
/**
|
|
32
|
+
* Generate filename from URL or use default.
|
|
33
|
+
* URL からファイル名を生成または既定値を使用
|
|
34
|
+
*/
|
|
35
|
+
export declare function generateFilename(url?: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Save content to file and return the saved path.
|
|
38
|
+
* コンテンツをファイルに保存し、保存したパスを返す
|
|
39
|
+
*/
|
|
40
|
+
export declare function saveContentToFile(content: string, savePath?: string, saveDirectory?: string, filename?: string): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Tool schema definitions for MCP servers.
|
|
43
|
+
* MCP サーバー用のツールスキーマ定義
|
|
44
|
+
*/
|
|
45
|
+
export declare const MCP_TOOL_SCHEMAS: {
|
|
46
|
+
htmlToMarkdown: {
|
|
47
|
+
readonly type: "object";
|
|
48
|
+
readonly properties: {
|
|
49
|
+
readonly url: {
|
|
50
|
+
readonly type: "string";
|
|
51
|
+
readonly description: "URL of the web page to convert (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively.";
|
|
52
|
+
};
|
|
53
|
+
readonly html_content: {
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
readonly description: "HTML string to convert directly. Use instead of URL for local files or API response HTML content.";
|
|
56
|
+
};
|
|
57
|
+
readonly locale: {
|
|
58
|
+
readonly type: "string";
|
|
59
|
+
readonly description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.";
|
|
60
|
+
readonly enum: readonly ["en-US", "ja-JP"];
|
|
61
|
+
readonly default: "en-US";
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
readonly anyOf: readonly [{
|
|
65
|
+
readonly required: readonly ["url"];
|
|
66
|
+
}, {
|
|
67
|
+
readonly required: readonly ["html_content"];
|
|
68
|
+
}];
|
|
69
|
+
};
|
|
70
|
+
saveContentToFile: {
|
|
71
|
+
readonly type: "object";
|
|
72
|
+
readonly properties: {
|
|
73
|
+
readonly content: {
|
|
74
|
+
readonly type: "string";
|
|
75
|
+
readonly description: "Text content to save to file. Will be saved as Markdown format.";
|
|
76
|
+
};
|
|
77
|
+
readonly save_path: {
|
|
78
|
+
readonly type: "string";
|
|
79
|
+
readonly description: "Complete file path including filename to save content (e.g., '/home/user/output.md'). Cannot be used with save_directory.";
|
|
80
|
+
};
|
|
81
|
+
readonly save_directory: {
|
|
82
|
+
readonly type: "string";
|
|
83
|
+
readonly description: "Directory path to save content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path.";
|
|
84
|
+
};
|
|
85
|
+
readonly filename: {
|
|
86
|
+
readonly type: "string";
|
|
87
|
+
readonly description: "Base filename to use when save_directory is specified (e.g., 'my-document'). Extension .md will be added automatically.";
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
readonly required: readonly ["content"];
|
|
91
|
+
readonly anyOf: readonly [{
|
|
92
|
+
readonly required: readonly ["save_path"];
|
|
93
|
+
}, {
|
|
94
|
+
readonly required: readonly ["save_directory"];
|
|
95
|
+
}];
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Common error handling utility for MCP tools.
|
|
100
|
+
* MCP ツール用の共通エラーハンドリングユーティリティ
|
|
101
|
+
*/
|
|
102
|
+
export declare function createErrorResult(error: unknown): CallToolResult;
|
|
103
|
+
/**
|
|
104
|
+
* Common success result utility for MCP tools.
|
|
105
|
+
* MCP ツール用の共通成功結果ユーティリティ
|
|
106
|
+
*/
|
|
107
|
+
export declare function createSuccessResult(text: string): CallToolResult;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import { CallToolResult, Progress, Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
import { HtmlToMarkdownArgs, SaveContentArgs } from './mcp-common.ts';
|
|
3
4
|
/**
|
|
4
5
|
* The context for a tool call.
|
|
5
6
|
* ツール呼び出しのコンテキスト
|
|
@@ -7,24 +8,12 @@ import { CallToolResult, Progress, Tool } from '@modelcontextprotocol/sdk/types.
|
|
|
7
8
|
export type ToolContext<T = unknown> = {
|
|
8
9
|
[toolName: string]: T;
|
|
9
10
|
};
|
|
10
|
-
/**
|
|
11
|
-
* Arguments for HTML to Markdown conversion tool.
|
|
12
|
-
* HTML から Markdown への変換ツールの引数
|
|
13
|
-
*/
|
|
14
|
-
interface HtmlToMarkdownArgs {
|
|
15
|
-
url?: string;
|
|
16
|
-
html_content?: string;
|
|
17
|
-
locale?: "en-US" | "ja-JP";
|
|
18
|
-
output_format?: "markdown" | "html" | "both";
|
|
19
|
-
save_path?: string;
|
|
20
|
-
save_directory?: string;
|
|
21
|
-
}
|
|
22
11
|
/**
|
|
23
12
|
* Extended Tool interface with handler function.
|
|
24
13
|
* ハンドラー関数を含む拡張 Tool インターフェース
|
|
25
14
|
*/
|
|
26
15
|
interface ExtendedTool extends Tool {
|
|
27
|
-
handler: (args: HtmlToMarkdownArgs, context: ToolContext<HtmlToMarkdownArgs>) => AsyncGenerator<Progress | {
|
|
16
|
+
handler: (args: HtmlToMarkdownArgs | SaveContentArgs, context: ToolContext<HtmlToMarkdownArgs | SaveContentArgs>) => AsyncGenerator<Progress | {
|
|
28
17
|
type: "result";
|
|
29
18
|
result: CallToolResult;
|
|
30
19
|
}>;
|
|
@@ -57,6 +46,14 @@ export declare class StreamableHtmlToMarkdownMcpServer {
|
|
|
57
46
|
type: "result";
|
|
58
47
|
result: CallToolResult;
|
|
59
48
|
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Handle save content to file tool call with streamable support.
|
|
51
|
+
* streamable サポート付きのファイル保存ツール呼び出しを処理
|
|
52
|
+
*/
|
|
53
|
+
handleSaveContentToFile(args: SaveContentArgs, _context: ToolContext<SaveContentArgs>): AsyncGenerator<Progress | {
|
|
54
|
+
type: "result";
|
|
55
|
+
result: CallToolResult;
|
|
56
|
+
}>;
|
|
60
57
|
/**
|
|
61
58
|
* Start the streamable MCP server.
|
|
62
59
|
* streamable MCP サーバーを開始
|
package/dist/src/mcp-server.d.ts
CHANGED
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* HTML から Markdown への変換ツールの引数
|
|
5
|
-
*/
|
|
6
|
-
interface HtmlToMarkdownArgs {
|
|
7
|
-
url?: string;
|
|
8
|
-
html_content?: string;
|
|
9
|
-
locale?: "en-US" | "ja-JP";
|
|
10
|
-
output_format?: "markdown" | "html" | "both";
|
|
11
|
-
save_path?: string;
|
|
12
|
-
save_directory?: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Validate and parse arguments for HTML to Markdown conversion.
|
|
16
|
-
* HTML から Markdown への変換の引数を検証・解析
|
|
17
|
-
*/
|
|
18
|
-
export declare function parseHtmlToMarkdownArgs(args: HtmlToMarkdownArgs | undefined): HtmlToMarkdownArgs;
|
|
2
|
+
import { HtmlToMarkdownArgs, SaveContentArgs } from './mcp-common.ts';
|
|
3
|
+
export { type HtmlToMarkdownArgs, type SaveContentArgs, parseHtmlToMarkdownArgs, parseSaveContentArgs, saveContentToFile, createErrorResult, createSuccessResult, MCP_TOOL_SCHEMAS, } from './mcp-common.ts';
|
|
19
4
|
/**
|
|
20
5
|
* MCP Server for HTML to Markdown conversion.
|
|
21
6
|
* HTML から Markdown への変換を行う MCP サーバー
|
|
@@ -34,11 +19,144 @@ export declare class HtmlToMarkdownMcpServer {
|
|
|
34
19
|
* HTML から Markdown への変換ツール呼び出しを処理
|
|
35
20
|
*/
|
|
36
21
|
handleHtmlToMarkdown(args: HtmlToMarkdownArgs | undefined): Promise<{
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
[x: string]: unknown;
|
|
23
|
+
content: ({
|
|
24
|
+
[x: string]: unknown;
|
|
25
|
+
text: string;
|
|
26
|
+
type: "text";
|
|
27
|
+
_meta?: {
|
|
28
|
+
[x: string]: unknown;
|
|
29
|
+
} | undefined;
|
|
30
|
+
} | {
|
|
31
|
+
[x: string]: unknown;
|
|
32
|
+
type: "image";
|
|
33
|
+
data: string;
|
|
34
|
+
mimeType: string;
|
|
35
|
+
_meta?: {
|
|
36
|
+
[x: string]: unknown;
|
|
37
|
+
} | undefined;
|
|
38
|
+
} | {
|
|
39
|
+
[x: string]: unknown;
|
|
40
|
+
type: "audio";
|
|
41
|
+
data: string;
|
|
42
|
+
mimeType: string;
|
|
43
|
+
_meta?: {
|
|
44
|
+
[x: string]: unknown;
|
|
45
|
+
} | undefined;
|
|
46
|
+
} | {
|
|
47
|
+
[x: string]: unknown;
|
|
48
|
+
type: "resource_link";
|
|
49
|
+
name: string;
|
|
50
|
+
uri: string;
|
|
51
|
+
title?: string | undefined;
|
|
52
|
+
_meta?: {
|
|
53
|
+
[x: string]: unknown;
|
|
54
|
+
} | undefined;
|
|
55
|
+
mimeType?: string | undefined;
|
|
56
|
+
description?: string | undefined;
|
|
57
|
+
} | {
|
|
58
|
+
[x: string]: unknown;
|
|
59
|
+
type: "resource";
|
|
60
|
+
resource: {
|
|
61
|
+
[x: string]: unknown;
|
|
62
|
+
text: string;
|
|
63
|
+
uri: string;
|
|
64
|
+
_meta?: {
|
|
65
|
+
[x: string]: unknown;
|
|
66
|
+
} | undefined;
|
|
67
|
+
mimeType?: string | undefined;
|
|
68
|
+
} | {
|
|
69
|
+
[x: string]: unknown;
|
|
70
|
+
uri: string;
|
|
71
|
+
blob: string;
|
|
72
|
+
_meta?: {
|
|
73
|
+
[x: string]: unknown;
|
|
74
|
+
} | undefined;
|
|
75
|
+
mimeType?: string | undefined;
|
|
76
|
+
};
|
|
77
|
+
_meta?: {
|
|
78
|
+
[x: string]: unknown;
|
|
79
|
+
} | undefined;
|
|
80
|
+
})[];
|
|
81
|
+
_meta?: {
|
|
82
|
+
[x: string]: unknown;
|
|
83
|
+
} | undefined;
|
|
84
|
+
structuredContent?: {
|
|
85
|
+
[x: string]: unknown;
|
|
86
|
+
} | undefined;
|
|
87
|
+
isError?: boolean | undefined;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Handle save content to file tool call.
|
|
91
|
+
* ファイル保存ツール呼び出しを処理
|
|
92
|
+
*/
|
|
93
|
+
handleSaveContentToFile(args: SaveContentArgs | undefined): Promise<{
|
|
94
|
+
[x: string]: unknown;
|
|
95
|
+
content: ({
|
|
96
|
+
[x: string]: unknown;
|
|
39
97
|
text: string;
|
|
40
|
-
|
|
41
|
-
|
|
98
|
+
type: "text";
|
|
99
|
+
_meta?: {
|
|
100
|
+
[x: string]: unknown;
|
|
101
|
+
} | undefined;
|
|
102
|
+
} | {
|
|
103
|
+
[x: string]: unknown;
|
|
104
|
+
type: "image";
|
|
105
|
+
data: string;
|
|
106
|
+
mimeType: string;
|
|
107
|
+
_meta?: {
|
|
108
|
+
[x: string]: unknown;
|
|
109
|
+
} | undefined;
|
|
110
|
+
} | {
|
|
111
|
+
[x: string]: unknown;
|
|
112
|
+
type: "audio";
|
|
113
|
+
data: string;
|
|
114
|
+
mimeType: string;
|
|
115
|
+
_meta?: {
|
|
116
|
+
[x: string]: unknown;
|
|
117
|
+
} | undefined;
|
|
118
|
+
} | {
|
|
119
|
+
[x: string]: unknown;
|
|
120
|
+
type: "resource_link";
|
|
121
|
+
name: string;
|
|
122
|
+
uri: string;
|
|
123
|
+
title?: string | undefined;
|
|
124
|
+
_meta?: {
|
|
125
|
+
[x: string]: unknown;
|
|
126
|
+
} | undefined;
|
|
127
|
+
mimeType?: string | undefined;
|
|
128
|
+
description?: string | undefined;
|
|
129
|
+
} | {
|
|
130
|
+
[x: string]: unknown;
|
|
131
|
+
type: "resource";
|
|
132
|
+
resource: {
|
|
133
|
+
[x: string]: unknown;
|
|
134
|
+
text: string;
|
|
135
|
+
uri: string;
|
|
136
|
+
_meta?: {
|
|
137
|
+
[x: string]: unknown;
|
|
138
|
+
} | undefined;
|
|
139
|
+
mimeType?: string | undefined;
|
|
140
|
+
} | {
|
|
141
|
+
[x: string]: unknown;
|
|
142
|
+
uri: string;
|
|
143
|
+
blob: string;
|
|
144
|
+
_meta?: {
|
|
145
|
+
[x: string]: unknown;
|
|
146
|
+
} | undefined;
|
|
147
|
+
mimeType?: string | undefined;
|
|
148
|
+
};
|
|
149
|
+
_meta?: {
|
|
150
|
+
[x: string]: unknown;
|
|
151
|
+
} | undefined;
|
|
152
|
+
})[];
|
|
153
|
+
_meta?: {
|
|
154
|
+
[x: string]: unknown;
|
|
155
|
+
} | undefined;
|
|
156
|
+
structuredContent?: {
|
|
157
|
+
[x: string]: unknown;
|
|
158
|
+
} | undefined;
|
|
159
|
+
isError?: boolean | undefined;
|
|
42
160
|
}>;
|
|
43
161
|
/**
|
|
44
162
|
* Start the MCP server.
|
|
@@ -56,4 +174,3 @@ export declare const createMcpServer: () => HtmlToMarkdownMcpServer;
|
|
|
56
174
|
* MCP サーバーを実行するメイン関数
|
|
57
175
|
*/
|
|
58
176
|
export declare const runMcpServer: () => Promise<void>;
|
|
59
|
-
export {};
|
|
@@ -6,8 +6,10 @@ Object.assign(global, {
|
|
|
6
6
|
self: window
|
|
7
7
|
});
|
|
8
8
|
import { b as getDefaultExportFromCjs } from "./core-CouDTni-.js";
|
|
9
|
+
import { promises } from "fs";
|
|
10
|
+
import { resolve, dirname } from "path";
|
|
9
11
|
import { readFileSync } from "node:fs";
|
|
10
|
-
import { dirname, resolve } from "node:path";
|
|
12
|
+
import { dirname as dirname$1, resolve as resolve$1 } from "node:path";
|
|
11
13
|
import { fileURLToPath } from "node:url";
|
|
12
14
|
var util$1;
|
|
13
15
|
(function(util2) {
|
|
@@ -11290,11 +11292,150 @@ class Server extends Protocol {
|
|
|
11290
11292
|
return this.notification({ method: "notifications/prompts/list_changed" });
|
|
11291
11293
|
}
|
|
11292
11294
|
}
|
|
11295
|
+
function parseHtmlToMarkdownArgs(args) {
|
|
11296
|
+
if (!args || typeof args !== "object") {
|
|
11297
|
+
throw new Error("Arguments are required");
|
|
11298
|
+
}
|
|
11299
|
+
const { url, html_content, locale = "en-US" } = args;
|
|
11300
|
+
if (!url && !html_content) {
|
|
11301
|
+
throw new Error("Either 'url' or 'html_content' is required");
|
|
11302
|
+
}
|
|
11303
|
+
if (url && typeof url !== "string") {
|
|
11304
|
+
throw new Error("'url' must be a string");
|
|
11305
|
+
}
|
|
11306
|
+
if (html_content && typeof html_content !== "string") {
|
|
11307
|
+
throw new Error("'html_content' must be a string");
|
|
11308
|
+
}
|
|
11309
|
+
if (locale && !["en-US", "ja-JP"].includes(locale)) {
|
|
11310
|
+
throw new Error("'locale' must be 'en-US' or 'ja-JP'");
|
|
11311
|
+
}
|
|
11312
|
+
return {
|
|
11313
|
+
url,
|
|
11314
|
+
html_content,
|
|
11315
|
+
locale
|
|
11316
|
+
};
|
|
11317
|
+
}
|
|
11318
|
+
function parseSaveContentArgs(args) {
|
|
11319
|
+
if (!args || typeof args !== "object") {
|
|
11320
|
+
throw new Error("Arguments are required");
|
|
11321
|
+
}
|
|
11322
|
+
const { content, save_path, save_directory, filename } = args;
|
|
11323
|
+
if (!content || typeof content !== "string") {
|
|
11324
|
+
throw new Error("'content' is required and must be a string");
|
|
11325
|
+
}
|
|
11326
|
+
if (!save_path && !save_directory) {
|
|
11327
|
+
throw new Error("Either 'save_path' or 'save_directory' is required");
|
|
11328
|
+
}
|
|
11329
|
+
if (save_path && typeof save_path !== "string") {
|
|
11330
|
+
throw new Error("'save_path' must be a string");
|
|
11331
|
+
}
|
|
11332
|
+
if (save_directory && typeof save_directory !== "string") {
|
|
11333
|
+
throw new Error("'save_directory' must be a string");
|
|
11334
|
+
}
|
|
11335
|
+
if (filename && typeof filename !== "string") {
|
|
11336
|
+
throw new Error("'filename' must be a string");
|
|
11337
|
+
}
|
|
11338
|
+
if (save_path && save_directory) {
|
|
11339
|
+
throw new Error("Cannot specify both 'save_path' and 'save_directory'");
|
|
11340
|
+
}
|
|
11341
|
+
return {
|
|
11342
|
+
content,
|
|
11343
|
+
save_path,
|
|
11344
|
+
save_directory,
|
|
11345
|
+
filename
|
|
11346
|
+
};
|
|
11347
|
+
}
|
|
11348
|
+
function generateFilename(url) {
|
|
11349
|
+
return "page";
|
|
11350
|
+
}
|
|
11351
|
+
async function saveContentToFile(content, savePath, saveDirectory, filename) {
|
|
11352
|
+
let finalPath;
|
|
11353
|
+
if (savePath) {
|
|
11354
|
+
finalPath = resolve(savePath);
|
|
11355
|
+
} else if (saveDirectory) {
|
|
11356
|
+
const baseFilename = filename || generateFilename();
|
|
11357
|
+
const extension = ".md";
|
|
11358
|
+
finalPath = resolve(saveDirectory, `${baseFilename}${extension}`);
|
|
11359
|
+
} else {
|
|
11360
|
+
throw new Error("Either save_path or save_directory must be specified");
|
|
11361
|
+
}
|
|
11362
|
+
await promises.mkdir(dirname(finalPath), { recursive: true });
|
|
11363
|
+
await promises.writeFile(finalPath, content, "utf-8");
|
|
11364
|
+
return finalPath;
|
|
11365
|
+
}
|
|
11366
|
+
const MCP_TOOL_SCHEMAS = {
|
|
11367
|
+
htmlToMarkdown: {
|
|
11368
|
+
type: "object",
|
|
11369
|
+
properties: {
|
|
11370
|
+
url: {
|
|
11371
|
+
type: "string",
|
|
11372
|
+
description: "URL of the web page to convert (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively."
|
|
11373
|
+
},
|
|
11374
|
+
html_content: {
|
|
11375
|
+
type: "string",
|
|
11376
|
+
description: "HTML string to convert directly. Use instead of URL for local files or API response HTML content."
|
|
11377
|
+
},
|
|
11378
|
+
locale: {
|
|
11379
|
+
type: "string",
|
|
11380
|
+
description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.",
|
|
11381
|
+
enum: ["en-US", "ja-JP"],
|
|
11382
|
+
default: "en-US"
|
|
11383
|
+
}
|
|
11384
|
+
},
|
|
11385
|
+
anyOf: [{ required: ["url"] }, { required: ["html_content"] }]
|
|
11386
|
+
},
|
|
11387
|
+
saveContentToFile: {
|
|
11388
|
+
type: "object",
|
|
11389
|
+
properties: {
|
|
11390
|
+
content: {
|
|
11391
|
+
type: "string",
|
|
11392
|
+
description: "Text content to save to file. Will be saved as Markdown format."
|
|
11393
|
+
},
|
|
11394
|
+
save_path: {
|
|
11395
|
+
type: "string",
|
|
11396
|
+
description: "Complete file path including filename to save content (e.g., '/home/user/output.md'). Cannot be used with save_directory."
|
|
11397
|
+
},
|
|
11398
|
+
save_directory: {
|
|
11399
|
+
type: "string",
|
|
11400
|
+
description: "Directory path to save content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path."
|
|
11401
|
+
},
|
|
11402
|
+
filename: {
|
|
11403
|
+
type: "string",
|
|
11404
|
+
description: "Base filename to use when save_directory is specified (e.g., 'my-document'). Extension .md will be added automatically."
|
|
11405
|
+
}
|
|
11406
|
+
},
|
|
11407
|
+
required: ["content"],
|
|
11408
|
+
anyOf: [{ required: ["save_path"] }, { required: ["save_directory"] }]
|
|
11409
|
+
}
|
|
11410
|
+
};
|
|
11411
|
+
function createErrorResult(error) {
|
|
11412
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
11413
|
+
return {
|
|
11414
|
+
content: [
|
|
11415
|
+
{
|
|
11416
|
+
type: "text",
|
|
11417
|
+
text: `Error: ${errorMessage}`
|
|
11418
|
+
}
|
|
11419
|
+
],
|
|
11420
|
+
isError: true
|
|
11421
|
+
};
|
|
11422
|
+
}
|
|
11423
|
+
function createSuccessResult(text) {
|
|
11424
|
+
return {
|
|
11425
|
+
content: [
|
|
11426
|
+
{
|
|
11427
|
+
type: "text",
|
|
11428
|
+
text
|
|
11429
|
+
}
|
|
11430
|
+
],
|
|
11431
|
+
isError: false
|
|
11432
|
+
};
|
|
11433
|
+
}
|
|
11293
11434
|
const getPackageVersion = () => {
|
|
11294
11435
|
try {
|
|
11295
11436
|
const __filename = fileURLToPath(import.meta.url);
|
|
11296
|
-
const __dirname = dirname(__filename);
|
|
11297
|
-
const packageJsonPath = resolve(__dirname, "../package.json");
|
|
11437
|
+
const __dirname = dirname$1(__filename);
|
|
11438
|
+
const packageJsonPath = resolve$1(__dirname, "../package.json");
|
|
11298
11439
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
11299
11440
|
return packageJson.version || "0.0.0";
|
|
11300
11441
|
} catch (error) {
|
|
@@ -11308,11 +11449,17 @@ export {
|
|
|
11308
11449
|
InitializeRequestSchema as I,
|
|
11309
11450
|
JSONRPCMessageSchema as J,
|
|
11310
11451
|
ListToolsRequestSchema as L,
|
|
11452
|
+
MCP_TOOL_SCHEMAS as M,
|
|
11311
11453
|
Server as S,
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11454
|
+
createErrorResult as a,
|
|
11455
|
+
parseSaveContentArgs as b,
|
|
11456
|
+
createSuccessResult as c,
|
|
11457
|
+
isJSONRPCRequest as d,
|
|
11458
|
+
SUPPORTED_PROTOCOL_VERSIONS as e,
|
|
11459
|
+
isJSONRPCResponse as f,
|
|
11316
11460
|
getPackageVersion as g,
|
|
11317
|
-
|
|
11461
|
+
isJSONRPCError as h,
|
|
11462
|
+
isInitializeRequest as i,
|
|
11463
|
+
parseHtmlToMarkdownArgs as p,
|
|
11464
|
+
saveContentToFile as s
|
|
11318
11465
|
};
|