@20baht/elysia-openapi-mcp 0.0.0-stage → 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/CHANGELOG.md ADDED
@@ -0,0 +1,142 @@
1
+ # Changelog
2
+
3
+ All notable changes to this package are documented here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). This package uses
5
+ [Semantic Versioning](https://semver.org/); before 1.0, a minor bump may break.
6
+
7
+ ## 0.1.0
8
+
9
+ First release as `@20baht/elysia-openapi-mcp`, the same code as `elysia-openapi-mcp` 0.4.0 (the last version under the old name, which gets deprecated in favour of this one). Every 20baht library moved into one repo ([bank20baht/20baht](https://github.com/bank20baht/20baht)) and the `@20baht` npm scope, and restarted at 0.1.0. Change the dependency and the imports from `elysia-openapi-mcp` to `@20baht/elysia-openapi-mcp`; nothing else changes.
10
+
11
+ ## 0.4.0
12
+
13
+ ### Breaking
14
+
15
+ - **CORS is off by default in request mode.** With `auth: { verify }`, `cors`
16
+ now defaults to `false`: no `Access-Control-*` headers, so a page on another
17
+ origin cannot read answers (or get its preflight approved). Before, any
18
+ `Origin` was reflected, which next to a cookie-trusting `verify` and an
19
+ app-wide `allow-credentials` let any site call the tools from a signed-in
20
+ browser. To keep browser access, list your front ends:
21
+ `cors: { origins: ['https://app.example'] }`. `cors: true` still reflects
22
+ every origin, and now warns in request mode (`cors-reflects-origin`). OAuth
23
+ mode and `unsafeNoAuth` keep the `true` default.
24
+
25
+ ### Added
26
+
27
+ - `cors: { origins: string[] | (origin) => boolean }`: CORS for listed origins
28
+ only. Any other origin gets no `Access-Control-Allow-Origin`, just
29
+ `Vary: Origin`. `McpifyCorsOption` type export.
30
+ - **Request-mode results.** `auth.verify` may return, besides a boolean:
31
+ - a refusal `{ status, code?, message }`, answered as that JSON-RPC error
32
+ with that HTTP status (`code` defaults to `-32001`);
33
+ - an admission `{ scopes?, tools?, readOnly? }`, which filters `tools/list`
34
+ and `tools/call` for that request. `scopes` checks each tool's
35
+ `detail.mcp.scopes` as OAuth mode does, `readOnly: true` keeps the
36
+ `readOnlyHint` tools, `tools` is a predicate. A tool left out answers
37
+ `Tool <name> not found`, like a name that does not exist.
38
+ - Malformed results fail closed (`401`) with a `verify-error` warning.
39
+ - `RequestAuthResult`, `RequestAuthRefusal` and `RequestAuthAdmission` type
40
+ exports.
41
+ - `onToolCall({ tool, args, request, response, durationMs })`: awaited after
42
+ each tool call that reached the app, with a copy of the response. A throw is
43
+ reported as `on-tool-call-error` and does not fail the call. `OnToolCall`
44
+ and `ToolCallEvent` type exports.
45
+ - `isToolCall(request)`: `true` for the synthetic request a tool call runs
46
+ through the app, in every hook and handler. Backed by a module `WeakSet`, so
47
+ there is no header to forge or strip.
48
+ - `detail.mcp.output`: a JSON Schema (TypeBox works) used as the tool's
49
+ `outputSchema` in place of the one derived from `response`. Elysia does not
50
+ enforce it.
51
+ - New warning kinds `cors-reflects-origin` and `on-tool-call-error`.
52
+
53
+ ### Changed
54
+
55
+ - **Guarded OpenAPI route.** When `specPath` exists but does not serve the
56
+ document to a caller without credentials, the document is built in-process
57
+ with `toOpenAPISchema(app)` instead of answering every MCP request with a
58
+ `500`. That build lacks the `openapi()` plugin's own options. The served
59
+ document is still read first. `@elysiajs/openapi` is now an optional peer
60
+ dependency, loaded with a dynamic `import()` for this fallback only.
61
+ - `initialize` reports the document's `info.title` / `info.version` when
62
+ `name` / `version` are not set. `@elysiajs/openapi`'s placeholder
63
+ (`Elysia Documentation`, `0.0.0`) is ignored, leaving the old defaults.
64
+ - A property without a description that is an `anyOf` / `oneOf` with one
65
+ non-null member takes that member's description
66
+ (`t.Optional(t.Nullable(t.Integer({ description })))`), so it no longer
67
+ warns `argument-description`.
68
+ - The default `warn` sink (`console.warn`) prints each distinct message once
69
+ per process, across `mcpify()` instances. A custom `warn` still gets every
70
+ warning of its instance.
71
+ - In request mode `scopes-not-enforced` fires when a request is admitted
72
+ without `{ scopes }`, not at startup. With `unsafeNoAuth` it is unchanged.
73
+ - `verify-error` also covers malformed `verify` results and a throwing
74
+ admission `tools` predicate (that tool is hidden).
75
+
76
+ ## 0.3.1
77
+
78
+ ### Added
79
+
80
+ - **Request-mode auth:** `auth: { verify(request) => boolean | Promise<boolean> }`
81
+ for apps guarded by an API key or a session cookie. It counts as `auth` for
82
+ the 0.3.0 auth-or-`unsafeNoAuth` rule. It gates the whole endpoint
83
+ (`initialize` and `tools/list` included); only a literal `true` admits, and
84
+ a throw rejects. A rejection is a `401` JSON-RPC error with
85
+ `Cache-Control: no-store` and no `WWW-Authenticate` challenge, so clients are
86
+ not sent into an OAuth flow that cannot succeed. No PRM document is served.
87
+ OAuth mode (`resource` + `authorizationServers`) is unchanged; OAuth-only
88
+ keys without `resource` throw at setup.
89
+ - **Warning kinds:** every warning has a kind (`MCPIFY_WARNING_KINDS`), passed
90
+ as the second argument to `warn(message, kind)`. `warnings: { kind: false }`
91
+ silences one kind, e.g. `{ unauthenticated: false }` for the `unsafeNoAuth`
92
+ banner or `{ 'path-param-description': false }` for undocumented path
93
+ parameters. Unknown kinds throw.
94
+ - `deriveTools()` and `flattenOperation()` return
95
+ `diagnostics: { kind, message }[]` next to `warnings`.
96
+ - `McpifyRequestAuthOptions`, `McpifyWarning` and `McpifyWarningKind` type
97
+ exports.
98
+
99
+ ### Changed
100
+
101
+ - Missing descriptions on path parameters are reported apart from other
102
+ arguments (`path-param-description` vs `argument-description`), so a tool can
103
+ log two lines where it logged one.
104
+ - The `unsafeNoAuth` banner names `auth: { verify }` and how to silence it.
105
+ - `McpifyAuthMode['auth']` is now `McpifyAuthOptions | McpifyRequestAuthOptions`;
106
+ code typing OAuth options as `Partial<McpifyOptions['auth']>` should use
107
+ `Partial<McpifyAuthOptions>`.
108
+
109
+ ## 0.3.0 (unreleased)
110
+
111
+ ### Breaking
112
+
113
+ - `mcpify()` throws at setup unless it gets exactly one of `auth` or
114
+ `unsafeNoAuth: true`. Before, omitting `auth` mounted an open endpoint and
115
+ only printed a warning. To keep an unauthenticated development setup, pass
116
+ `unsafeNoAuth: true`. The options type enforces the same rule.
117
+ - The default JWKS verifier requires the `typ: at+jwt` JOSE header
118
+ (RFC 9068 §4). `application/at+jwt` also matches. Tokens without it are
119
+ rejected with `401 invalid_token`. Set `auth.jwks.typ` to require another
120
+ value, or `false` to skip the check.
121
+ - The `elysia` peer range is `^1.4.0` (was `>=1.4.0`, which also accepted 2.x).
122
+
123
+ ### Added
124
+
125
+ - `auth.requireToolScopes`: expose only tools that declare `detail.mcp.scopes`
126
+ or `detail.mcp: { public: true }`. Other tools are left out, with a warning.
127
+ Default `false`.
128
+ - `McpifyBaseOptions` and `McpifyAuthMode` type exports.
129
+
130
+ ### Documentation
131
+
132
+ - The README warns that with the default `allRoutes: true`, a tool without
133
+ `detail.mcp.scopes` is callable by any token issued for the resource.
134
+
135
+ ## 0.2.0
136
+
137
+ - Serve protocol `2026-07-28` through SDK v2, add per-tool scopes and
138
+ anonymous access.
139
+
140
+ ## 0.1.0
141
+
142
+ - Harden tool execution and derivation. First release.