@pipeworx/mcp-mdn-search 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 +128 -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-mdn-search
|
|
2
|
+
|
|
3
|
+
MDN Search MCP
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 250+ live data sources.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
| `search` | Full-text search across MDN content. |
|
|
12
|
+
| `summary` | Page summary by slug (e.g. "Web/API/fetch" or "Web/CSS/grid"). |
|
|
13
|
+
| `bcd` | Browser Compatibility Data block for a feature page. |
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"mcpServers": {
|
|
22
|
+
"mdn-search": {
|
|
23
|
+
"url": "https://gateway.pipeworx.io/mdn-search/mcp"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or connect to the full Pipeworx gateway for access to all 250+ 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 Mdn Search 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-mdn-search",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MDN Search MCP",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "mdn-search"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-mdn-search"
|
|
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/mdn-search",
|
|
4
|
+
"title": "Mdn Search",
|
|
5
|
+
"description": "MDN Search MCP",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/mdn-search",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-mdn-search",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/mdn-search/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
* MDN Search MCP
|
|
21
|
+
*
|
|
22
|
+
* Auth: none.
|
|
23
|
+
* Docs: there's no formal public API contract, but the developer.mozilla.org
|
|
24
|
+
* frontend uses these stable JSON endpoints to power its own search.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const BASE = 'https://developer.mozilla.org';
|
|
29
|
+
|
|
30
|
+
const tools: McpToolExport['tools'] = [
|
|
31
|
+
{
|
|
32
|
+
name: 'search',
|
|
33
|
+
description: 'Full-text search across MDN content.',
|
|
34
|
+
inputSchema: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
query: { type: 'string' },
|
|
38
|
+
locale: { type: 'string', description: 'en-US (default) | fr | es | ja | zh-CN | …' },
|
|
39
|
+
size: { type: 'number', description: '1-100 (default 10)' },
|
|
40
|
+
page: { type: 'number', description: '1-based page' },
|
|
41
|
+
},
|
|
42
|
+
required: ['query'],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'summary',
|
|
47
|
+
description: 'Page summary by slug (e.g. "Web/API/fetch" or "Web/CSS/grid").',
|
|
48
|
+
inputSchema: {
|
|
49
|
+
type: 'object',
|
|
50
|
+
properties: {
|
|
51
|
+
slug: { type: 'string' },
|
|
52
|
+
locale: { type: 'string' },
|
|
53
|
+
},
|
|
54
|
+
required: ['slug'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'bcd',
|
|
59
|
+
description: 'Browser Compatibility Data block for a feature page.',
|
|
60
|
+
inputSchema: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
slug: { type: 'string' },
|
|
64
|
+
locale: { type: 'string' },
|
|
65
|
+
},
|
|
66
|
+
required: ['slug'],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
72
|
+
switch (name) {
|
|
73
|
+
case 'search': {
|
|
74
|
+
const params = new URLSearchParams({
|
|
75
|
+
q: reqStr(args, 'query', '"async iterator"'),
|
|
76
|
+
locale: String(args.locale ?? 'en-US'),
|
|
77
|
+
size: String(Math.min(100, Math.max(1, (args.size as number) ?? 10))),
|
|
78
|
+
page: String(Math.max(1, (args.page as number) ?? 1)),
|
|
79
|
+
});
|
|
80
|
+
return mdnGet(`/api/v1/search?${params}`);
|
|
81
|
+
}
|
|
82
|
+
case 'summary':
|
|
83
|
+
return mdnGet(`/${String(args.locale ?? 'en-US')}/docs/${stripWebPrefix(reqStr(args, 'slug', '"Web/API/fetch"'))}/index.json`);
|
|
84
|
+
case 'bcd': {
|
|
85
|
+
const slug = stripWebPrefix(reqStr(args, 'slug', '"Web/API/fetch"'));
|
|
86
|
+
const data = (await mdnGet(`/${String(args.locale ?? 'en-US')}/docs/${slug}/index.json`)) as {
|
|
87
|
+
doc?: {
|
|
88
|
+
body?: { type?: string; value?: { data?: unknown; query?: string; dataURL?: string } }[];
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
const bcdBlock = data.doc?.body?.find((b) => b.type === 'browser_compatibility');
|
|
92
|
+
return { slug, bcd: bcdBlock?.value ?? null };
|
|
93
|
+
}
|
|
94
|
+
default:
|
|
95
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function stripWebPrefix(slug: string): string {
|
|
100
|
+
// Accept both "Web/API/fetch" and "/en-US/docs/Web/API/fetch" — normalize to slug-only.
|
|
101
|
+
return slug.replace(/^\/?(?:[a-z]{2}-[A-Z]{2}\/docs\/)?/, '');
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function mdnGet(path: string) {
|
|
105
|
+
const res = await fetch(`${BASE}${path}`, {
|
|
106
|
+
headers: {
|
|
107
|
+
Accept: 'application/json',
|
|
108
|
+
'User-Agent': 'pipeworx-mcp-mdn-search/1.0 (+https://pipeworx.io)',
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
if (res.status === 404) throw new Error('MDN: not found');
|
|
112
|
+
if (res.status === 429) throw new Error('MDN: rate-limit (HTTP 429)');
|
|
113
|
+
if (!res.ok) {
|
|
114
|
+
const t = await res.text();
|
|
115
|
+
throw new Error(`MDN error: ${res.status} ${t.slice(0, 200)}`);
|
|
116
|
+
}
|
|
117
|
+
return res.json();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function reqStr(args: Record<string, unknown>, key: string, example: string): string {
|
|
121
|
+
const v = args[key];
|
|
122
|
+
if (typeof v !== 'string' || !v.trim()) {
|
|
123
|
+
throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
|
|
124
|
+
}
|
|
125
|
+
return v;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
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
|
+
}
|