@aiquants/html-to-markdown 0.1.4 → 0.1.6

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.
Files changed (60) hide show
  1. package/README.md +100 -18
  2. package/dist/{core-CVMYjtlI.cjs → core-D2dlEt1l.cjs} +1 -1
  3. package/dist/{core-DOzMLPij.js → core-DU_246Q7.js} +52 -14
  4. package/dist/index.cjs +1 -1
  5. package/dist/index.js +8 -2
  6. package/dist/main.cjs +1 -1
  7. package/dist/main.js +1 -1
  8. package/dist/mcp-server-CpmnW1p8.js +283 -0
  9. package/dist/mcp-server-D4Mj1IQ9.cjs +1 -0
  10. package/dist/mcp-server-streamable-Bu7QAr3W.cjs +1 -0
  11. package/dist/mcp-server-streamable-CQD5zK30.js +7538 -0
  12. package/dist/mcp-streamable.cjs +2 -0
  13. package/dist/mcp-streamable.js +6 -0
  14. package/dist/mcp.cjs +2 -0
  15. package/dist/mcp.js +13 -0
  16. package/dist/src/core.d.ts +4 -4
  17. package/dist/src/index.d.ts +2 -0
  18. package/dist/src/mcp-server-streamable.d.ts +74 -0
  19. package/dist/src/mcp-server.d.ts +57 -0
  20. package/dist/src/mcp-streamable.d.ts +6 -0
  21. package/dist/src/mcp.d.ts +6 -0
  22. package/dist/src/types.d.ts +5 -0
  23. package/dist/src/version.d.ts +9 -0
  24. package/dist/tests/core-unified.test.d.ts +5 -0
  25. package/dist/tests/coverage-complete.test.d.ts +5 -0
  26. package/dist/tests/mcp-unified.test.d.ts +5 -0
  27. package/dist/tests/plugins-unified.test.d.ts +5 -0
  28. package/dist/tests/test-client.d.ts +4 -0
  29. package/dist/version-BRVBmpor.js +11318 -0
  30. package/dist/version-DTaUKNBS.cjs +1 -0
  31. package/mcp.json +14 -0
  32. package/package.json +27 -10
  33. package/dist/tests/100-percent-final.test.d.ts +0 -1
  34. package/dist/tests/absolute-final-coverage.test.d.ts +0 -1
  35. package/dist/tests/browser-100.test.d.ts +0 -1
  36. package/dist/tests/browser-coverage.test.d.ts +0 -1
  37. package/dist/tests/browser.test.d.ts +0 -1
  38. package/dist/tests/cli.test.d.ts +0 -1
  39. package/dist/tests/converter-coverage.test.d.ts +0 -1
  40. package/dist/tests/converter.test.d.ts +0 -1
  41. package/dist/tests/core.test.d.ts +0 -1
  42. package/dist/tests/coverage-edge-cases.test.d.ts +0 -1
  43. package/dist/tests/direct-coverage.test.d.ts +0 -1
  44. package/dist/tests/final-100-percent.test.d.ts +0 -1
  45. package/dist/tests/final-coverage.test.d.ts +0 -1
  46. package/dist/tests/i18n.test.d.ts +0 -1
  47. package/dist/tests/index.test.d.ts +0 -1
  48. package/dist/tests/line-70-coverage.test.d.ts +0 -1
  49. package/dist/tests/main.test.d.ts +0 -1
  50. package/dist/tests/plugins.test.d.ts +0 -1
  51. package/dist/tests/readme-usage.test.d.ts +0 -1
  52. package/dist/tests/rehype-absolute-links-coverage.test.d.ts +0 -1
  53. package/dist/tests/rehype-absolute-links.test.d.ts +0 -1
  54. package/dist/tests/rehype-named-anchors.test.d.ts +0 -1
  55. package/dist/tests/rehype-sanitize-html-coverage.test.d.ts +0 -1
  56. package/dist/tests/rehype-sanitize-html.test.d.ts +0 -1
  57. package/dist/tests/rehype-wikipedia-footnotes.test.d.ts +0 -1
  58. package/dist/tests/types.test.d.ts +0 -1
  59. package/dist/tests/ultimate-coverage.test.d.ts +0 -1
  60. /package/dist/tests/{100-percent-coverage.test.d.ts → entry-points-error.test.d.ts} +0 -0
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @aiquants/html-to-markdown
2
2
 
3
- A tool to dynamically fetch a web page from a given URL and convert it to Markdown.
3
+ A tool to dynamically fetch a web page from a given URL and convert it to Markdown. Now with Model Context Protocol (MCP) server support!
4
4
 
5
5
  This tool fetches the fully rendered HTML after JavaScript execution and converts it to Markdown. It supports complex pages, including footnotes and table structures.
6
6
 
@@ -10,7 +10,9 @@ This tool fetches the fully rendered HTML after JavaScript execution and convert
10
10
  - **High-Fidelity Conversion**: Performs powerful AST (Abstract Syntax Tree)-based conversion using `rehype` and `remark`.
11
11
  - **Preserves Table Content**: Retains HTML tags within table cells (`<td>`, `<th>`) as much as possible to maintain rich formatting.
12
12
  - **Link Normalization**: Automatically converts relative links on the page to absolute links to prevent broken links.
