@pipeworx/mcp-data-ny 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 +59 -0
- package/package.json +20 -0
- package/server.json +18 -0
- package/src/index.ts +130 -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,59 @@
|
|
|
1
|
+
# mcp-data-ny
|
|
2
|
+
|
|
3
|
+
data.ny.gov — New York State open-data Socrata portal
|
|
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
|
+
| `datasets` | Search dataset catalogue. |
|
|
12
|
+
| `query` | SoQL query on a single resource. |
|
|
13
|
+
| `metadata` | Resource metadata. |
|
|
14
|
+
| `column_data` | Distinct values in a column. |
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"mcpServers": {
|
|
23
|
+
"data-ny": {
|
|
24
|
+
"url": "https://gateway.pipeworx.io/data-ny/mcp"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or connect to the full Pipeworx gateway for access to all 250+ data sources:
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"mcpServers": {
|
|
35
|
+
"pipeworx": {
|
|
36
|
+
"url": "https://gateway.pipeworx.io/mcp"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Using with ask_pipeworx
|
|
43
|
+
|
|
44
|
+
Instead of calling tools directly, you can ask questions in plain English:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
ask_pipeworx({ question: "your question about Data Ny data" })
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The gateway picks the right tool and fills the arguments automatically.
|
|
51
|
+
|
|
52
|
+
## More
|
|
53
|
+
|
|
54
|
+
- [All tools and guides](https://github.com/pipeworx-io/examples)
|
|
55
|
+
- [pipeworx.io](https://pipeworx.io)
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pipeworx/mcp-data-ny",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "data.ny.gov — New York State open-data Socrata portal",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"types": "src/index.ts",
|
|
8
|
+
"keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "data-ny"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/pipeworx-io/mcp-data-ny"
|
|
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/data-ny",
|
|
4
|
+
"title": "Data Ny",
|
|
5
|
+
"description": "data.ny.gov — New York State open-data Socrata portal",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"websiteUrl": "https://pipeworx.io/packs/data-ny",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "https://github.com/pipeworx-io/mcp-data-ny",
|
|
10
|
+
"source": "github"
|
|
11
|
+
},
|
|
12
|
+
"remotes": [
|
|
13
|
+
{
|
|
14
|
+
"type": "streamable-http",
|
|
15
|
+
"url": "https://gateway.pipeworx.io/data-ny/mcp"
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
* data.ny.gov Socrata MCP.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const BASE = 'https://data.ny.gov';
|
|
25
|
+
const UA = 'pipeworx-mcp-data-ny/1.0 (+https://pipeworx.io)';
|
|
26
|
+
|
|
27
|
+
const tools: McpToolExport['tools'] = [
|
|
28
|
+
{
|
|
29
|
+
name: 'datasets',
|
|
30
|
+
description: 'Search dataset catalogue.',
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
query: { type: 'string' },
|
|
35
|
+
limit: { type: 'number' },
|
|
36
|
+
offset: { type: 'number' },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'query',
|
|
42
|
+
description: 'SoQL query on a single resource.',
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: 'object',
|
|
45
|
+
properties: {
|
|
46
|
+
resource_id: { type: 'string', description: 'Socrata 4x4, e.g. "xj2p-gjci"' },
|
|
47
|
+
where: { type: 'string', description: 'SoQL WHERE clause (without "WHERE").' },
|
|
48
|
+
select: { type: 'string' },
|
|
49
|
+
group: { type: 'string' },
|
|
50
|
+
order: { type: 'string' },
|
|
51
|
+
limit: { type: 'number' },
|
|
52
|
+
offset: { type: 'number' },
|
|
53
|
+
},
|
|
54
|
+
required: ['resource_id'],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'metadata',
|
|
59
|
+
description: 'Resource metadata.',
|
|
60
|
+
inputSchema: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: { resource_id: { type: 'string' } },
|
|
63
|
+
required: ['resource_id'],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'column_data',
|
|
68
|
+
description: 'Distinct values in a column.',
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: {
|
|
72
|
+
resource_id: { type: 'string' },
|
|
73
|
+
column: { type: 'string' },
|
|
74
|
+
},
|
|
75
|
+
required: ['resource_id', 'column'],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
|
|
81
|
+
switch (name) {
|
|
82
|
+
case 'datasets': {
|
|
83
|
+
const p = new URLSearchParams({
|
|
84
|
+
limit: String(Math.min(100, Math.max(1, (args.limit as number) ?? 20))),
|
|
85
|
+
offset: String(Math.max(0, (args.offset as number) ?? 0)),
|
|
86
|
+
search_context: 'data.ny.gov',
|
|
87
|
+
});
|
|
88
|
+
if (args.query) p.set('q', String(args.query));
|
|
89
|
+
const res = await fetch(`http://api.us.socrata.com/api/catalog/v1?${p}&domains=data.ny.gov`, {
|
|
90
|
+
headers: { Accept: 'application/json', 'User-Agent': UA },
|
|
91
|
+
});
|
|
92
|
+
if (!res.ok) throw new Error(`Socrata catalog: ${res.status}`);
|
|
93
|
+
return res.json();
|
|
94
|
+
}
|
|
95
|
+
case 'query': {
|
|
96
|
+
const id = reqStr(args, 'resource_id', '"xj2p-gjci"');
|
|
97
|
+
const p = new URLSearchParams();
|
|
98
|
+
for (const k of ['where', 'select', 'group', 'order'] as const) {
|
|
99
|
+
if (args[k]) p.set(`$${k}`, String(args[k]));
|
|
100
|
+
}
|
|
101
|
+
if (args.limit != null) p.set('$limit', String(args.limit));
|
|
102
|
+
if (args.offset != null) p.set('$offset', String(args.offset));
|
|
103
|
+
return socrataGet(`/resource/${id}.json?${p}`);
|
|
104
|
+
}
|
|
105
|
+
case 'metadata':
|
|
106
|
+
return socrataGet(`/api/views/${reqStr(args, 'resource_id', '"xj2p-gjci"')}.json`);
|
|
107
|
+
case 'column_data': {
|
|
108
|
+
const id = reqStr(args, 'resource_id', '"xj2p-gjci"');
|
|
109
|
+
const col = reqStr(args, 'column', '"county"');
|
|
110
|
+
const p = new URLSearchParams({ $select: col, $group: col, $limit: '5000' });
|
|
111
|
+
return socrataGet(`/resource/${id}.json?${p}`);
|
|
112
|
+
}
|
|
113
|
+
default:
|
|
114
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function socrataGet(path: string): Promise<unknown> {
|
|
119
|
+
const res = await fetch(`${BASE}${path}`, { headers: { Accept: 'application/json', 'User-Agent': UA } });
|
|
120
|
+
if (!res.ok) throw new Error(`data.ny.gov: ${res.status} ${await res.text().then((t) => t.slice(0, 200))}`);
|
|
121
|
+
return res.json();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function reqStr(args: Record<string, unknown>, key: string, example: string): string {
|
|
125
|
+
const v = args[key];
|
|
126
|
+
if (typeof v !== 'string' || !v.trim()) throw new Error(`Required argument "${key}" is missing. Pass a string like ${example}.`);
|
|
127
|
+
return v;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
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
|
+
}
|