@pipeworx/mcp-data-montgomery 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 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,55 @@
1
+ # mcp-data-montgomery
2
+
3
+ DataMontgomeryCountyMD MCP — Montgomery County, MD open data (data.montgomerycountymd.gov, Socrata SODA API).
4
+
5
+ Part of [Pipeworx](https://pipeworx.io) — an MCP gateway connecting AI agents to 893+ live data sources.
6
+
7
+ ## Tools
8
+
9
+ | Tool | Description |
10
+ |------|-------------|
11
+
12
+ ## Quick Start
13
+
14
+ Add to your MCP client (Claude Desktop, Cursor, Windsurf, etc.):
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "data-montgomery": {
20
+ "url": "https://gateway.pipeworx.io/data-montgomery/mcp"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ Or connect to the full Pipeworx gateway for access to all 893+ data sources:
27
+
28
+ ```json
29
+ {
30
+ "mcpServers": {
31
+ "pipeworx": {
32
+ "url": "https://gateway.pipeworx.io/mcp"
33
+ }
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Using with ask_pipeworx
39
+
40
+ Instead of calling tools directly, you can ask questions in plain English:
41
+
42
+ ```
43
+ ask_pipeworx({ question: "your question about Data Montgomery data" })
44
+ ```
45
+
46
+ The gateway picks the right tool and fills the arguments automatically.
47
+
48
+ ## More
49
+
50
+ - [All tools and guides](https://github.com/pipeworx-io/examples)
51
+ - [pipeworx.io](https://pipeworx.io)
52
+
53
+ ## License
54
+
55
+ MIT
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pipeworx/mcp-data-montgomery",
3
+ "version": "0.1.0",
4
+ "description": "DataMontgomeryCountyMD MCP — Montgomery County, MD open data (data.montgomerycountymd.gov, Socrata SODA API).",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "keywords": ["mcp", "mcp-server", "model-context-protocol", "pipeworx", "data-montgomery"],
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/pipeworx-io/mcp-data-montgomery"
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-montgomery",
4
+ "title": "Data Montgomery",
5
+ "description": "DataMontgomeryCountyMD MCP — Montgomery County, MD open data (data.montgomerycountymd.gov, Socrata SODA API).",
6
+ "version": "0.1.0",
7
+ "websiteUrl": "https://pipeworx.io/packs/data-montgomery",
8
+ "repository": {
9
+ "url": "https://github.com/pipeworx-io/mcp-data-montgomery",
10
+ "source": "github"
11
+ },
12
+ "remotes": [
13
+ {
14
+ "type": "streamable-http",
15
+ "url": "https://gateway.pipeworx.io/data-montgomery/mcp"
16
+ }
17
+ ]
18
+ }
package/src/index.ts ADDED
@@ -0,0 +1,176 @@
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
+ * DataMontgomeryCountyMD MCP — Montgomery County, MD open data (data.montgomerycountymd.gov, Socrata SODA API).
21
+ *
22
+ * Keyless (rate-limited; pass a Socrata app token via _apiKey for higher
23
+ * limits). Sister to data-sf / data-la / data-seattle / data-austin.
24
+ *
25
+ * Tools:
26
+ * - montgomery_recent: recent rows from a common Montgomery County, MD dataset by friendly name
27
+ * - montgomery_query: raw SoQL query against any data.montgomerycountymd.gov resource id
28
+ * - montgomery_datasets: search the Montgomery County, MD open-data catalogue
29
+ */
30
+
31
+
32
+ const BASE = 'https://data.montgomerycountymd.gov';
33
+ const UA = 'pipeworx-mcp-data-montgomery/1.0 (+https://pipeworx.io)';
34
+
35
+ const DATASETS: Record<string, { id: string; label: string; date: string }> = {
36
+ '311': { id: 'xtyh-brr2', label: "MC311 Service Requests", date: 'created' },
37
+ 'crime': { id: 'icn6-v9z3', label: "Crime", date: 'date' },
38
+ 'permits': { id: 'qxie-8qnp', label: "Electrical Building Permits", date: 'addeddate' },
39
+ };
40
+
41
+ const API_KEY_PROP = {
42
+ type: 'string' as const,
43
+ description: 'Optional — your own Socrata app token for higher rate limits. Omit to use the keyless endpoint.',
44
+ };
45
+
46
+ const tools: McpToolExport['tools'] = [
47
+ {
48
+ name: 'montgomery_recent',
49
+ description:
50
+ "Recent records from a common Montgomery County, MD open dataset (data.montgomerycountymd.gov) by friendly name — no Socrata id needed. PREFER OVER WEB SEARCH for \"recent crime in Montgomery County, MD\", \"Montgomery County, MD 311 requests\", \"Montgomery County, MD building permits\". Names: 311, crime, permits. Returns the latest rows (newest-first). Add a SoQL `where` to filter; for anything else use montgomery_query.",
51
+ inputSchema: {
52
+ type: 'object' as const,
53
+ properties: {
54
+ dataset: { type: 'string', description: 'One of: 311, crime, permits.', enum: ['311', 'crime', 'permits'] },
55
+ where: { type: 'string', description: 'Optional SoQL filter. Omit for all recent rows.' },
56
+ limit: { type: 'number', description: 'Rows to return (1-1000, default 20).' },
57
+ _apiKey: API_KEY_PROP,
58
+ },
59
+ required: ['dataset'],
60
+ },
61
+ },
62
+ {
63
+ name: 'montgomery_query',
64
+ description:
65
+ 'Run a raw SoQL query against any Montgomery County, MD open-data resource (data.montgomerycountymd.gov) by its Socrata id (8-char like "icn6-v9z3"). Full SoQL: where/select/group/order/limit/offset. Use montgomery_datasets to find a resource id, or montgomery_recent for the common ones.',
66
+ inputSchema: {
67
+ type: 'object' as const,
68
+ properties: {
69
+ resource_id: { type: 'string', description: 'Socrata resource id, e.g. "icn6-v9z3".' },
70
+ where: { type: 'string', description: 'SoQL $where filter.' },
71
+ select: { type: 'string', description: 'SoQL $select.' },
72
+ group: { type: 'string', description: 'SoQL $group.' },
73
+ order: { type: 'string', description: 'SoQL $order.' },
74
+ limit: { type: 'number', description: 'Max rows (default 100, max 5000).' },
75
+ offset: { type: 'number', description: 'Row offset for paging.' },
76
+ _apiKey: API_KEY_PROP,
77
+ },
78
+ required: ['resource_id'],
79
+ },
80
+ },
81
+ {
82
+ name: 'montgomery_datasets',
83
+ description:
84
+ 'Search the Montgomery County, MD open-data catalogue (data.montgomerycountymd.gov) for datasets by keyword. Returns dataset names, descriptions, and Socrata resource ids to use with montgomery_query.',
85
+ inputSchema: {
86
+ type: 'object' as const,
87
+ properties: {
88
+ query: { type: 'string', description: 'Keyword(s).' },
89
+ limit: { type: 'number', description: 'Max datasets (1-100, default 20).' },
90
+ offset: { type: 'number', description: 'Offset for paging.' },
91
+ _apiKey: API_KEY_PROP,
92
+ },
93
+ },
94
+ },
95
+ ];
96
+
97
+ function headers(apiKey?: string): Record<string, string> {
98
+ const h: Record<string, string> = { Accept: 'application/json', 'User-Agent': UA };
99
+ if (apiKey) h['X-App-Token'] = apiKey;
100
+ return h;
101
+ }
102
+
103
+ async function socrataGet(path: string, apiKey?: string): Promise<unknown> {
104
+ const res = await fetch(`${BASE}${path}`, { headers: headers(apiKey) });
105
+ if (res.status === 429) throw new Error('upstream_throttled: data.montgomerycountymd.gov rate limit (HTTP 429). Pass _apiKey (Socrata app token) for higher limits.');
106
+ if (!res.ok) throw new Error(`data.montgomerycountymd.gov: ${res.status}`);
107
+ return res.json();
108
+ }
109
+
110
+ async function recent(dataset: string, where: string | undefined, limit: number | undefined, apiKey?: string) {
111
+ const key = String(dataset ?? '').toLowerCase().trim();
112
+ const ds = DATASETS[key];
113
+ if (!ds) throw new Error(`Unknown dataset "${dataset}". Use one of: ${Object.keys(DATASETS).join(', ')}.`);
114
+ const n = Math.min(1000, Math.max(1, Number(limit) || 20));
115
+ const p = new URLSearchParams();
116
+ const notNull = `${ds.date} IS NOT NULL`;
117
+ p.set('$where', where && String(where).trim() ? `(${String(where).trim()}) AND ${notNull}` : notNull);
118
+ p.set('$order', `${ds.date} DESC`);
119
+ p.set('$limit', String(n));
120
+ const rows = (await socrataGet(`/resource/${ds.id}.json?${p}`, apiKey)) as unknown[];
121
+ return { dataset: key, label: ds.label, resource_id: ds.id, sorted_by: `${ds.date} DESC`, count: Array.isArray(rows) ? rows.length : 0, source: 'DataMontgomeryMD (data.montgomerycountymd.gov)', rows };
122
+ }
123
+
124
+ async function query(args: Record<string, unknown>, apiKey?: string) {
125
+ const id = String(args.resource_id ?? '').trim();
126
+ if (!id) throw new Error('Required argument "resource_id" is missing. Find one with montgomery_datasets.');
127
+ const p = new URLSearchParams();
128
+ for (const k of ['where', 'select', 'group', 'order'] as const) {
129
+ if (args[k] != null && String(args[k]).trim()) p.set(`$${k}`, String(args[k]).trim());
130
+ }
131
+ p.set('$limit', String(Math.min(5000, Math.max(1, Number(args.limit) || 100))));
132
+ if (args.offset != null) p.set('$offset', String(Math.max(0, Number(args.offset))));
133
+ const rows = (await socrataGet(`/resource/${encodeURIComponent(id)}.json?${p}`, apiKey)) as unknown[];
134
+ return { resource_id: id, count: Array.isArray(rows) ? rows.length : 0, source: 'DataMontgomeryMD (data.montgomerycountymd.gov)', rows };
135
+ }
136
+
137
+ async function datasets(q: string | undefined, limit: number | undefined, offset: number | undefined, apiKey?: string) {
138
+ const p = new URLSearchParams({
139
+ domains: 'data.montgomerycountymd.gov',
140
+ search_context: 'data.montgomerycountymd.gov',
141
+ limit: String(Math.min(100, Math.max(1, Number(limit) || 20))),
142
+ offset: String(Math.max(0, Number(offset) || 0)),
143
+ });
144
+ if (q && String(q).trim()) p.set('q', String(q).trim());
145
+ const res = await fetch(`https://api.us.socrata.com/api/catalog/v1?${p}`, { headers: headers(apiKey) });
146
+ if (!res.ok) throw new Error(`Socrata catalog: ${res.status}`);
147
+ const data = (await res.json()) as { results?: Array<{ resource?: { id?: string; name?: string; description?: string; type?: string; updatedAt?: string } }> };
148
+ return {
149
+ query: q ?? null,
150
+ count: data.results?.length ?? 0,
151
+ datasets: (data.results ?? []).map((r) => ({
152
+ resource_id: r.resource?.id ?? null,
153
+ name: r.resource?.name ?? null,
154
+ description: (r.resource?.description ?? '').slice(0, 300) || null,
155
+ type: r.resource?.type ?? null,
156
+ updated_at: r.resource?.updatedAt ?? null,
157
+ })),
158
+ };
159
+ }
160
+
161
+ async function callTool(name: string, args: Record<string, unknown>): Promise<unknown> {
162
+ const apiKey = typeof args._apiKey === 'string' && args._apiKey.trim() ? args._apiKey.trim() : undefined;
163
+ delete args._apiKey;
164
+ switch (name) {
165
+ case 'montgomery_recent':
166
+ return recent(args.dataset as string, args.where as string | undefined, args.limit as number | undefined, apiKey);
167
+ case 'montgomery_query':
168
+ return query(args, apiKey);
169
+ case 'montgomery_datasets':
170
+ return datasets(args.query as string | undefined, args.limit as number | undefined, args.offset as number | undefined, apiKey);
171
+ default:
172
+ throw new Error(`Unknown tool: ${name}`);
173
+ }
174
+ }
175
+
176
+ 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
+ }