13
- - **Dual Interface**: Usable as both a Node.js library and a command-line tool.
13
+ - **Multiple Interfaces**: Usable as a Node.js library, command-line tool, and MCP server.
14
+ - **MCP Server Support**: Provides Model Context Protocol server functionality for AI assistants.
15
+ - **Streamable MCP Support**: Supports streamable MCP protocols for real-time progress updates.
14
16
 
15
17
  ## Installation
16
18
 
@@ -73,6 +75,83 @@ async function main() {
73
75
  main();
74
76
  ```
75
77
 
78
+ ### As an MCP Server
79
+
80
+ This package can be used as a Model Context Protocol (MCP) server, allowing AI assistants and MCP-compatible applications to convert web pages to Markdown.
81
+
82
+ #### MCP Server Configuration
83
+
84
+ **For VS Code with MCP extension, add to your `mcp.json`:**
85
+
86
+ ```json
87
+ {
88
+ "html-to-md": {
89
+ "command": "npx",
90
+ "args": [
91
+ "aiq-html2md-mcp"
92
+ ],
93
+ "type": "stdio"
94
+ },
95
+ "html-to-md-streamable": {
96
+ "url": "http://127.0.0.1:4001/mcp",
97
+ "type": "http",
98
+ "_comment": "Note: You need to start the streamable MCP server separately using 'npx aiq-html2md-mcp-stream'"
99
+ }
100
+ }
101
+ ```
102
+
103
+ **For Claude Desktop or other MCP clients, add to your configuration file:**
104
+
105
+ ```json
106
+ {
107
+ "mcpServers": {
108
+ "html-to-markdown": {
109
+ "command": "npx",
110
+ "args": ["aiq-html2md-mcp"],
111
+ "description": "Convert HTML content from URLs to Markdown format"
112
+ }
113
+ }
114
+ }
115
+ ```
116
+
117
+ **Note:** The streamable MCP server runs as an HTTP server on port 4001 and needs to be started separately:
118
+
119
+ ```bash
120
+ # Start the streamable MCP server (requires global installation)
121
+ npm install -g @aiquants/html-to-markdown
122
+ aiq-html2md-mcp-stream
123
+ ```
124
+
125
+ Alternatively, you can use npx to run without global installation:
126
+
127
+ ```bash
128
+ # Using npx with the streamable server binary
129
+ npx aiq-html2md-mcp-stream
130
+ ```
131
+
132
+ #### MCP Tools Available
133
+
134
+ - **html_to_markdown**: Convert HTML content from a URL to Markdown format
135
+ - `url` (required): The URL of the web page to convert
136
+ - `locale` (optional): Browser locale (`en-US` or `ja-JP`, defaults to `en-US`)
137
+ - `output_format` (optional): Output format (`markdown`, `html`, or `both`, defaults to `markdown`)
138
+
139
+ - **html_to_markdown_streamable**: Same as above but with streamable MCP support for progress updates
140
+
141
+ ### Using MCP Server Programmatically
142
+
143
+ ```typescript
144
+ import { createMcpServer, createStreamableMcpServer } from '@aiquants/html-to-markdown';
145
+
146
+ // Create standard MCP server
147
+ const mcpServer = createMcpServer();
148
+ await mcpServer.start(8000); // Port 8000
149
+
150
+ // Create streamable MCP server
151
+ const streamableMcpServer = createStreamableMcpServer();
152
+ await streamableMcpServer.start(8000); // Port 8000
153
+ ```
154
+
76
155
  ## API
77
156
 
78
157
  ### `htmlToMarkdown(url, options?)`
@@ -113,22 +192,25 @@ This tool follows these steps for conversion:
113
192
 
114
193
  This project is built upon the following open-source software. We are grateful to the developers of these libraries.
115
194
 
116
- | Package | License |
117
- | ------------------------ | ---------- |
118
- | github-slugger | MIT |
119
- | happy-dom | MIT |
120
- | hast | MIT |
121
- | hast-util-to-html | MIT |
122
- | playwright | Apache-2.0 |
123
- | rehype-parse | MIT |
124
- | rehype-raw | MIT |
125
- | rehype-remark | MIT |
126
- | rehype-slug | MIT |
127
- | remark-gfm | MIT |
128
- | remark-stringify | MIT |
129
- | unified | MIT |
130
- | unist-util-visit | MIT |
131
- | yargs-parser | ISC |
195
+ | Package | License |
196
+ | -------------------------- | ---------- |
197
+ | @modelcontextprotocol/sdk | MIT |
198
+ | cors | MIT |
199
+ | express | MIT |
200
+ | github-slugger | ISC |
201
+ | happy-dom | MIT |
202
+ | hast | MIT |
203
+ | hast-util-to-html | MIT |
204
+ | playwright | Apache-2.0 |
205
+ | rehype-parse | MIT |
206
+ | rehype-raw | MIT |
207
+ | rehype-remark | MIT |
208
+ | rehype-slug | MIT |
209
+ | remark-gfm | MIT |
210
+ | remark-stringify | MIT |
211
+ | unified | MIT |
212
+ | unist-util-visit | MIT |
213
+ | yargs-parser | ISC |
132
214
 
133
215
  *This list is generated based on the `dependencies` in `package.json`. For the most accurate and up-to-date license information, please refer to the individual packages.*
134
216