@pipeworx/mcp-url 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 +109 -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-url
|
|
2
|
+
|
|
3
|
+
URL parsing & building MCP.
|
|
4
|
+
|
|
5
|
+
Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 1148+ live data sources.
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
| Tool | Description |
|
|
10
|
+
|------|-------------|
|
|
11
|
+
| `parse_url` | Parse a URL into its components (keyless, offline): protocol, host, hostname, port, path, query (as an object), fragment, origin, and any userinfo. |
|
|
12
|
+
| `build_url` | Build a URL string from components. Provide at least `hostname` (and optionally protocol, port, path, hash) plus a `query` object of key/value pairs. |
|
|
13
|
+
| `parse_query` | Parse a query string (with or without a leading "?") into an object; repeated keys become arrays. |
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"mcpServers": {
|
|
22
|
+
"url": {
|
|
23
|
+
"url": "https://gateway.pipeworx.io/url/mcp"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Or connect to the full Pipeworx gateway for access to all 1148+ 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 Url 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-url",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "URL parsing & building MCP.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "url"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-url"
|
|
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/url",
|
|
4
|
+
"title": "Url",
|
|
5
|
+
"description": "URL parsing & building MCP.",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/url",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-url",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/url/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
* URL parsing & building MCP.
|
|
21
|
+
*
|
|
22
|
+
* Keyless, offline: parse a URL into its components (with query params broken
|
|
23
|
+
* out), build a URL from parts, and parse/stringify query strings. Uses the
|
|
24
|
+
* platform URL/URLSearchParams — no API, no key.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
const tools: McpToolExport['tools'] = [
|
|
29
|
+
{
|
|
30
|
+
name: 'parse_url',
|
|
31
|
+
description: 'Parse a URL into its components (keyless, offline): protocol, host, hostname, port, path, query (as an object), fragment, origin, and any userinfo.',
|
|
32
|
+
inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'A full URL, e.g. "https://user@example.com:8443/a/b?x=1&y=2#frag".' } }, required: ['url'] },
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'build_url',
|
|
36
|
+
description: 'Build a URL string from components. Provide at least `hostname` (and optionally protocol, port, path, hash) plus a `query` object of key/value pairs.',
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
protocol: { type: 'string', description: 'e.g. "https" (default).' },
|
|
41
|
+
hostname: { type: 'string', description: 'Host, e.g. "example.com".' },
|
|
42
|
+
port: { type: 'number', description: 'Optional port.' },
|
|
43
|
+
path: { type: 'string', description: 'Path, e.g. "/search" (default "/").' },
|
|
44
|
+
query: { type: 'object', description: 'Query parameters as an object, e.g. {"q":"cats","page":2}.' },
|
|
45
|
+
hash: { type: 'string', description: 'Optional fragment (without "#").' },
|
|
46
|
+
},
|
|
47
|
+
required: ['hostname'],
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'parse_query',
|
|
52
|
+
description: 'Parse a query string (with or without a leading "?") into an object; repeated keys become arrays.',
|
|
53
|
+
inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'e.g. "a=1&b=2&b=3".' } }, required: ['query'] },
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
58
|
+
switch (name) {
|
|
59
|
+
case 'parse_url': {
|
|
60
|
+
const raw = reqStr(args, 'url', '"https://example.com/a?x=1"');
|
|
61
|
+
let u: URL;
|
|
62
|
+
try { u = new URL(raw); } catch { return { input: raw, valid: false, reason: 'Not a valid absolute URL (include the scheme, e.g. https://).' }; }
|
|
63
|
+
const query: Record<string, string | string[]> = {};
|
|
64
|
+
for (const [k, v] of u.searchParams) query[k] = k in query ? ([] as string[]).concat(query[k] as any, v) : v;
|
|
65
|
+
return {
|
|
66
|
+
input: raw, valid: true,
|
|
67
|
+
protocol: u.protocol.replace(/:$/, ''), origin: u.origin, host: u.host, hostname: u.hostname,
|
|
68
|
+
port: u.port || null, path: u.pathname, query, fragment: u.hash.replace(/^#/, '') || null,
|
|
69
|
+
username: u.username || null, password: u.password || null,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
case 'build_url': {
|
|
73
|
+
const hostname = reqStr(args, 'hostname', '"example.com"');
|
|
74
|
+
const protocol = (typeof args.protocol === 'string' ? args.protocol : 'https').replace(/:$/, '');
|
|
75
|
+
let s = `${protocol}://${hostname}`;
|
|
76
|
+
if (typeof args.port === 'number') s += `:${args.port}`;
|
|
77
|
+
let path = typeof args.path === 'string' ? args.path : '/';
|
|
78
|
+
if (!path.startsWith('/')) path = '/' + path;
|
|
79
|
+
s += path;
|
|
80
|
+
if (args.query && typeof args.query === 'object') {
|
|
81
|
+
const p = new URLSearchParams();
|
|
82
|
+
for (const [k, v] of Object.entries(args.query as Record<string, unknown>)) {
|
|
83
|
+
if (Array.isArray(v)) v.forEach((x) => p.append(k, String(x)));
|
|
84
|
+
else p.append(k, String(v));
|
|
85
|
+
}
|
|
86
|
+
const qs = p.toString(); if (qs) s += '?' + qs;
|
|
87
|
+
}
|
|
88
|
+
if (typeof args.hash === 'string' && args.hash) s += '#' + args.hash.replace(/^#/, '');
|
|
89
|
+
return { url: s };
|
|
90
|
+
}
|
|
91
|
+
case 'parse_query': {
|
|
92
|
+
const q = reqStr(args, 'query', '"a=1&b=2"').replace(/^\?/, '');
|
|
93
|
+
const params = new URLSearchParams(q);
|
|
94
|
+
const out: Record<string, string | string[]> = {};
|
|
95
|
+
for (const [k, v] of params) out[k] = k in out ? ([] as string[]).concat(out[k] as any, v) : v;
|
|
96
|
+
return { input: q, params: out };
|
|
97
|
+
}
|
|
98
|
+
default:
|
|
99
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function reqStr(args: Record<string, unknown>, key: string, ex: string): string {
|
|
104
|
+
const v = args[key];
|
|
105
|
+
if (typeof v !== 'string' || !v.trim()) throw new Error(`Required argument "${key}" is missing. Pass a string like ${ex}.`);
|
|
106
|
+
return v;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
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
|
+
}
|