@aiquants/html-to-markdown 0.3.0 → 0.5.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 +123 -4
- package/dist/{core-CouDTni-.js → core-DJV8t_Qj.js} +8 -4
- package/dist/core-Dq4LfiYy.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/main.cjs +1 -1
- package/dist/main.js +30 -13
- package/dist/mcp-server-CMBUHOmc.cjs +1 -0
- package/dist/{mcp-server-BAmy7d8r.js → mcp-server-DD8CqdNw.js} +59 -2
- package/dist/{mcp-server-streamable-CVDJHcWu.js → mcp-server-streamable-DODolSbj.js} +127 -3
- package/dist/{mcp-server-streamable-mF26pg3E.cjs → mcp-server-streamable-IQlimU2H.cjs} +1 -1
- 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/index.d.ts +1 -1
- package/dist/src/mcp-common.d.ts +57 -0
- package/dist/src/mcp-server-streamable.d.ts +15 -2
- package/dist/src/mcp-server.d.ts +79 -2
- package/dist/src/types.d.ts +6 -6
- package/dist/{version-Cg6D6H9g.cjs → version-BkgGdAYt.cjs} +1 -1
- package/dist/{version-BF9-U8Ef.js → version-CTdrYd1G.js} +81 -7
- package/mcp.json +2 -2
- package/package.json +1 -1
- package/dist/core-D2dlEt1l.cjs +0 -1
- package/dist/mcp-server-CCu0Pcm3.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-IQlimU2H.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-DODolSbj.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-CMBUHOmc.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-DD8CqdNw.js";
|
|
10
10
|
runMcpServer().catch((error) => {
|
|
11
11
|
console.error("Failed to start MCP server:", error);
|
|
12
12
|
process.exit(1);
|
package/dist/src/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { htmlToMarkdown } from './core.ts';
|
|
6
6
|
export { getMessage } from './i18n.ts';
|
|
7
|
-
export type { HtmlToMarkdownOptions } from './types.ts';
|
|
8
7
|
export { createMcpServer, runMcpServer } from './mcp-server.ts';
|
|
9
8
|
export { createStreamableMcpServer, runStreamableMcpServer } from './mcp-server-streamable.ts';
|
|
9
|
+
export type { HtmlToMarkdownOptions } from './types.ts';
|
package/dist/src/mcp-common.d.ts
CHANGED
|
@@ -18,6 +18,18 @@ export interface SaveContentArgs {
|
|
|
18
18
|
save_directory?: string;
|
|
19
19
|
filename?: string;
|
|
20
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
|
+
}
|
|
21
33
|
/**
|
|
22
34
|
* Validate and parse arguments for HTML to Markdown conversion.
|
|
23
35
|
* HTML から Markdown への変換の引数を検証・解析
|
|
@@ -28,6 +40,11 @@ export declare function parseHtmlToMarkdownArgs(args: HtmlToMarkdownArgs | undef
|
|
|
28
40
|
* コンテンツ保存の引数を検証・解析
|
|
29
41
|
*/
|
|
30
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;
|
|
31
48
|
/**
|
|
32
49
|
* Generate filename from URL or use default.
|
|
33
50
|
* URL からファイル名を生成または既定値を使用
|
|
@@ -94,6 +111,46 @@ export declare const MCP_TOOL_SCHEMAS: {
|
|
|
94
111
|
readonly required: readonly ["save_directory"];
|
|
95
112
|
}];
|
|
96
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
|
+
};
|
|
97
154
|
};
|
|
98
155
|
/**
|
|
99
156
|
* Common error handling utility for MCP tools.
|
|
@@ -1,6 +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
|
+
import { HtmlToMarkdownArgs, SaveContentArgs, UrlToMarkdownFileArgs } from './mcp-common.ts';
|
|
4
4
|
/**
|
|
5
5
|
* The context for a tool call.
|
|
6
6
|
* ツール呼び出しのコンテキスト
|
|
@@ -13,7 +13,7 @@ export type ToolContext<T = unknown> = {
|
|
|
13
13
|
* ハンドラー関数を含む拡張 Tool インターフェース
|
|
14
14
|
*/
|
|
15
15
|
interface ExtendedTool extends Tool {
|
|
16
|
-
handler: (args: HtmlToMarkdownArgs | SaveContentArgs, context: ToolContext<HtmlToMarkdownArgs | SaveContentArgs>) => AsyncGenerator<Progress | {
|
|
16
|
+
handler: (args: HtmlToMarkdownArgs | SaveContentArgs | UrlToMarkdownFileArgs, context: ToolContext<HtmlToMarkdownArgs | SaveContentArgs | UrlToMarkdownFileArgs>) => AsyncGenerator<Progress | {
|
|
17
17
|
type: "result";
|
|
18
18
|
result: CallToolResult;
|
|
19
19
|
}>;
|
|
@@ -54,6 +54,19 @@ export declare class StreamableHtmlToMarkdownMcpServer {
|
|
|
54
54
|
type: "result";
|
|
55
55
|
result: CallToolResult;
|
|
56
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;
|
|
57
70
|
/**
|
|
58
71
|
* Start the streamable MCP server.
|
|
59
72
|
* streamable MCP サーバーを開始
|
package/dist/src/mcp-server.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
-
import { HtmlToMarkdownArgs, SaveContentArgs } from './mcp-common.ts';
|
|
3
|
-
export {
|
|
2
|
+
import { HtmlToMarkdownArgs, SaveContentArgs, UrlToMarkdownFileArgs } from './mcp-common.ts';
|
|
3
|
+
export { createErrorResult, createSuccessResult, type HtmlToMarkdownArgs, MCP_TOOL_SCHEMAS, parseHtmlToMarkdownArgs, parseSaveContentArgs, parseUrlToMarkdownFileArgs, type SaveContentArgs, saveContentToFile, type UrlToMarkdownFileArgs, } from './mcp-common.ts';
|
|
4
4
|
/**
|
|
5
5
|
* MCP Server for HTML to Markdown conversion.
|
|
6
6
|
* HTML から Markdown への変換を行う MCP サーバー
|
|
@@ -158,6 +158,83 @@ export declare class HtmlToMarkdownMcpServer {
|
|
|
158
158
|
} | undefined;
|
|
159
159
|
isError?: boolean | undefined;
|
|
160
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;
|
|
161
238
|
/**
|
|
162
239
|
* Start the MCP server.
|
|
163
240
|
* MCP サーバーを開始
|
package/dist/src/types.d.ts
CHANGED
|
@@ -20,16 +20,16 @@ export interface HtmlToMarkdownOptions {
|
|
|
20
20
|
*/
|
|
21
21
|
htmlContent?: string;
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Message keys for i18n.
|
|
25
|
-
* i18n 用のメッセージキー
|
|
26
|
-
*/
|
|
27
|
-
export type MessageKey = "error_url_required" | "usage" | "example" | "cli_start" | "cli_url" | "cli_locale" | "cli_output" | "success_save" | "success_path" | "error_app" | "playwright_launch" | "playwright_goto" | "playwright_get_content" | "playwright_close" | "playwright_error" | "convert_start" | "convert_success" | "url_parse_error";
|
|
28
23
|
/**
|
|
29
24
|
* Supported locales.
|
|
30
25
|
* サポートされているロケール
|
|
31
26
|
*/
|
|
32
|
-
export type SupportedLocale = "
|
|
27
|
+
export type SupportedLocale = "en-US" | "ja-JP";
|
|
28
|
+
/**
|
|
29
|
+
* Message keys for i18n.
|
|
30
|
+
* i18n 用のメッセージキー
|
|
31
|
+
*/
|
|
32
|
+
export type MessageKey = "error_url_required" | "error_url_or_html_required" | "usage" | "example" | "cli_start" | "cli_url" | "cli_html_content" | "cli_locale" | "cli_output" | "success_save" | "success_path" | "error_app" | "playwright_launch" | "playwright_goto" | "playwright_get_content" | "playwright_close" | "playwright_error" | "convert_start" | "convert_success" | "url_parse_error";
|
|
33
33
|
/**
|
|
34
34
|
* The following types are based on the type definitions of `hast-util-to-mdast`.
|
|
35
35
|
* `hast-util-to-mdast` の型定義に基づいた型。
|