@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,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, UrlToMarkdownFileArgs } 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 | UrlToMarkdownFileArgs, context: ToolContext<HtmlToMarkdownArgs | SaveContentArgs | UrlToMarkdownFileArgs>) => AsyncGenerator<Progress | {
|
|
28
17
|
type: "result";
|
|
29
18
|
result: CallToolResult;
|
|
30
19
|
}>;
|
|
@@ -57,6 +46,27 @@ 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
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Handle URL to Markdown file conversion tool call with streamable support.
|
|
59
|
+
* streamable サポート付きの URL から Markdown ファイルへの変換ツール呼び出しを処理
|
|
60
|
+
*/
|
|
61
|
+
handleUrlToMarkdownFile(args: UrlToMarkdownFileArgs, _context: ToolContext<UrlToMarkdownFileArgs>): AsyncGenerator<Progress | {
|
|
62
|
+
type: "result";
|
|
63
|
+
result: CallToolResult;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Generate filename from URL.
|
|
67
|
+
* URL からファイル名を生成
|
|
68
|
+
*/
|
|
69
|
+
private generateFilenameFromUrl;
|
|
60
70
|
/**
|
|
61
71
|
* Start the streamable MCP server.
|
|
62
72
|
* 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, UrlToMarkdownFileArgs } from './mcp-common.ts';
|
|
3
|
+
export { type HtmlToMarkdownArgs, type SaveContentArgs, type UrlToMarkdownFileArgs, parseHtmlToMarkdownArgs, parseSaveContentArgs, parseUrlToMarkdownFileArgs, 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,12 +19,222 @@ 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;
|
|
39
25
|
text: string;
|
|
40
|
-
|
|
41
|
-
|
|
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;
|
|
42
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;
|
|
97
|
+
text: string;
|
|
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;
|
|
160
|
+
}>;
|
|
161
|
+
/**
|
|
162
|
+
* Handle URL to Markdown file conversion tool call.
|
|
163
|
+
* URL から Markdown ファイルへの変換ツール呼び出しを処理
|
|
164
|
+
*/
|
|
165
|
+
handleUrlToMarkdownFile(args: UrlToMarkdownFileArgs | undefined): Promise<{
|
|
166
|
+
[x: string]: unknown;
|
|
167
|
+
content: ({
|
|
168
|
+
[x: string]: unknown;
|
|
169
|
+
text: string;
|
|
170
|
+
type: "text";
|
|
171
|
+
_meta?: {
|
|
172
|
+
[x: string]: unknown;
|
|
173
|
+
} | undefined;
|
|
174
|
+
} | {
|
|
175
|
+
[x: string]: unknown;
|
|
176
|
+
type: "image";
|
|
177
|
+
data: string;
|
|
178
|
+
mimeType: string;
|
|
179
|
+
_meta?: {
|
|
180
|
+
[x: string]: unknown;
|
|
181
|
+
} | undefined;
|
|
182
|
+
} | {
|
|
183
|
+
[x: string]: unknown;
|
|
184
|
+
type: "audio";
|
|
185
|
+
data: string;
|
|
186
|
+
mimeType: string;
|
|
187
|
+
_meta?: {
|
|
188
|
+
[x: string]: unknown;
|
|
189
|
+
} | undefined;
|
|
190
|
+
} | {
|
|
191
|
+
[x: string]: unknown;
|
|
192
|
+
type: "resource_link";
|
|
193
|
+
name: string;
|
|
194
|
+
uri: string;
|
|
195
|
+
title?: string | undefined;
|
|
196
|
+
_meta?: {
|
|
197
|
+
[x: string]: unknown;
|
|
198
|
+
} | undefined;
|
|
199
|
+
mimeType?: string | undefined;
|
|
200
|
+
description?: string | undefined;
|
|
201
|
+
} | {
|
|
202
|
+
[x: string]: unknown;
|
|
203
|
+
type: "resource";
|
|
204
|
+
resource: {
|
|
205
|
+
[x: string]: unknown;
|
|
206
|
+
text: string;
|
|
207
|
+
uri: string;
|
|
208
|
+
_meta?: {
|
|
209
|
+
[x: string]: unknown;
|
|
210
|
+
} | undefined;
|
|
211
|
+
mimeType?: string | undefined;
|
|
212
|
+
} | {
|
|
213
|
+
[x: string]: unknown;
|
|
214
|
+
uri: string;
|
|
215
|
+
blob: string;
|
|
216
|
+
_meta?: {
|
|
217
|
+
[x: string]: unknown;
|
|
218
|
+
} | undefined;
|
|
219
|
+
mimeType?: string | undefined;
|
|
220
|
+
};
|
|
221
|
+
_meta?: {
|
|
222
|
+
[x: string]: unknown;
|
|
223
|
+
} | undefined;
|
|
224
|
+
})[];
|
|
225
|
+
_meta?: {
|
|
226
|
+
[x: string]: unknown;
|
|
227
|
+
} | undefined;
|
|
228
|
+
structuredContent?: {
|
|
229
|
+
[x: string]: unknown;
|
|
230
|
+
} | undefined;
|
|
231
|
+
isError?: boolean | undefined;
|
|
232
|
+
}>;
|
|
233
|
+
/**
|
|
234
|
+
* Generate filename from URL.
|
|
235
|
+
* URL からファイル名を生成
|
|
236
|
+
*/
|
|
237
|
+
private generateFilenameFromUrl;
|
|
43
238
|
/**
|
|
44
239
|
* Start the MCP server.
|
|
45
240
|
* MCP サーバーを開始
|
|
@@ -56,4 +251,3 @@ export declare const createMcpServer: () => HtmlToMarkdownMcpServer;
|
|
|
56
251
|
* MCP サーバーを実行するメイン関数
|
|
57
252
|
*/
|
|
58
253
|
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,223 @@ 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 parseUrlToMarkdownFileArgs(args) {
|
|
11349
|
+
if (!args || typeof args !== "object") {
|
|
11350
|
+
throw new Error("Arguments are required");
|
|
11351
|
+
}
|
|
11352
|
+
const { url, html_content, locale = "en-US", save_path, save_directory, filename } = args;
|
|
11353
|
+
if (!url && !html_content) {
|
|
11354
|
+
throw new Error("Either 'url' or 'html_content' is required");
|
|
11355
|
+
}
|
|
11356
|
+
if (url && typeof url !== "string") {
|
|
11357
|
+
throw new Error("'url' must be a string");
|
|
11358
|
+
}
|
|
11359
|
+
if (html_content && typeof html_content !== "string") {
|
|
11360
|
+
throw new Error("'html_content' must be a string");
|
|
11361
|
+
}
|
|
11362
|
+
if (locale && !["en-US", "ja-JP"].includes(locale)) {
|
|
11363
|
+
throw new Error("'locale' must be 'en-US' or 'ja-JP'");
|
|
11364
|
+
}
|
|
11365
|
+
if (!save_path && !save_directory) {
|
|
11366
|
+
throw new Error("Either 'save_path' or 'save_directory' is required");
|
|
11367
|
+
}
|
|
11368
|
+
if (save_path && typeof save_path !== "string") {
|
|
11369
|
+
throw new Error("'save_path' must be a string");
|
|
11370
|
+
}
|
|
11371
|
+
if (save_directory && typeof save_directory !== "string") {
|
|
11372
|
+
throw new Error("'save_directory' must be a string");
|
|
11373
|
+
}
|
|
11374
|
+
if (filename && typeof filename !== "string") {
|
|
11375
|
+
throw new Error("'filename' must be a string");
|
|
11376
|
+
}
|
|
11377
|
+
if (save_path && save_directory) {
|
|
11378
|
+
throw new Error("Cannot specify both 'save_path' and 'save_directory'");
|
|
11379
|
+
}
|
|
11380
|
+
return {
|
|
11381
|
+
url,
|
|
11382
|
+
html_content,
|
|
11383
|
+
locale,
|
|
11384
|
+
save_path,
|
|
11385
|
+
save_directory,
|
|
11386
|
+
filename
|
|
11387
|
+
};
|
|
11388
|
+
}
|
|
11389
|
+
function generateFilename(url) {
|
|
11390
|
+
return "page";
|
|
11391
|
+
}
|
|
11392
|
+
async function saveContentToFile(content, savePath, saveDirectory, filename) {
|
|
11393
|
+
let finalPath;
|
|
11394
|
+
if (savePath) {
|
|
11395
|
+
finalPath = resolve(savePath);
|
|
11396
|
+
} else if (saveDirectory) {
|
|
11397
|
+
const baseFilename = filename || generateFilename();
|
|
11398
|
+
const extension = ".md";
|
|
11399
|
+
finalPath = resolve(saveDirectory, `${baseFilename}${extension}`);
|
|
11400
|
+
} else {
|
|
11401
|
+
throw new Error("Either save_path or save_directory must be specified");
|
|
11402
|
+
}
|
|
11403
|
+
await promises.mkdir(dirname(finalPath), { recursive: true });
|
|
11404
|
+
await promises.writeFile(finalPath, content, "utf-8");
|
|
11405
|
+
return finalPath;
|
|
11406
|
+
}
|
|
11407
|
+
const MCP_TOOL_SCHEMAS = {
|
|
11408
|
+
htmlToMarkdown: {
|
|
11409
|
+
type: "object",
|
|
11410
|
+
properties: {
|
|
11411
|
+
url: {
|
|
11412
|
+
type: "string",
|
|
11413
|
+
description: "URL of the web page to convert (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively."
|
|
11414
|
+
},
|
|
11415
|
+
html_content: {
|
|
11416
|
+
type: "string",
|
|
11417
|
+
description: "HTML string to convert directly. Use instead of URL for local files or API response HTML content."
|
|
11418
|
+
},
|
|
11419
|
+
locale: {
|
|
11420
|
+
type: "string",
|
|
11421
|
+
description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.",
|
|
11422
|
+
enum: ["en-US", "ja-JP"],
|
|
11423
|
+
default: "en-US"
|
|
11424
|
+
}
|
|
11425
|
+
},
|
|
11426
|
+
anyOf: [{ required: ["url"] }, { required: ["html_content"] }]
|
|
11427
|
+
},
|
|
11428
|
+
saveContentToFile: {
|
|
11429
|
+
type: "object",
|
|
11430
|
+
properties: {
|
|
11431
|
+
content: {
|
|
11432
|
+
type: "string",
|
|
11433
|
+
description: "Text content to save to file. Will be saved as Markdown format."
|
|
11434
|
+
},
|
|
11435
|
+
save_path: {
|
|
11436
|
+
type: "string",
|
|
11437
|
+
description: "Complete file path including filename to save content (e.g., '/home/user/output.md'). Cannot be used with save_directory."
|
|
11438
|
+
},
|
|
11439
|
+
save_directory: {
|
|
11440
|
+
type: "string",
|
|
11441
|
+
description: "Directory path to save content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path."
|
|
11442
|
+
},
|
|
11443
|
+
filename: {
|
|
11444
|
+
type: "string",
|
|
11445
|
+
description: "Base filename to use when save_directory is specified (e.g., 'my-document'). Extension .md will be added automatically."
|
|
11446
|
+
}
|
|
11447
|
+
},
|
|
11448
|
+
required: ["content"],
|
|
11449
|
+
anyOf: [{ required: ["save_path"] }, { required: ["save_directory"] }]
|
|
11450
|
+
},
|
|
11451
|
+
urlToMarkdownFile: {
|
|
11452
|
+
type: "object",
|
|
11453
|
+
properties: {
|
|
11454
|
+
url: {
|
|
11455
|
+
type: "string",
|
|
11456
|
+
description: "URL of the web page to convert and save as Markdown file (e.g., https://example.com). Handles JavaScript-rendered dynamic content effectively."
|
|
11457
|
+
},
|
|
11458
|
+
html_content: {
|
|
11459
|
+
type: "string",
|
|
11460
|
+
description: "HTML string to convert directly and save as Markdown file. Use instead of URL for local files or API response HTML content."
|
|
11461
|
+
},
|
|
11462
|
+
locale: {
|
|
11463
|
+
type: "string",
|
|
11464
|
+
description: "Browser locale setting. Use 'ja-JP' for Japanese sites, 'en-US' for English sites. Affects content rendering and language detection.",
|
|
11465
|
+
enum: ["en-US", "ja-JP"],
|
|
11466
|
+
default: "en-US"
|
|
11467
|
+
},
|
|
11468
|
+
save_path: {
|
|
11469
|
+
type: "string",
|
|
11470
|
+
description: "Complete file path including filename to save the converted Markdown content (e.g., '/home/user/output.md'). Cannot be used with save_directory."
|
|
11471
|
+
},
|
|
11472
|
+
save_directory: {
|
|
11473
|
+
type: "string",
|
|
11474
|
+
description: "Directory path to save the converted Markdown content with auto-generated filename (e.g., '/home/user/downloads'). Cannot be used with save_path."
|
|
11475
|
+
},
|
|
11476
|
+
filename: {
|
|
11477
|
+
type: "string",
|
|
11478
|
+
description: "Base filename to use when save_directory is specified (e.g., 'my-document'). Extension .md will be added automatically."
|
|
11479
|
+
}
|
|
11480
|
+
},
|
|
11481
|
+
anyOf: [{ required: ["url", "save_path"] }, { required: ["url", "save_directory"] }, { required: ["html_content", "save_path"] }, { required: ["html_content", "save_directory"] }]
|
|
11482
|
+
}
|
|
11483
|
+
};
|
|
11484
|
+
function createErrorResult(error) {
|
|
11485
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
11486
|
+
return {
|
|
11487
|
+
content: [
|
|
11488
|
+
{
|
|
11489
|
+
type: "text",
|
|
11490
|
+
text: `Error: ${errorMessage}`
|
|
11491
|
+
}
|
|
11492
|
+
],
|
|
11493
|
+
isError: true
|
|
11494
|
+
};
|
|
11495
|
+
}
|
|
11496
|
+
function createSuccessResult(text) {
|
|
11497
|
+
return {
|
|
11498
|
+
content: [
|
|
11499
|
+
{
|
|
11500
|
+
type: "text",
|
|
11501
|
+
text
|
|
11502
|
+
}
|
|
11503
|
+
],
|
|
11504
|
+
isError: false
|
|
11505
|
+
};
|
|
11506
|
+
}
|
|
11293
11507
|
const getPackageVersion = () => {
|
|
11294
11508
|
try {
|
|
11295
11509
|
const __filename = fileURLToPath(import.meta.url);
|
|
11296
|
-
const __dirname = dirname(__filename);
|
|
11297
|
-
const packageJsonPath = resolve(__dirname, "../package.json");
|
|
11510
|
+
const __dirname = dirname$1(__filename);
|
|
11511
|
+
const packageJsonPath = resolve$1(__dirname, "../package.json");
|
|
11298
11512
|
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
11299
11513
|
return packageJson.version || "0.0.0";
|
|
11300
11514
|
} catch (error) {
|
|
@@ -11308,11 +11522,18 @@ export {
|
|
|
11308
11522
|
InitializeRequestSchema as I,
|
|
11309
11523
|
JSONRPCMessageSchema as J,
|
|
11310
11524
|
ListToolsRequestSchema as L,
|
|
11525
|
+
MCP_TOOL_SCHEMAS as M,
|
|
11311
11526
|
Server as S,
|
|
11312
|
-
|
|
11313
|
-
|
|
11314
|
-
|
|
11315
|
-
|
|
11527
|
+
createErrorResult as a,
|
|
11528
|
+
parseSaveContentArgs as b,
|
|
11529
|
+
createSuccessResult as c,
|
|
11530
|
+
parseUrlToMarkdownFileArgs as d,
|
|
11531
|
+
isJSONRPCRequest as e,
|
|
11532
|
+
SUPPORTED_PROTOCOL_VERSIONS as f,
|
|
11316
11533
|
getPackageVersion as g,
|
|
11317
|
-
|
|
11534
|
+
isJSONRPCResponse as h,
|
|
11535
|
+
isInitializeRequest as i,
|
|
11536
|
+
isJSONRPCError as j,
|
|
11537
|
+
parseHtmlToMarkdownArgs as p,
|
|
11538
|
+
saveContentToFile as s
|
|
11318
11539
|
};
|