@blen/fedreg-mcp-server 2.0.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/CHANGELOG.md +125 -0
- package/LICENSE +202 -0
- package/NOTICE +15 -0
- package/README.md +219 -0
- package/SECURITY.md +99 -0
- package/dist/auth/embedded.d.ts +2 -0
- package/dist/auth/embedded.d.ts.map +1 -0
- package/dist/auth/embedded.js +17 -0
- package/dist/auth/embedded.js.map +1 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +2 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +120 -0
- package/dist/bin.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/sandbox/deno.d.ts +13 -0
- package/dist/sandbox/deno.d.ts.map +1 -0
- package/dist/sandbox/deno.js +203 -0
- package/dist/sandbox/deno.js.map +1 -0
- package/dist/sandbox/index.d.ts +20 -0
- package/dist/sandbox/index.d.ts.map +1 -0
- package/dist/sandbox/index.js +46 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/isolate.d.ts +7 -0
- package/dist/sandbox/isolate.d.ts.map +1 -0
- package/dist/sandbox/isolate.js +100 -0
- package/dist/sandbox/isolate.js.map +1 -0
- package/dist/sandbox/policy.d.ts +7 -0
- package/dist/sandbox/policy.d.ts.map +1 -0
- package/dist/sandbox/policy.js +70 -0
- package/dist/sandbox/policy.js.map +1 -0
- package/dist/sandbox/types.d.ts +41 -0
- package/dist/sandbox/types.d.ts.map +1 -0
- package/dist/sandbox/types.js +2 -0
- package/dist/sandbox/types.js.map +1 -0
- package/dist/sdk/bindings.d.ts +10 -0
- package/dist/sdk/bindings.d.ts.map +1 -0
- package/dist/sdk/bindings.js +15 -0
- package/dist/sdk/bindings.js.map +1 -0
- package/dist/sdk/ecfr-client.d.ts +61 -0
- package/dist/sdk/ecfr-client.d.ts.map +1 -0
- package/dist/sdk/ecfr-client.js +45 -0
- package/dist/sdk/ecfr-client.js.map +1 -0
- package/dist/sdk/fr-client.d.ts +81 -0
- package/dist/sdk/fr-client.d.ts.map +1 -0
- package/dist/sdk/fr-client.js +77 -0
- package/dist/sdk/fr-client.js.map +1 -0
- package/dist/sdk/regs-client.d.ts +34 -0
- package/dist/sdk/regs-client.d.ts.map +1 -0
- package/dist/sdk/regs-client.js +44 -0
- package/dist/sdk/regs-client.js.map +1 -0
- package/dist/sdk/runtime.d.ts +21 -0
- package/dist/sdk/runtime.d.ts.map +1 -0
- package/dist/sdk/runtime.js +31 -0
- package/dist/sdk/runtime.js.map +1 -0
- package/dist/sdk/sources/corpus-loader.d.ts +6 -0
- package/dist/sdk/sources/corpus-loader.d.ts.map +1 -0
- package/dist/sdk/sources/corpus-loader.js +9 -0
- package/dist/sdk/sources/corpus-loader.js.map +1 -0
- package/dist/sdk/sources/ecfr.d.ts +3 -0
- package/dist/sdk/sources/ecfr.d.ts.map +1 -0
- package/dist/sdk/sources/ecfr.js +12 -0
- package/dist/sdk/sources/ecfr.js.map +1 -0
- package/dist/sdk/sources/fr.d.ts +3 -0
- package/dist/sdk/sources/fr.d.ts.map +1 -0
- package/dist/sdk/sources/fr.js +12 -0
- package/dist/sdk/sources/fr.js.map +1 -0
- package/dist/sdk/sources/index.d.ts +7 -0
- package/dist/sdk/sources/index.d.ts.map +1 -0
- package/dist/sdk/sources/index.js +25 -0
- package/dist/sdk/sources/index.js.map +1 -0
- package/dist/sdk/sources/regs.d.ts +3 -0
- package/dist/sdk/sources/regs.d.ts.map +1 -0
- package/dist/sdk/sources/regs.js +24 -0
- package/dist/sdk/sources/regs.js.map +1 -0
- package/dist/sdk/sources/source.d.ts +32 -0
- package/dist/sdk/sources/source.d.ts.map +1 -0
- package/dist/sdk/sources/source.js +2 -0
- package/dist/sdk/sources/source.js.map +1 -0
- package/dist/search/bm25.d.ts +25 -0
- package/dist/search/bm25.d.ts.map +1 -0
- package/dist/search/bm25.js +67 -0
- package/dist/search/bm25.js.map +1 -0
- package/dist/search/corpus.d.ts +24 -0
- package/dist/search/corpus.d.ts.map +1 -0
- package/dist/search/corpus.js +23 -0
- package/dist/search/corpus.js.map +1 -0
- package/dist/server/authz.d.ts +18 -0
- package/dist/server/authz.d.ts.map +1 -0
- package/dist/server/authz.js +42 -0
- package/dist/server/authz.js.map +1 -0
- package/dist/server/http.d.ts +21 -0
- package/dist/server/http.d.ts.map +1 -0
- package/dist/server/http.js +159 -0
- package/dist/server/http.js.map +1 -0
- package/dist/server/ipRateLimiter.d.ts +11 -0
- package/dist/server/ipRateLimiter.d.ts.map +1 -0
- package/dist/server/ipRateLimiter.js +27 -0
- package/dist/server/ipRateLimiter.js.map +1 -0
- package/dist/server/mcpServer.d.ts +15 -0
- package/dist/server/mcpServer.d.ts.map +1 -0
- package/dist/server/mcpServer.js +67 -0
- package/dist/server/mcpServer.js.map +1 -0
- package/dist/server/stdio.d.ts +3 -0
- package/dist/server/stdio.d.ts.map +1 -0
- package/dist/server/stdio.js +16 -0
- package/dist/server/stdio.js.map +1 -0
- package/dist/server/toolCatalog.d.ts +20 -0
- package/dist/server/toolCatalog.d.ts.map +1 -0
- package/dist/server/toolCatalog.js +29 -0
- package/dist/server/toolCatalog.js.map +1 -0
- package/dist/server/wellKnown.d.ts +16 -0
- package/dist/server/wellKnown.d.ts.map +1 -0
- package/dist/server/wellKnown.js +17 -0
- package/dist/server/wellKnown.js.map +1 -0
- package/dist/server/zodToJsonSchema.d.ts +7 -0
- package/dist/server/zodToJsonSchema.d.ts.map +1 -0
- package/dist/server/zodToJsonSchema.js +44 -0
- package/dist/server/zodToJsonSchema.js.map +1 -0
- package/dist/supervisor/index.d.ts +19 -0
- package/dist/supervisor/index.d.ts.map +1 -0
- package/dist/supervisor/index.js +22 -0
- package/dist/supervisor/index.js.map +1 -0
- package/dist/tools/describeSchema.d.ts +35 -0
- package/dist/tools/describeSchema.d.ts.map +1 -0
- package/dist/tools/describeSchema.js +14 -0
- package/dist/tools/describeSchema.js.map +1 -0
- package/dist/tools/execute.d.ts +33 -0
- package/dist/tools/execute.d.ts.map +1 -0
- package/dist/tools/execute.js +28 -0
- package/dist/tools/execute.js.map +1 -0
- package/dist/tools/searchApi.d.ts +27 -0
- package/dist/tools/searchApi.d.ts.map +1 -0
- package/dist/tools/searchApi.js +14 -0
- package/dist/tools/searchApi.js.map +1 -0
- package/dist/util/httpClient.d.ts +46 -0
- package/dist/util/httpClient.d.ts.map +1 -0
- package/dist/util/httpClient.js +139 -0
- package/dist/util/httpClient.js.map +1 -0
- package/dist/util/logger.d.ts +7 -0
- package/dist/util/logger.d.ts.map +1 -0
- package/dist/util/logger.js +19 -0
- package/dist/util/logger.js.map +1 -0
- package/dist/util/quotas.d.ts +13 -0
- package/dist/util/quotas.d.ts.map +1 -0
- package/dist/util/quotas.js +29 -0
- package/dist/util/quotas.js.map +1 -0
- package/dist/util/tokenBucket.d.ts +11 -0
- package/dist/util/tokenBucket.d.ts.map +1 -0
- package/dist/util/tokenBucket.js +30 -0
- package/dist/util/tokenBucket.js.map +1 -0
- package/package.json +95 -0
- package/schema/ecfr.json +148 -0
- package/schema/fr.json +194 -0
- package/schema/regs.json +67 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project
|
|
5
|
+
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [2.0.0] - 2026-08-06
|
|
10
|
+
|
|
11
|
+
**Breaking release.** The HTTP transport moves to the stateless MCP `2026-07-28`
|
|
12
|
+
protocol and tool arguments are now strictly validated. Pre-2026 MCP clients
|
|
13
|
+
keep working via a built-in legacy fallback. See the
|
|
14
|
+
[v2 migration guide](docs/migration-v2.md) for client and operator upgrade
|
|
15
|
+
steps.
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
- **MCP protocol upgraded to `2026-07-28` (stateless core).** BREAKING for the
|
|
19
|
+
HTTP transport. The `initialize`/`initialized` handshake and the
|
|
20
|
+
`Mcp-Session-Id` header are gone; each request is self-contained, carrying its
|
|
21
|
+
protocol version, client info, and capabilities in `_meta`. Requests can now
|
|
22
|
+
be load-balanced across replicas with no sticky routing or shared session
|
|
23
|
+
store. Migrated from `@modelcontextprotocol/sdk@1.x` to the v2 SDK
|
|
24
|
+
(`@modelcontextprotocol/server` + `@modelcontextprotocol/node` `2.0.0`), which
|
|
25
|
+
is the release line implementing this revision.
|
|
26
|
+
- **Per-subject quota attribution no longer depends on a session.** The
|
|
27
|
+
authenticated subject is re-derived from the caller's bearer token on every
|
|
28
|
+
request and passed to the tool catalog for that request only. This replaces
|
|
29
|
+
the 2025-era session-subject binding (and the `403 session_subject_mismatch`
|
|
30
|
+
guard added on `main` after v1.0.0, which never shipped in a release). The
|
|
31
|
+
binding existed to stop one tenant reusing another's session id to spend
|
|
32
|
+
or pollute their quota — an attack with no carrier now that no session id
|
|
33
|
+
exists.
|
|
34
|
+
- **Tool arguments are now validated against the advertised JSON Schema.**
|
|
35
|
+
BREAKING for clients that sent extra argument keys. `registerTool` attaches the
|
|
36
|
+
SDK's validator, and the generated schemas set `additionalProperties: false`, so
|
|
37
|
+
an unrecognized key returns `isError: true` with `"Input validation error: …
|
|
38
|
+
must NOT have additional properties"`. Under `1.x` the schema was advertisement
|
|
39
|
+
only and Zod silently stripped unknown keys.
|
|
40
|
+
- **An unknown tool name is now a JSON-RPC error, not a tool result.** It returns
|
|
41
|
+
`{"error":{"code":-32602,"message":"Tool X not found"}}` instead of the previous
|
|
42
|
+
`isError: true` content block, so clients must not read `result.isError` to
|
|
43
|
+
detect it.
|
|
44
|
+
- **Per-source corpora** — the merged `schema/field-dictionary.json` is now
|
|
45
|
+
split into per-source files (`schema/{fr,ecfr,regs}.json`), each loaded by
|
|
46
|
+
its own `Source` via a registry (`getSources`).
|
|
47
|
+
|
|
48
|
+
### Added
|
|
49
|
+
- `server/discover` — advertises supported protocol versions, capabilities, and
|
|
50
|
+
server identity on demand, replacing what the handshake used to carry.
|
|
51
|
+
- On modern (`2026-07-28`) requests the `Mcp-Method` routing header is
|
|
52
|
+
required — plus `Mcp-Name` for `tools/call` — and is validated against the
|
|
53
|
+
request body; a missing or disagreeing header is rejected with `-32020`
|
|
54
|
+
(`HeaderMismatch`). Legacy requests are unaffected.
|
|
55
|
+
- `tools/list` and `server/discover` results carry `ttlMs` (300 s) and
|
|
56
|
+
`cacheScope: "public"`. The catalog derives only from process configuration,
|
|
57
|
+
never from the caller, so it is identical for every tenant and safe to share.
|
|
58
|
+
- Backward compatibility for pre-2026 clients: requests without the `_meta`
|
|
59
|
+
envelope are classified as legacy and answered by a per-request stateless
|
|
60
|
+
`2025-11-25` fallback, so the `initialize` handshake keeps working. No session
|
|
61
|
+
is minted on either path.
|
|
62
|
+
|
|
63
|
+
- **regulations.gov source** — a third SDK binding, `regs.*`
|
|
64
|
+
(`documents`, `comments`, `dockets`, each with `search` / `get`), exposing
|
|
65
|
+
public comments, dockets, and live comment-period status. Requires a free
|
|
66
|
+
API key (`FEDREG_REGS_API_KEY`); the key is held host-side and never reaches
|
|
67
|
+
the sandbox. Without it, `regs` is disabled (`SourceUnavailable`) while `fr`
|
|
68
|
+
and `ecfr` keep working. Configurable via `FEDREG_REGS_BASE_URL` and a
|
|
69
|
+
per-`execute()` upstream-call budget (`FEDREG_REGS_MAX_CALLS_PER_EXECUTE`,
|
|
70
|
+
default 30).
|
|
71
|
+
- **regulations.gov rate guardrails** — to protect the shared api.data.gov key:
|
|
72
|
+
a process-wide hourly token bucket (`FEDREG_REGS_RATE_PER_HOUR`, default 1000;
|
|
73
|
+
in-memory, so it does not coordinate across replicas), a per-authenticated-subject
|
|
74
|
+
hourly quota in HTTP mode (`FEDREG_REGS_SUBJECT_RATE_PER_HOUR`, default 500), and
|
|
75
|
+
no-429-retry on `regs`. The GET response cache key now also incorporates a redacted
|
|
76
|
+
auth-context hash (no cross-key cache bleed), and the per-subject quota is keyed on
|
|
77
|
+
the subject the request's own bearer token verified as.
|
|
78
|
+
|
|
79
|
+
### Removed
|
|
80
|
+
- `FEDREG_MAX_SESSIONS` — there are no protocol sessions left to cap. An existing
|
|
81
|
+
deployment that still sets it is silently ignored rather than erroring.
|
|
82
|
+
- `GET`/`DELETE` on `/mcp` (2025-era session operations) now return `405`.
|
|
83
|
+
- `subscriptions/listen` is refused (`maxSubscriptions: 0`). This server declares
|
|
84
|
+
only the `tools` capability, but the SDK routes the method regardless and would
|
|
85
|
+
otherwise hold up to 1024 long-lived SSE streams per handler — the unbounded
|
|
86
|
+
long-lived state that `FEDREG_MAX_SESSIONS` used to cap.
|
|
87
|
+
|
|
88
|
+
## [1.0.0] - 2026-05-20
|
|
89
|
+
|
|
90
|
+
Initial public release.
|
|
91
|
+
|
|
92
|
+
### Added
|
|
93
|
+
- **Three-tool code-mode MCP surface** — `search_api`, `describe_schema`,
|
|
94
|
+
`execute` (the same pattern as `clinicaltrials-mcp-server`).
|
|
95
|
+
- **SDK bindings** — `fr.*` for FederalRegister.gov v1 (`documents`,
|
|
96
|
+
`publicInspection`, `agencies`, `issues`, `suggestedSearches`, `images`)
|
|
97
|
+
and `ecfr.*` for the Electronic Code of Federal Regulations (`titles`,
|
|
98
|
+
`admin.agencies`, `structure`, `ancestry`, `versions`, `full`, `search.*`).
|
|
99
|
+
- **BM25 search** over a curated endpoint + field dictionary
|
|
100
|
+
(`schema/field-dictionary.json`).
|
|
101
|
+
- **Sandbox** — `isolated-vm` (primary) and Deno subprocess (fallback) with
|
|
102
|
+
shared AST preflight via `acorn`, wall-clock timeout, and heap cap.
|
|
103
|
+
- **stdio transport** for Claude Desktop and MCPB.
|
|
104
|
+
- **Streamable HTTP transport** built on `@modelcontextprotocol/sdk` 1.29:
|
|
105
|
+
per-session `StreamableHTTPServerTransport`, SSE streaming, graceful
|
|
106
|
+
SIGTERM/SIGINT drain.
|
|
107
|
+
- **OAuth 2.0 Protected Resource Metadata** per RFC 9728 at
|
|
108
|
+
`/.well-known/oauth-protected-resource/mcp`, `WWW-Authenticate` header
|
|
109
|
+
pointing at it on 401.
|
|
110
|
+
- **Bearer token verification** via `jose` against any JWKS endpoint
|
|
111
|
+
(presets: `clerk`, `workos`, `auth0`, `generic-oidc`; `embedded` HS256
|
|
112
|
+
for dev).
|
|
113
|
+
- **Hardening** — per-IP token-bucket rate limiting, per-subject daily
|
|
114
|
+
quotas, Host-header allowlist for DNS-rebinding protection.
|
|
115
|
+
- **Deploy** — multi-stage Dockerfile (`deploy/Dockerfile`) that builds
|
|
116
|
+
`isolated-vm` and slims to a `node:22-bookworm-slim` runtime, plus a
|
|
117
|
+
Railway walkthrough in `deploy/RAILWAY.md`.
|
|
118
|
+
- **27 tests** across BM25, sandbox policy, both SDK clients (vs `undici`
|
|
119
|
+
MockAgent), HTTP rate limiter, and an end-to-end MCP flow (initialize
|
|
120
|
+
→ notifications/initialized → tools/list → tools/call → sandbox → SDK
|
|
121
|
+
→ mocked upstream).
|
|
122
|
+
|
|
123
|
+
[Unreleased]: https://github.com/blen-labs/fedreg-mcp-server/compare/v2.0.0...HEAD
|
|
124
|
+
[2.0.0]: https://github.com/blen-labs/fedreg-mcp-server/compare/v1.0.0...v2.0.0
|
|
125
|
+
[1.0.0]: https://github.com/blen-labs/fedreg-mcp-server/releases/tag/v1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@blen/fedreg-mcp-server
|
|
2
|
+
Copyright 2026 BLEN, Inc.
|
|
3
|
+
|
|
4
|
+
This product includes software developed at BLEN, Inc. (https://blenlabs.com).
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License.
|
|
8
|
+
You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
This product fetches data from public U.S. government APIs:
|
|
13
|
+
- FederalRegister.gov API v1 (U.S. Government Publishing Office / National Archives)
|
|
14
|
+
- Electronic Code of Federal Regulations (eCFR) API
|
|
15
|
+
- Regulations.gov API v4 (U.S. General Services Administration / api.data.gov)
|
package/README.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Federal Register MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://github.com/blen-labs/fedreg-mcp-server/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/@blen/fedreg-mcp-server)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
[](https://modelcontextprotocol.io/specification/2026-07-28)
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<video src="https://github.com/blen-labs/fedreg-mcp-server/raw/main/media/fedreg-launch.mp4" poster="https://raw.githubusercontent.com/blen-labs/fedreg-mcp-server/main/media/launch-poster.png" controls muted playsinline width="760"></video>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
**Ask your AI assistant real questions about U.S. federal regulations — and get answers grounded in the official Federal Register, eCFR, and regulations.gov.**
|
|
14
|
+
|
|
15
|
+
This is a [Model Context Protocol](https://modelcontextprotocol.io) server that connects any MCP client (Claude Desktop and others) to three official U.S. government sources:
|
|
16
|
+
|
|
17
|
+
- **[Federal Register](https://www.federalregister.gov)** — the daily journal of the federal government: rules, proposed rules, notices, and presidential documents since 1994.
|
|
18
|
+
- **[Electronic Code of Federal Regulations (eCFR)](https://www.ecfr.gov)** — the current, continuously updated text of the Code of Federal Regulations.
|
|
19
|
+
- **[regulations.gov](https://www.regulations.gov)** — public comments, dockets, and live comment-period status for federal rulemakings.
|
|
20
|
+
|
|
21
|
+
Instead of bolting on dozens of rigid, narrow tools, it hands the model a small, well-typed TypeScript SDK and lets it write the exact query it needs — then runs that code in a locked-down sandbox. This is the **code-mode** pattern, and it makes wide government APIs usable without overwhelming the model with tool definitions.
|
|
22
|
+
|
|
23
|
+
> Independent open-source project. It calls public U.S. government APIs and is not affiliated with or endorsed by the U.S. government.
|
|
24
|
+
|
|
25
|
+
## See it in action
|
|
26
|
+
|
|
27
|
+
Ask Claude:
|
|
28
|
+
|
|
29
|
+
> *"What does 50 CFR 21.150 cover, and have there been recent Federal Register rules touching migratory-bird depredation?"*
|
|
30
|
+
|
|
31
|
+
The model finds the right calls and runs them in the sandbox — no hand-written tool per endpoint:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// Pull the current text of an eCFR section…
|
|
35
|
+
const { titles } = await ecfr.titles.list();
|
|
36
|
+
const date = titles.find(t => t.number === 50).latest_issue_date;
|
|
37
|
+
const section = await ecfr.full(date, 50, { part: '21', section: '21.150' });
|
|
38
|
+
|
|
39
|
+
// …and search the Federal Register for related rulemaking.
|
|
40
|
+
const rules = await fr.documents.search({
|
|
41
|
+
conditions: { term: 'migratory bird depredation', type: ['RULE', 'PRORULE'] },
|
|
42
|
+
fields: ['title', 'publication_date', 'html_url'],
|
|
43
|
+
per_page: 5,
|
|
44
|
+
order: 'newest',
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
…then answers in plain English, citing the section and the rules it found.
|
|
49
|
+
|
|
50
|
+
## Features
|
|
51
|
+
|
|
52
|
+
- **Three official sources, one server** — the full Federal Register v1 (`fr.*`), eCFR (`ecfr.*`), and regulations.gov v4 (`regs.*`) APIs behind one server.
|
|
53
|
+
- **Code mode, not tool sprawl** — the model writes TypeScript against typed `fr` / `ecfr` / `regs` SDKs instead of juggling dozens of single-purpose tools.
|
|
54
|
+
- **Safe by construction** — user code runs in an `isolated-vm` (or Deno) sandbox with **no network, filesystem, env, or subprocess access**. The only way out is to the three upstream government APIs.
|
|
55
|
+
- **Runs anywhere MCP does** — stdio for Claude Desktop, or a remote Streamable HTTP server with OAuth, rate limiting, and quotas.
|
|
56
|
+
- **Discovery built in** — `search_api` and `describe_schema` help the model (and you) find the right call fast.
|
|
57
|
+
|
|
58
|
+
## Which source for what
|
|
59
|
+
|
|
60
|
+
| Need | Source |
|
|
61
|
+
|---|---|
|
|
62
|
+
| Daily rules, proposed rules, notices; FR document metadata since 1994 | `fr` |
|
|
63
|
+
| Current Code of Federal Regulations text | `ecfr` |
|
|
64
|
+
| Public comments, dockets, live comment-period status | `regs` |
|
|
65
|
+
|
|
66
|
+
For canonical Federal Register rule text and metadata since 1994, prefer `fr.documents` — regulations.gov documents overlap it. Reach for `regs` when you need what only it has: public **comments**, **dockets**, and live comment-period status.
|
|
67
|
+
|
|
68
|
+
### regulations.gov API key
|
|
69
|
+
|
|
70
|
+
regulations.gov requires a free API key from [api.data.gov / open.gsa.gov](https://open.gsa.gov/api/regulationsgov/). Set it via `FEDREG_REGS_API_KEY`. The key is held host-side and never reaches the sandbox.
|
|
71
|
+
|
|
72
|
+
Without a key the `regs` source is **disabled** — `regs.*` calls return a clear `SourceUnavailable` error, while `fr` and `ecfr` keep working normally.
|
|
73
|
+
|
|
74
|
+
Because the regulations.gov key is shared, `regs` upstream calls are bounded by a process-wide hourly bucket (`FEDREG_REGS_RATE_PER_HOUR`), a per-subject hourly quota in HTTP mode (`FEDREG_REGS_SUBJECT_RATE_PER_HOUR`; under `--insecure` all callers share the single `anonymous` bucket, and stdio skips it), and a per-`execute()` call budget (`FEDREG_REGS_MAX_CALLS_PER_EXECUTE`). For the two hourly rates, `0` is **not** "unlimited" — it blocks all regs calls; to disable regs entirely, leave `FEDREG_REGS_API_KEY` unset.
|
|
75
|
+
|
|
76
|
+
### Bridge example: comments on a Federal Register rule
|
|
77
|
+
|
|
78
|
+
`frDocNum` is a *returned* attribute on regs documents, not a filter — so bridge from FR to regulations.gov via the document number as a `searchTerm`:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
// 1. Find the rule in the Federal Register and read its document number.
|
|
82
|
+
const fr1 = await fr.documents.search({
|
|
83
|
+
conditions: { term: 'methane', type: ['RULE'] },
|
|
84
|
+
per_page: 1,
|
|
85
|
+
order: 'newest',
|
|
86
|
+
});
|
|
87
|
+
const docNum = fr1.results[0].document_number;
|
|
88
|
+
|
|
89
|
+
// 2. Look it up on regulations.gov by document number, then read its objectId.
|
|
90
|
+
const rd = await regs.documents.search({ filter: { searchTerm: docNum } });
|
|
91
|
+
const objectId = rd.data[0].attributes.objectId;
|
|
92
|
+
|
|
93
|
+
// 3. Pull the public comments filed on that document.
|
|
94
|
+
const comments = await regs.comments.search({
|
|
95
|
+
filter: { commentOnId: objectId },
|
|
96
|
+
page: { size: 250 },
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Quickstart (Claude Desktop)
|
|
101
|
+
|
|
102
|
+
Add the server to your Claude Desktop config (**Settings → Developer → Edit Config**):
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"mcpServers": {
|
|
107
|
+
"fedreg": {
|
|
108
|
+
"command": "npx",
|
|
109
|
+
"args": ["-y", "@blen/fedreg-mcp-server"]
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Restart Claude Desktop, then just ask in plain language:
|
|
116
|
+
|
|
117
|
+
> *"Find EPA methane rules published since 2024."*
|
|
118
|
+
> *"What does 40 CFR Part 60 cover?"*
|
|
119
|
+
> *"Which proposed rules opened for public comment this week?"*
|
|
120
|
+
|
|
121
|
+
Requires **Node.js ≥ 20.10**. `npx` downloads and runs the server on demand; no global install needed. If the `execute` tool reports `SandboxUnavailable`, see [Sandbox runtimes](#sandbox-runtimes).
|
|
122
|
+
|
|
123
|
+
## How it works
|
|
124
|
+
|
|
125
|
+
Three tools, in the order the model uses them:
|
|
126
|
+
|
|
127
|
+
| Tool | What it does |
|
|
128
|
+
|---|---|
|
|
129
|
+
| `search_api(query, k?)` | Finds the right endpoint/field via BM25 over the SDK docs. Returns ready-to-run TypeScript snippets. |
|
|
130
|
+
| `describe_schema({ path? \| prefix? })` | Looks up an exact call or lists a whole namespace. |
|
|
131
|
+
| `execute({ code, timeoutMs?, memoryMb? })` | Runs TypeScript in the sandbox, with `fr`, `ecfr`, and `regs` as globals. (`regs` is always defined; without `FEDREG_REGS_API_KEY` its calls return a `SourceUnavailable` error rather than a `ReferenceError`.) |
|
|
132
|
+
|
|
133
|
+
A request flows from the MCP client through `execute` into the sandbox; the `fr.*` / `ecfr.*` / `regs.*` globals are thin proxies that marshal each call across a host-side RPC bridge to the real APIs:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
MCP client → execute(code) → sandbox → fr.* / ecfr.* / regs.* RPC bridge → upstream APIs
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Full SDK surface: [`docs/sdk-reference.md`](./docs/sdk-reference.md) · Architecture: [`docs/architecture.md`](./docs/architecture.md) · Paste-ready examples: [`examples/`](./examples/).
|
|
140
|
+
|
|
141
|
+
## Sandbox runtimes
|
|
142
|
+
|
|
143
|
+
`execute` needs a sandbox runner. The server picks one automatically:
|
|
144
|
+
|
|
145
|
+
1. **`isolated-vm`** (preferred) — a fresh V8 isolate. Built automatically during install on Linux/macOS/Windows (x64/arm64) where a C++ toolchain is present.
|
|
146
|
+
2. **Deno** (fallback) — used when `isolated-vm` isn't available and `deno` is on `PATH`.
|
|
147
|
+
3. If neither is available, `search_api` and `describe_schema` still work; `execute` returns `SandboxUnavailable`.
|
|
148
|
+
|
|
149
|
+
> On very new Node majors, `isolated-vm` may not have a compatible prebuild yet. Install [Deno](https://docs.deno.com/runtime/getting_started/installation/) and run with `--sandbox deno` (or `FEDREG_SANDBOX=deno`). Node 20 and 22 build `isolated-vm` cleanly.
|
|
150
|
+
|
|
151
|
+
## Self-hosting (remote HTTP)
|
|
152
|
+
|
|
153
|
+
Run a shared, authenticated endpoint over Streamable HTTP:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Dev only — no auth, loopback-bound:
|
|
157
|
+
npx @blen/fedreg-mcp-server --http --insecure --host 127.0.0.1 --port 8080
|
|
158
|
+
|
|
159
|
+
# Production — auth via any OIDC issuer:
|
|
160
|
+
FEDREG_AUTH_PROVIDER=clerk \
|
|
161
|
+
FEDREG_AUTH_ISSUER=https://<tenant>.clerk.accounts.dev \
|
|
162
|
+
FEDREG_AUTH_JWKS_URL=https://<tenant>.clerk.accounts.dev/.well-known/jwks.json \
|
|
163
|
+
FEDREG_PUBLIC_ORIGIN=https://your-host.example.com \
|
|
164
|
+
FEDREG_ALLOWED_HOSTS=your-host.example.com \
|
|
165
|
+
npx @blen/fedreg-mcp-server --http
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Then point any MCP client at it:
|
|
169
|
+
|
|
170
|
+
```json
|
|
171
|
+
{ "mcpServers": { "fedreg": { "type": "http", "url": "https://your-host.example.com/mcp" } } }
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The HTTP transport implements the stateless MCP `2026-07-28` Streamable HTTP profile — no `initialize` handshake and no `Mcp-Session-Id`, so requests can be load-balanced across replicas without sticky routing. Pre-2026 clients are still served through a stateless legacy fallback. It adds OAuth 2.0 Protected Resource Metadata (RFC 9728), per-IP rate limiting, per-subject daily quotas, and Host-header allowlisting. A step-by-step Railway walkthrough is in [`deploy/RAILWAY.md`](./deploy/RAILWAY.md); the bundled [`Dockerfile`](./deploy/Dockerfile) precompiles `isolated-vm` and slims to a ~220 MB `node:22-bookworm-slim` runtime.
|
|
175
|
+
|
|
176
|
+
### Configuration
|
|
177
|
+
|
|
178
|
+
The most common knobs (full list and defaults in [`.env.example`](./.env.example)):
|
|
179
|
+
|
|
180
|
+
| Variable | Default | Notes |
|
|
181
|
+
|---|---|---|
|
|
182
|
+
| `FEDREG_SANDBOX` | `auto` | `auto` / `isolate` / `deno` |
|
|
183
|
+
| `FEDREG_USER_AGENT` | `fedreg-mcp-server/2.0 …` | Identify yourself, per FR/eCFR etiquette. |
|
|
184
|
+
| `FEDREG_REGS_API_KEY` | — | Free key from regulations.gov / api.data.gov. Unset ⇒ `regs` disabled (fr/ecfr unaffected). |
|
|
185
|
+
| `FEDREG_REGS_BASE_URL` | `https://api.regulations.gov` | regulations.gov v4 API base URL. |
|
|
186
|
+
| `FEDREG_REGS_MAX_CALLS_PER_EXECUTE` | `30` | Caps regulations.gov upstream calls per `execute()` run (rate-limit guardrail). |
|
|
187
|
+
| `FEDREG_REGS_RATE_PER_HOUR` | `1000` | Process-wide cap on regs upstream calls/hour (protects the shared key). In-memory; with N replicas, divide by N. Must be ≥ 1. |
|
|
188
|
+
| `FEDREG_REGS_SUBJECT_RATE_PER_HOUR` | `500` | Per-subject regs calls/hour (HTTP mode only; skipped on stdio; one shared `anonymous` bucket under `--insecure`). Must be ≥ 1. |
|
|
189
|
+
| `FEDREG_AUTH_PROVIDER` | `none` | `none` / `embedded` / `generic-oidc` / `clerk` / `workos` / `auth0` |
|
|
190
|
+
| `FEDREG_PUBLIC_ORIGIN` | — | Public origin clients reach (used in OAuth metadata). |
|
|
191
|
+
| `FEDREG_SUBJECT_DAILY_QUOTA` | `10000` | Requests per authenticated subject per UTC day. |
|
|
192
|
+
|
|
193
|
+
CLI options: `--http`, `--port`, `--host`, `--sandbox auto|isolate|deno`, `--insecure`, `--help`.
|
|
194
|
+
|
|
195
|
+
## Security
|
|
196
|
+
|
|
197
|
+
User code is sandboxed by design — no network, filesystem, env, or subprocess access, an `acorn` AST preflight, a wall-clock timeout, and — on the `isolated-vm` runner — a heap cap (`memoryMb` is not enforceable on the Deno fallback). The full threat model is in [`SECURITY.md`](./SECURITY.md). Found a sandbox escape or auth bypass? Please open a [private Security Advisory](https://github.com/blen-labs/fedreg-mcp-server/security/advisories/new) rather than a public issue.
|
|
198
|
+
|
|
199
|
+
## Contributing
|
|
200
|
+
|
|
201
|
+
Contributions are welcome — see [`CONTRIBUTING.md`](./CONTRIBUTING.md) for the dev setup and ground rules, and please open an issue before anything non-trivial. By participating you agree to the [Code of Conduct](./CODE_OF_CONDUCT.md).
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
[Apache-2.0](./LICENSE) © 2026 BLEN, Inc. See also [`NOTICE`](./NOTICE).
|
|
206
|
+
|
|
207
|
+
## Acknowledgements
|
|
208
|
+
|
|
209
|
+
- The U.S. Government Publishing Office and the National Archives for publishing the Federal Register and eCFR APIs.
|
|
210
|
+
- The [Model Context Protocol](https://modelcontextprotocol.io) team for the spec and TypeScript SDK.
|
|
211
|
+
- The teams who popularized the code-mode pattern for wide APIs.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## About BLEN
|
|
216
|
+
|
|
217
|
+
BLEN, Inc is a digital services company that provides Emerging Technology (ML/AI, RPA), Digital Modernization (Legacy to Cloud), and Human-Centered Web/Mobile Design and Development.
|
|
218
|
+
|
|
219
|
+
Built with ❤️ by [BLEN, Inc](https://www.blenlabs.com).
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
Please **do not file public GitHub issues for security reports**. Instead,
|
|
6
|
+
open a private GitHub Security Advisory:
|
|
7
|
+
|
|
8
|
+
> <https://github.com/blen-labs/fedreg-mcp-server/security/advisories/new>
|
|
9
|
+
|
|
10
|
+
If that's not available, contact the maintainers via the GitHub organization
|
|
11
|
+
page at <https://github.com/blen-labs>.
|
|
12
|
+
|
|
13
|
+
We try to respond within **3 business days**. A typical timeline for a
|
|
14
|
+
confirmed sandbox-escape report:
|
|
15
|
+
|
|
16
|
+
1. Initial acknowledgement and severity triage — within 3 business days.
|
|
17
|
+
2. Coordinated fix in a private branch — within 14 days for critical, 30 for
|
|
18
|
+
high-severity issues.
|
|
19
|
+
3. Patched release published to npm with a credit line (unless you ask not
|
|
20
|
+
to be credited).
|
|
21
|
+
4. Public advisory and CVE filing once users have had reasonable upgrade time.
|
|
22
|
+
|
|
23
|
+
## Scope
|
|
24
|
+
|
|
25
|
+
In scope:
|
|
26
|
+
- **Sandbox escapes** — any code in `execute` that gets host filesystem,
|
|
27
|
+
network, environment, subprocess, native binding, or out-of-isolate
|
|
28
|
+
references.
|
|
29
|
+
- **AST preflight bypasses** — code that passes `preflight()` in
|
|
30
|
+
`src/sandbox/policy.ts` but performs disallowed operations at runtime.
|
|
31
|
+
- **Auth bypass** — sending requests to `/mcp` without a valid bearer that
|
|
32
|
+
reaches a tool handler.
|
|
33
|
+
- **DNS rebinding / SSRF** against the HTTP transport.
|
|
34
|
+
- **Quota / rate-limit bypass** that allows a single subject or IP to exceed
|
|
35
|
+
the configured ceiling.
|
|
36
|
+
|
|
37
|
+
Out of scope (please file a normal issue instead):
|
|
38
|
+
- Upstream API rate limits (those are FederalRegister.gov / eCFR /
|
|
39
|
+
regulations.gov limits; see the `FEDREG_REGS_*` guardrails in the README).
|
|
40
|
+
- Denial of service via lawful but expensive queries (we accept this risk
|
|
41
|
+
on a per-tenant basis; tune `FEDREG_SUBJECT_DAILY_QUOTA` and
|
|
42
|
+
`FEDREG_IP_RPS`).
|
|
43
|
+
- Issues that only occur with `--insecure` (which is documented as dev-only).
|
|
44
|
+
|
|
45
|
+
## Sandbox guarantees
|
|
46
|
+
|
|
47
|
+
The `execute` tool runs user-supplied TypeScript with two layered defenses:
|
|
48
|
+
|
|
49
|
+
1. **AST preflight** (`acorn` + `acorn-walk`, see `src/sandbox/policy.ts`):
|
|
50
|
+
rejects `import` / `import()` / `eval` / `new Function` and references to
|
|
51
|
+
`process`, `globalThis`, `Buffer`, `Deno`, `fetch`, `Worker`, plus
|
|
52
|
+
`__proto__` / `constructor` / `prototype` member access. The check rejects
|
|
53
|
+
*static* uses of these names; runtime synthesis (e.g. via string
|
|
54
|
+
concatenation) is the next layer's job.
|
|
55
|
+
2. **Runtime isolation** — one of:
|
|
56
|
+
- `isolated-vm`: a fresh V8 isolate, **no host references** other than
|
|
57
|
+
a single Reference to the RPC dispatcher; heap cap, wall-clock cap.
|
|
58
|
+
- `deno run --no-prompt <runner>`: subprocess with **no `--allow-*` flags**,
|
|
59
|
+
so no net/fs/env/ffi/subprocess access; wall-clock cap. The runner is a
|
|
60
|
+
temporary file so stdin stays free for the host RPC channel.
|
|
61
|
+
|
|
62
|
+
Both runners deny network access to user code; the only way to reach
|
|
63
|
+
upstream APIs is via the `fr.*` / `ecfr.*` / `regs.*` proxies, which serialize
|
|
64
|
+
calls through a host-side RPC and execute them against the configured URL
|
|
65
|
+
allowlist (`FEDREG_FR_BASE_URL`, `FEDREG_ECFR_BASE_URL`,
|
|
66
|
+
`FEDREG_REGS_BASE_URL`).
|
|
67
|
+
|
|
68
|
+
The regulations.gov API key (`FEDREG_REGS_API_KEY`) is held host-side in the
|
|
69
|
+
`HttpClient` and is **never exposed to sandboxed user code**: it is injected
|
|
70
|
+
into the upstream request on the host side of the RPC bridge, not passed into
|
|
71
|
+
the sandbox, so user code cannot read or exfiltrate it.
|
|
72
|
+
|
|
73
|
+
We treat any of the following as a vulnerability:
|
|
74
|
+
- Reading the contents of any file under `/`.
|
|
75
|
+
- Establishing any outbound socket to a host not configured in the SDK.
|
|
76
|
+
- Reading process environment variables.
|
|
77
|
+
- Reading or modifying host globals (this includes obtaining `globalThis`,
|
|
78
|
+
`Reflect`, `Function`, `eval`, or any constructor reachable from them).
|
|
79
|
+
- Causing the host process to crash or hang past `timeoutMs * 2`.
|
|
80
|
+
|
|
81
|
+
## Threat model
|
|
82
|
+
|
|
83
|
+
This server is designed to be exposed to **untrusted MCP clients** behind
|
|
84
|
+
an authenticated edge. Authentication is provided by an external OIDC issuer
|
|
85
|
+
(Clerk / WorkOS / Auth0 / generic OIDC) and verified via JWKS. The HTTP
|
|
86
|
+
transport adds Host-header allowlisting (DNS rebinding), per-IP token-bucket
|
|
87
|
+
rate limiting, and per-subject daily quotas.
|
|
88
|
+
|
|
89
|
+
This server is **not** designed to be a public unauthenticated endpoint.
|
|
90
|
+
Operators who deploy with `--insecure` are explicitly opting out of all
|
|
91
|
+
auth-layer protections and accept the resulting risk.
|
|
92
|
+
|
|
93
|
+
## Dependencies
|
|
94
|
+
|
|
95
|
+
We track advisories on direct runtime dependencies — `@modelcontextprotocol/server`,
|
|
96
|
+
`@modelcontextprotocol/node`, `undici`, `jose`, `acorn`, `lru-cache`, `zod`, and the
|
|
97
|
+
optional `isolated-vm`.
|
|
98
|
+
For an advisory in any of these that affects this server, expect a patch
|
|
99
|
+
release within the timeline above.
|