@cliwant/mcp-sam-gov 1.4.0 → 1.6.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 -21
- package/README.ja.md +240 -231
- package/README.ko.md +240 -231
- package/README.md +725 -706
- package/dist/cbp-border.d.ts +51 -0
- package/dist/cbp-border.d.ts.map +1 -0
- package/dist/cbp-border.js +123 -0
- package/dist/cbp-border.js.map +1 -0
- package/dist/datagov-catalog.d.ts.map +1 -1
- package/dist/datagov-catalog.js +16 -2
- package/dist/datagov-catalog.js.map +1 -1
- package/dist/ecfr.d.ts +2 -2
- package/dist/ecfr.d.ts.map +1 -1
- package/dist/ecfr.js +24 -10
- package/dist/ecfr.js.map +1 -1
- package/dist/edgar.d.ts.map +1 -1
- package/dist/edgar.js +26 -6
- package/dist/edgar.js.map +1 -1
- package/dist/epa-envirofacts.d.ts.map +1 -1
- package/dist/epa-envirofacts.js +14 -1
- package/dist/epa-envirofacts.js.map +1 -1
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +11 -0
- package/dist/errors.js.map +1 -1
- package/dist/far.d.ts.map +1 -1
- package/dist/far.js +3 -1
- package/dist/far.js.map +1 -1
- package/dist/federal-register.d.ts +2 -2
- package/dist/federal-register.d.ts.map +1 -1
- package/dist/federal-register.js +26 -10
- package/dist/federal-register.js.map +1 -1
- package/dist/feedback.d.ts +64 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/feedback.js +131 -0
- package/dist/feedback.js.map +1 -0
- package/dist/fema.d.ts +36 -0
- package/dist/fema.d.ts.map +1 -1
- package/dist/fema.js +124 -0
- package/dist/fema.js.map +1 -1
- package/dist/gov-domains.d.ts +66 -0
- package/dist/gov-domains.d.ts.map +1 -0
- package/dist/gov-domains.js +211 -0
- package/dist/gov-domains.js.map +1 -0
- package/dist/nist-controls.d.ts +48 -0
- package/dist/nist-controls.d.ts.map +1 -0
- package/dist/nist-controls.js +174 -0
- package/dist/nist-controls.js.map +1 -0
- package/dist/nws-weather.d.ts +57 -0
- package/dist/nws-weather.d.ts.map +1 -0
- package/dist/nws-weather.js +131 -0
- package/dist/nws-weather.js.map +1 -0
- package/dist/openfda-drugsfda.d.ts +72 -0
- package/dist/openfda-drugsfda.d.ts.map +1 -0
- package/dist/openfda-drugsfda.js +230 -0
- package/dist/openfda-drugsfda.js.map +1 -0
- package/dist/openfda.d.ts.map +1 -1
- package/dist/openfda.js +31 -8
- package/dist/openfda.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +374 -11
- package/dist/server.js.map +1 -1
- package/dist/treasury.d.ts +2 -0
- package/dist/treasury.d.ts.map +1 -1
- package/dist/treasury.js +7 -0
- package/dist/treasury.js.map +1 -1
- package/dist/usaspending.d.ts +32 -1
- package/dist/usaspending.d.ts.map +1 -1
- package/dist/usaspending.js +143 -16
- package/dist/usaspending.js.map +1 -1
- package/package.json +111 -111
- package/src/attachments.ts +652 -652
- package/src/bea.ts +372 -372
- package/src/bls.ts +1943 -1943
- package/src/cache.ts +73 -73
- package/src/cbp-border.ts +177 -0
- package/src/census-economic.ts +431 -431
- package/src/census.ts +735 -735
- package/src/ckan.ts +495 -495
- package/src/clinicaltrials.ts +923 -923
- package/src/cms-facility.ts +379 -379
- package/src/cms-hospital.ts +344 -344
- package/src/cms-supplier.ts +527 -527
- package/src/cms-utilization.ts +389 -389
- package/src/cms.ts +634 -634
- package/src/coerce.ts +47 -47
- package/src/courtlistener.ts +465 -465
- package/src/cpsc.ts +333 -333
- package/src/datagov-catalog.ts +312 -296
- package/src/datagov.ts +907 -907
- package/src/datagovKey.ts +68 -68
- package/src/datasource.ts +721 -721
- package/src/disclosure.ts +61 -61
- package/src/dol.ts +515 -515
- package/src/ecfr.ts +248 -231
- package/src/echo.ts +496 -496
- package/src/edgar.ts +3046 -3014
- package/src/epa-envirofacts.ts +358 -342
- package/src/errors.ts +324 -303
- package/src/fac.ts +529 -529
- package/src/far.ts +1009 -1007
- package/src/fdic.ts +2052 -2052
- package/src/federal-register.ts +725 -706
- package/src/feedback.ts +160 -0
- package/src/fema.ts +680 -541
- package/src/fpds.ts +620 -620
- package/src/fred.ts +464 -464
- package/src/gao.ts +744 -744
- package/src/gov-domains.ts +237 -0
- package/src/govinfo.ts +497 -497
- package/src/grants.ts +290 -290
- package/src/gsa-csv.ts +992 -992
- package/src/gsa-perdiem.ts +361 -361
- package/src/integrity.ts +928 -928
- package/src/keys.ts +268 -268
- package/src/lda.ts +385 -385
- package/src/meta.ts +292 -292
- package/src/nhtsa.ts +352 -352
- package/src/nih.ts +375 -375
- package/src/nist-controls.ts +219 -0
- package/src/nonprofit.ts +460 -460
- package/src/nppes.ts +834 -834
- package/src/nsf.ts +706 -706
- package/src/nvd.ts +1124 -1124
- package/src/nws-weather.ts +167 -0
- package/src/ofac.ts +1166 -1166
- package/src/openfda-device.ts +356 -356
- package/src/openfda-drugsfda.ts +313 -0
- package/src/openfda.ts +518 -495
- package/src/pricing.ts +1075 -1075
- package/src/sam-gov/client.ts +774 -774
- package/src/sam-gov/index.ts +32 -32
- package/src/sam-gov/types.ts +152 -152
- package/src/sba.ts +357 -357
- package/src/server.ts +6688 -6297
- package/src/snapshot.ts +223 -223
- package/src/socrata.ts +532 -532
- package/src/treasury.ts +582 -575
- package/src/usaspending.ts +2852 -2680
- package/src/usitc.ts +420 -420
package/src/feedback.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* feedback.ts — the in-product feedback → GitHub-issue loop (KEYLESS, PULL-only).
|
|
3
|
+
*
|
|
4
|
+
* Why this exists
|
|
5
|
+
* ----------------
|
|
6
|
+
* This server's "user" is an AI agent, not a human at a keyboard. So the way we
|
|
7
|
+
* collect "this looked wrong / this is broken / I wish it could do X" from real
|
|
8
|
+
* usage is THROUGH the agent: a tool (or an error envelope) hands the agent a
|
|
9
|
+
* PREFILLED GitHub "new issue" URL, and the agent offers it to the human, who
|
|
10
|
+
* opens and submits it.
|
|
11
|
+
*
|
|
12
|
+
* Hard guarantees (consistent with the server's keyless / honest / no-telemetry
|
|
13
|
+
* posture — and with the rule never to submit a form on the user's behalf):
|
|
14
|
+
* • PULL only. The server NEVER posts to GitHub. It builds a link; the human
|
|
15
|
+
* clicks and submits. No token, no account, no auto-submit, no network call.
|
|
16
|
+
* • No PII. A prefill carries only the tool name, server version, and (for the
|
|
17
|
+
* `feedback` tool) a caller-supplied one-line summary. It NEVER embeds the
|
|
18
|
+
* user's tool arguments or the upstream response, and every prefill body
|
|
19
|
+
* tells the human to redact anything sensitive before submitting.
|
|
20
|
+
* • Non-nagging. Error links are attached only to the two "something may be
|
|
21
|
+
* broken" kinds (schema_drift, upstream_unavailable) — never to expected
|
|
22
|
+
* outcomes (not_found, invalid_input, rate_limited).
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export const REPO_URL = "https://github.com/cliwant/mcp-sam-gov";
|
|
26
|
+
const NEW_ISSUE_URL = `${REPO_URL}/issues/new`;
|
|
27
|
+
|
|
28
|
+
export type FeedbackKind = "bug" | "feature" | "wrong_output";
|
|
29
|
+
|
|
30
|
+
const REDACT_NOTE =
|
|
31
|
+
"⚠️ This is a PUBLIC issue. Do NOT paste API keys, credentials, personal data, or sensitive query values — redact anything private before you submit.";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Build a GitHub "new issue" URL with a prefilled title/body/labels. Everything
|
|
35
|
+
* is URL-encoded via URLSearchParams. A prefilled label that does not exist in
|
|
36
|
+
* the repo is simply ignored by GitHub (the issue still opens) — never an error.
|
|
37
|
+
*/
|
|
38
|
+
function buildIssueUrl(params: { title: string; body: string; labels: string[] }): string {
|
|
39
|
+
const q = new URLSearchParams();
|
|
40
|
+
q.set("title", params.title);
|
|
41
|
+
q.set("body", params.body);
|
|
42
|
+
if (params.labels.length > 0) q.set("labels", params.labels.join(","));
|
|
43
|
+
return `${NEW_ISSUE_URL}?${q.toString()}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The prefilled report link attached to a schema_drift / upstream_unavailable
|
|
48
|
+
* error envelope. Carries ONLY tool + kind + server version — no args, no PII.
|
|
49
|
+
*/
|
|
50
|
+
export function reportUrlForError(tool: string, kind: string, version: string): string {
|
|
51
|
+
const title = `[${tool}] ${kind}`;
|
|
52
|
+
const kindHint =
|
|
53
|
+
kind === "schema_drift"
|
|
54
|
+
? "schema_drift means the government API very likely changed its response shape, so the wrapper needs updating — this is the single most useful thing to report."
|
|
55
|
+
: "upstream_unavailable is often a transient government-side outage; please report only if it PERSISTS or the endpoint appears to have permanently moved.";
|
|
56
|
+
const body = [
|
|
57
|
+
"**Reporting a tool problem** (this link was suggested by the server).",
|
|
58
|
+
"",
|
|
59
|
+
`- **Tool:** \`${tool}\``,
|
|
60
|
+
`- **Error kind:** \`${kind}\``,
|
|
61
|
+
`- **Server version:** \`${version}\``,
|
|
62
|
+
"",
|
|
63
|
+
"**What I was trying to do:** _(describe — no sensitive values)_",
|
|
64
|
+
"",
|
|
65
|
+
"**Why it looks wrong / how often it happens:** _(describe)_",
|
|
66
|
+
"",
|
|
67
|
+
`_${kindHint}_`,
|
|
68
|
+
"",
|
|
69
|
+
REDACT_NOTE,
|
|
70
|
+
].join("\n");
|
|
71
|
+
return buildIssueUrl({ title, body, labels: ["from-tool"] });
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The ONLY two error kinds that get a prefilled report link — the "something may
|
|
76
|
+
* be broken on our side" kinds. Expected/user errors (invalid_input, not_found,
|
|
77
|
+
* rate_limited) are deliberately excluded so their envelopes stay byte-identical.
|
|
78
|
+
*/
|
|
79
|
+
export const REPORTABLE_ERROR_KINDS: ReadonlySet<string> = new Set([
|
|
80
|
+
"schema_drift",
|
|
81
|
+
"upstream_unavailable",
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Attach a prefilled `report` URL to an error envelope IN PLACE, but only for a
|
|
86
|
+
* reportable kind. A no-op (envelope unchanged) for every other kind. Centralizes
|
|
87
|
+
* the policy so the dispatcher and the tests agree on exactly which kinds report.
|
|
88
|
+
*/
|
|
89
|
+
export function maybeAttachReport(
|
|
90
|
+
error: { kind: string; report?: string },
|
|
91
|
+
tool: string,
|
|
92
|
+
version: string,
|
|
93
|
+
): void {
|
|
94
|
+
if (REPORTABLE_ERROR_KINDS.has(error.kind)) {
|
|
95
|
+
error.report = reportUrlForError(tool, error.kind, version);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const KIND_TITLE: Record<FeedbackKind, string> = {
|
|
100
|
+
bug: "Bug",
|
|
101
|
+
feature: "Feature request",
|
|
102
|
+
wrong_output: "Tool returned a wrong-looking result",
|
|
103
|
+
};
|
|
104
|
+
const KIND_LABELS: Record<FeedbackKind, string[]> = {
|
|
105
|
+
bug: ["bug"],
|
|
106
|
+
feature: ["enhancement"],
|
|
107
|
+
wrong_output: ["bug", "wrong-output"],
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type FeedbackResult = {
|
|
111
|
+
reportUrl: string;
|
|
112
|
+
repo: string;
|
|
113
|
+
willPost: false;
|
|
114
|
+
instructions: string;
|
|
115
|
+
privacy: string;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The `feedback` tool handler. Turns a caller's (agent's) bug/feature/wrong-output
|
|
120
|
+
* report into a PREFILLED GitHub new-issue URL for the HUMAN to open and submit.
|
|
121
|
+
* Pure + keyless: no network, no posting. `summary` is caller-supplied free text
|
|
122
|
+
* and is trusted to be non-sensitive (the description + privacy note say so).
|
|
123
|
+
*/
|
|
124
|
+
export function feedbackTool(input: {
|
|
125
|
+
kind?: FeedbackKind;
|
|
126
|
+
tool?: string;
|
|
127
|
+
summary?: string;
|
|
128
|
+
}): FeedbackResult {
|
|
129
|
+
const kind: FeedbackKind = input.kind ?? "bug";
|
|
130
|
+
const toolPart = input.tool ? `[${input.tool}] ` : "";
|
|
131
|
+
const summary = (input.summary ?? "").trim();
|
|
132
|
+
const title = `${toolPart}${KIND_TITLE[kind]}${summary ? `: ${summary}` : ""}`;
|
|
133
|
+
const lead =
|
|
134
|
+
kind === "feature"
|
|
135
|
+
? "**What I want to be able to do:**"
|
|
136
|
+
: "**What I did, expected, and got:**";
|
|
137
|
+
const body = [
|
|
138
|
+
`**Type:** ${KIND_TITLE[kind]}`,
|
|
139
|
+
input.tool ? `**Tool:** \`${input.tool}\`` : "",
|
|
140
|
+
"",
|
|
141
|
+
`${lead} ${summary || "_(describe)_"}`,
|
|
142
|
+
"",
|
|
143
|
+
kind === "feature"
|
|
144
|
+
? "**Why it matters / use case:** _(describe)_"
|
|
145
|
+
: "**Steps to reproduce:** _(describe — no sensitive values)_",
|
|
146
|
+
"",
|
|
147
|
+
REDACT_NOTE,
|
|
148
|
+
]
|
|
149
|
+
.filter((line, i) => !(line === "" && i === 2 && !input.tool))
|
|
150
|
+
.join("\n");
|
|
151
|
+
return {
|
|
152
|
+
reportUrl: buildIssueUrl({ title, body, labels: KIND_LABELS[kind] }),
|
|
153
|
+
repo: REPO_URL,
|
|
154
|
+
willPost: false,
|
|
155
|
+
instructions:
|
|
156
|
+
"Open reportUrl in a browser and submit the issue yourself — the server does NOT post anything automatically. Edit the prefilled title/body first if you like.",
|
|
157
|
+
privacy:
|
|
158
|
+
"The link prefills only your summary + tool name — no API keys, query values, or personal data. Keep it that way; the issue is public.",
|
|
159
|
+
};
|
|
160
|
+
}
|