@pipeworx/mcp-markdown 0.1.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/LICENSE +21 -0
- package/README.md +58 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +97 -0
- package/tsconfig.json +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pipeworx
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# mcp-markdown
|
|
2
|
+
|
|
3
|
+
Markdown utilities MCP.
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 1170+ live data sources.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
| `markdown_to_text` | Convert Markdown to readable plain text (keyless, offline): strips headings, emphasis, code fences, and turns links/images into their text/alt. Ideal for de-formatting Markdown. |
|
|
12
|
+
| `extract_links` | Extract all Markdown links [text](url) (and bare autolinks) as {text, url} pairs (keyless, offline). |
|
|
13
|
+
| `extract_headings` | Extract the ATX heading outline (# … ######) as {level, text} entries (keyless, offline). |
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"mcpServers": {
|
|
22
|
+
"markdown": {
|
|
23
|
+
"url": "https://gateway.pipeworx.io/markdown/mcp"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or connect to the full Pipeworx gateway for access to all 1170+ data sources:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"mcpServers": {
|
|
34
|
+
"pipeworx": {
|
|
35
|
+
"url": "https://gateway.pipeworx.io/mcp"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Using with ask_pipeworx
|
|
42
|
+
|
|
43
|
+
Instead of calling tools directly, you can ask questions in plain English:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
ask_pipeworx({ question: "your question about Markdown data" })
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The gateway picks the right tool and fills the arguments automatically.
|
|
50
|
+
|
|
51
|
+
## More
|
|
52
|
+
|
|
53
|
+
- [All tools and guides](https://github.com/pipeworx-io/examples)
|
|
54
|
+
- [pipeworx.io](https://pipeworx.io)
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-markdown",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Markdown utilities MCP.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "markdown"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-markdown"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"typecheck": "tsc --noEmit"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"typescript": "^5.7.0"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.pipeworx-io/markdown",
|
|
4
|
+
"title": "Markdown",
|
|
5
|
+
"description": "Markdown utilities MCP.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/markdown",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-markdown",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/markdown/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
interface McpToolDefinition {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: 'object';
|
|
6
|
+
properties: Record<string, unknown>;
|
|
7
|
+
required?: string[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface McpToolExport {
|
|
12
|
+
tools: McpToolDefinition[];
|
|
13
|
+
callTool: (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
14
|
+
meter?: { credits: number };
|
|
15
|
+
cost?: Record<string, unknown>;
|
|
16
|
+
provider?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Markdown utilities MCP.
|
|
21
|
+
*
|
|
22
|
+
* Keyless, offline: convert Markdown to readable plain text, extract links, and
|
|
23
|
+
* extract the heading outline. Regex-based (not a full CommonMark parser) — good
|
|
24
|
+
* for cleaning Markdown before feeding it to a model. No API, no key.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function toText(md: string): string {
|
|
29
|
+
return md
|
|
30
|
+
.replace(/```[\s\S]*?```/g, (b) => b.replace(/```[^\n]*\n?/g, '').replace(/```/g, ''))
|
|
31
|
+
.replace(/`([^`]+)`/g, '$1')
|
|
32
|
+
.replace(/!\[([^\]]*)\]\([^)]*\)/g, '$1')
|
|
33
|
+
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1')
|
|
34
|
+
.replace(/^\s{0,3}#{1,6}\s+/gm, '')
|
|
35
|
+
.replace(/^\s{0,3}>\s?/gm, '')
|
|
36
|
+
.replace(/^\s*([-*+]|\d+\.)\s+/gm, '• ')
|
|
37
|
+
.replace(/^\s*([-*_]\s*){3,}\s*$/gm, '')
|
|
38
|
+
.replace(/(\*\*|__)(.*?)\1/g, '$2')
|
|
39
|
+
.replace(/(\*|_)(.*?)\1/g, '$2')
|
|
40
|
+
.replace(/~~(.*?)~~/g, '$1')
|
|
41
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
42
|
+
.trim();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const tools: McpToolExport['tools'] = [
|
|
46
|
+
{
|
|
47
|
+
name: 'markdown_to_text',
|
|
48
|
+
description: 'Convert Markdown to readable plain text (keyless, offline): strips headings, emphasis, code fences, and turns links/images into their text/alt. Ideal for de-formatting Markdown.',
|
|
49
|
+
inputSchema: { type: 'object', properties: { markdown: { type: 'string', description: 'The Markdown text.' } }, required: ['markdown'] },
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'extract_links',
|
|
53
|
+
description: 'Extract all Markdown links [text](url) (and bare autolinks) as {text, url} pairs (keyless, offline).',
|
|
54
|
+
inputSchema: { type: 'object', properties: { markdown: { type: 'string', description: 'The Markdown text.' } }, required: ['markdown'] },
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'extract_headings',
|
|
58
|
+
description: 'Extract the ATX heading outline (# … ######) as {level, text} entries (keyless, offline).',
|
|
59
|
+
inputSchema: { type: 'object', properties: { markdown: { type: 'string', description: 'The Markdown text.' } }, required: ['markdown'] },
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
64
|
+
const md = reqStr(args, 'markdown', '"# Title\\nHello"');
|
|
65
|
+
switch (name) {
|
|
66
|
+
case 'markdown_to_text': {
|
|
67
|
+
const text = toText(md);
|
|
68
|
+
return { text, length: text.length };
|
|
69
|
+
}
|
|
70
|
+
case 'extract_links': {
|
|
71
|
+
const links: { text: string; url: string }[] = [];
|
|
72
|
+
const re = /\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)/g;
|
|
73
|
+
let m; while ((m = re.exec(md)) && links.length < 500) links.push({ text: m[1], url: m[2] });
|
|
74
|
+
const auto = /<((?:https?|mailto):[^>]+)>/g;
|
|
75
|
+
while ((m = auto.exec(md)) && links.length < 500) links.push({ text: m[1], url: m[1] });
|
|
76
|
+
return { count: links.length, links };
|
|
77
|
+
}
|
|
78
|
+
case 'extract_headings': {
|
|
79
|
+
const headings: { level: number; text: string }[] = [];
|
|
80
|
+
for (const line of md.split('\n')) {
|
|
81
|
+
const m = line.match(/^\s{0,3}(#{1,6})\s+(.+?)\s*#*\s*$/);
|
|
82
|
+
if (m) headings.push({ level: m[1].length, text: m[2].trim() });
|
|
83
|
+
}
|
|
84
|
+
return { count: headings.length, headings };
|
|
85
|
+
}
|
|
86
|
+
default:
|
|
87
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function reqStr(args: Record<string, unknown>, key: string, ex: string): string {
|
|
92
|
+
const v = args[key];
|
|
93
|
+
if (typeof v !== 'string' || !v.length) throw new Error(`Required argument "${key}" is missing. Pass a string like ${ex}.`);
|
|
94
|
+
return v;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default { tools, callTool, meter: { credits: 1 } } satisfies McpToolExport;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"outDir": "dist",
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"declaration": true
|
|
12
|
+
},
|
|
13
|
+
"include": ["src"]
|
|
14
|
+
}
|