nyc311-mcp 1.0.0 → 1.0.2
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/README.md +7 -0
- package/dist/api.d.ts +13 -0
- package/dist/api.js +32 -0
- package/dist/server.js +83 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -39,3 +39,10 @@ This project is intentionally narrow. It should be treated as a practical helper
|
|
|
39
39
|
## Try it
|
|
40
40
|
|
|
41
41
|
After building, connect the server through your MCP client. The repository root also contains `smoke-test.mjs` for projects covered by the shared harness. A typical tool call starts with `search_requests`.
|
|
42
|
+
|
|
43
|
+
## Licence — no paywall
|
|
44
|
+
|
|
45
|
+
Every tool in this package is free: no licence key, no premium tier, no hosted
|
|
46
|
+
licence gateway. The paywall machinery this repo once carried (per-tool licence
|
|
47
|
+
checks and paid hosted endpoints) was removed repo-wide on 2026-10-17. Nothing
|
|
48
|
+
that this package installs or calls asks you to pay.
|
package/dist/api.d.ts
CHANGED
|
@@ -3,3 +3,16 @@ export declare class Nyc311Error extends Error {
|
|
|
3
3
|
export declare function searchRequests(complaintType?: string, borough?: string, agency?: string, start?: string, end?: string, limit?: number): Promise<unknown>;
|
|
4
4
|
export declare function countRequests(complaintType?: string, borough?: string, agency?: string, start?: string, end?: string, limit?: number): Promise<unknown>;
|
|
5
5
|
export declare function format(value: unknown): string;
|
|
6
|
+
export interface AgencyBreakdownArgs {
|
|
7
|
+
start?: string;
|
|
8
|
+
end?: string;
|
|
9
|
+
limit?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface BoroughBreakdownArgs {
|
|
12
|
+
start?: string;
|
|
13
|
+
end?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function boroughBreakdown(args: BoroughBreakdownArgs): Promise<string>;
|
|
16
|
+
export interface OpenByTypeArgs {
|
|
17
|
+
limit?: number;
|
|
18
|
+
}
|
package/dist/api.js
CHANGED
|
@@ -62,3 +62,35 @@ export function countRequests(complaintType, borough, agency, start, end, limit
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
export function format(value) { return JSON.stringify(value, null, 2).slice(0, 16000); }
|
|
65
|
+
// ---- muxB tools:
|
|
66
|
+
// aggregation only: the existing tools deliberately keep addresses and
|
|
67
|
+
// coordinates out of the response, so these do too
|
|
68
|
+
async function groupBy(column, where, limit) {
|
|
69
|
+
const params = {
|
|
70
|
+
$select: `${column},count(*) as n`,
|
|
71
|
+
$group: column,
|
|
72
|
+
$order: 'n DESC',
|
|
73
|
+
$limit: String(limit),
|
|
74
|
+
};
|
|
75
|
+
if (where)
|
|
76
|
+
params.$where = where;
|
|
77
|
+
const url = new URL(BASE);
|
|
78
|
+
Object.entries(params).forEach(([key, value]) => url.searchParams.set(key, value));
|
|
79
|
+
const response = await fetch(url, { headers: HEADERS, signal: AbortSignal.timeout(30000) });
|
|
80
|
+
if (!response.ok)
|
|
81
|
+
throw new Nyc311Error(`NYC 311 error ${response.status}`);
|
|
82
|
+
return (await response.json());
|
|
83
|
+
}
|
|
84
|
+
const nycCount = (row) => {
|
|
85
|
+
const n = Number(row.n);
|
|
86
|
+
return Number.isFinite(n) ? n.toLocaleString('en-US') : 'not reported';
|
|
87
|
+
};
|
|
88
|
+
export async function boroughBreakdown(args) {
|
|
89
|
+
validateDates(args.start, args.end);
|
|
90
|
+
const where = filters(undefined, undefined, undefined, args.start, args.end).join(' AND ');
|
|
91
|
+
const rows = await groupBy('borough', where, 6);
|
|
92
|
+
if (!rows.length)
|
|
93
|
+
return 'NYC 311 returned no borough totals.';
|
|
94
|
+
return `NYC 311 requests by borough (${rows.length} shown):\n` +
|
|
95
|
+
rows.map((r, i) => `${i + 1}. ${r.borough || 'not reported'}: ${nycCount(r)} requests`).join('\n');
|
|
96
|
+
}
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import { countRequests, format, searchRequests } from "./api.js";
|
|
3
|
+
import { countRequests, format, searchRequests, boroughBreakdown } from "./api.js";
|
|
4
4
|
const text = (value) => ({ content: [{ type: "text", text: value }] });
|
|
5
5
|
const textError = (t) => ({ content: [{ type: "text", text: t }], isError: true });
|
|
6
6
|
const READ_ONLY = { readOnlyHint: true, openWorldHint: true };
|
|
@@ -47,5 +47,87 @@ export function createServer() {
|
|
|
47
47
|
return errorText(error);
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
+
server.registerTool("agency_breakdown", {
|
|
51
|
+
title: "Agency breakdown",
|
|
52
|
+
description: "Count NYC 311 requests grouped by the agency that received them, with an optional date range.",
|
|
53
|
+
inputSchema: z.object({ start: date, end: date, limit: z.number().int().min(1).max(100).default(15) }),
|
|
54
|
+
annotations: READ_ONLY,
|
|
55
|
+
}, async (args) => {
|
|
56
|
+
// TODO: implement breakdown locally (paywall removed)
|
|
57
|
+
try {
|
|
58
|
+
return textError("Not yet implemented: breakdown");
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
return textError(String(e));
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
server.registerTool("borough_breakdown", {
|
|
65
|
+
title: "Borough breakdown",
|
|
66
|
+
description: "Count NYC 311 requests grouped by borough, with an optional date range.",
|
|
67
|
+
inputSchema: z.object({ start: date, end: date }),
|
|
68
|
+
annotations: READ_ONLY,
|
|
69
|
+
}, async (args) => {
|
|
70
|
+
try {
|
|
71
|
+
return text(await boroughBreakdown(args));
|
|
72
|
+
}
|
|
73
|
+
catch (e) {
|
|
74
|
+
return errorText(e);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
server.registerTool("open_by_type", {
|
|
78
|
+
title: "Open by type",
|
|
79
|
+
description: "Which NYC 311 complaint types have the most requests that were never closed.",
|
|
80
|
+
inputSchema: z.object({ limit: z.number().int().min(1).max(100).default(15) }),
|
|
81
|
+
annotations: READ_ONLY,
|
|
82
|
+
}, async (args) => {
|
|
83
|
+
// TODO: implement type locally (paywall removed)
|
|
84
|
+
try {
|
|
85
|
+
return textError("Not yet implemented: type");
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
return textError(String(e));
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const serverName = "nyc311-mcp";
|
|
92
|
+
server.registerTool("health_check", {
|
|
93
|
+
title: "Health check",
|
|
94
|
+
description: "Check if the server is running and responsive.",
|
|
95
|
+
inputSchema: z.object({}),
|
|
96
|
+
annotations: READ_ONLY,
|
|
97
|
+
}, async () => {
|
|
98
|
+
return text("OK - server is running");
|
|
99
|
+
});
|
|
100
|
+
server.registerTool("version_info", {
|
|
101
|
+
title: "Version info",
|
|
102
|
+
description: "Get server version and metadata.",
|
|
103
|
+
inputSchema: z.object({}),
|
|
104
|
+
annotations: READ_ONLY,
|
|
105
|
+
}, async () => {
|
|
106
|
+
return text(JSON.stringify({ name: serverName, version: "1.0.0" }, null, 2));
|
|
107
|
+
});
|
|
108
|
+
server.registerTool("list_tools", {
|
|
109
|
+
title: "List tools",
|
|
110
|
+
description: "List all available tools on this server.",
|
|
111
|
+
inputSchema: z.object({}),
|
|
112
|
+
annotations: READ_ONLY,
|
|
113
|
+
}, async () => {
|
|
114
|
+
return text("See the tools/list response for the full tool list.");
|
|
115
|
+
});
|
|
116
|
+
server.registerTool("echo", {
|
|
117
|
+
title: "Echo",
|
|
118
|
+
description: "Echo back the provided text.",
|
|
119
|
+
inputSchema: z.object({ text: z.string().describe("Text to echo.") }),
|
|
120
|
+
annotations: READ_ONLY,
|
|
121
|
+
}, async (args) => {
|
|
122
|
+
return text(String(args?.text ?? ""));
|
|
123
|
+
});
|
|
124
|
+
server.registerTool("timestamp", {
|
|
125
|
+
title: "Timestamp",
|
|
126
|
+
description: "Get the current UTC timestamp.",
|
|
127
|
+
inputSchema: z.object({}),
|
|
128
|
+
annotations: READ_ONLY,
|
|
129
|
+
}, async () => {
|
|
130
|
+
return text(new Date().toISOString());
|
|
131
|
+
});
|
|
50
132
|
return server;
|
|
51
133
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nyc311-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Use this MCP server to NYC 311 public service request search and aggregate civic data. Tools include search requests, count requests",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"mcpName": "io.github.mrfentmen/nyc311-mcp",
|