@knitli/openapi-mcp 0.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.
Files changed (116) hide show
  1. package/LICENSE-APACHE +202 -0
  2. package/LICENSE-MIT +21 -0
  3. package/README.md +362 -0
  4. package/dist/cli.d.ts +2 -0
  5. package/dist/cli.js +249 -0
  6. package/dist/compile.d.ts +14 -0
  7. package/dist/compile.js +132 -0
  8. package/dist/compiler.d.ts +13 -0
  9. package/dist/compiler.js +7 -0
  10. package/dist/conformance/fixtures.d.ts +24 -0
  11. package/dist/conformance/fixtures.js +119 -0
  12. package/dist/conformance/index.d.ts +2 -0
  13. package/dist/conformance/index.js +2 -0
  14. package/dist/conformance/runtime-suite.d.ts +31 -0
  15. package/dist/conformance/runtime-suite.js +343 -0
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.js +1 -0
  18. package/dist/load.d.ts +31 -0
  19. package/dist/load.js +20 -0
  20. package/dist/operations.d.ts +27 -0
  21. package/dist/operations.js +231 -0
  22. package/dist/permissions.d.ts +31 -0
  23. package/dist/permissions.js +89 -0
  24. package/dist/release/compile-release.d.ts +33 -0
  25. package/dist/release/compile-release.js +1620 -0
  26. package/dist/release/load-v4.d.ts +29 -0
  27. package/dist/release/load-v4.js +297 -0
  28. package/dist/release/manifest-builder.d.ts +19 -0
  29. package/dist/release/manifest-builder.js +28 -0
  30. package/dist/release/publish.d.ts +45 -0
  31. package/dist/release/publish.js +346 -0
  32. package/dist/release/reference-map.d.ts +53 -0
  33. package/dist/release/reference-map.js +347 -0
  34. package/dist/release/schema-v4.d.ts +5 -0
  35. package/dist/release/schema-v4.js +91 -0
  36. package/dist/runtime/action-permit.d.ts +11 -0
  37. package/dist/runtime/action-permit.js +1 -0
  38. package/dist/runtime/classify.d.ts +16 -0
  39. package/dist/runtime/classify.js +279 -0
  40. package/dist/runtime/credential-binding.d.ts +3 -0
  41. package/dist/runtime/credential-binding.js +101 -0
  42. package/dist/runtime/digest.d.ts +8 -0
  43. package/dist/runtime/digest.js +80 -0
  44. package/dist/runtime/errors.d.ts +14 -0
  45. package/dist/runtime/errors.js +15 -0
  46. package/dist/runtime/index.d.ts +20 -0
  47. package/dist/runtime/index.js +14 -0
  48. package/dist/runtime/manifest.d.ts +33 -0
  49. package/dist/runtime/manifest.js +489 -0
  50. package/dist/runtime/prepared-call.d.ts +39 -0
  51. package/dist/runtime/prepared-call.js +566 -0
  52. package/dist/runtime/references.d.ts +7 -0
  53. package/dist/runtime/references.js +197 -0
  54. package/dist/runtime/runtime.d.ts +25 -0
  55. package/dist/runtime/runtime.js +1272 -0
  56. package/dist/runtime/schema-keywords.d.ts +2 -0
  57. package/dist/runtime/schema-keywords.js +30 -0
  58. package/dist/runtime/schema-resolver.d.ts +10 -0
  59. package/dist/runtime/schema-resolver.js +237 -0
  60. package/dist/runtime/serialize.d.ts +12 -0
  61. package/dist/runtime/serialize.js +877 -0
  62. package/dist/runtime/store.d.ts +52 -0
  63. package/dist/runtime/store.js +582 -0
  64. package/dist/runtime/strict-json.d.ts +19 -0
  65. package/dist/runtime/strict-json.js +539 -0
  66. package/dist/runtime/types.d.ts +457 -0
  67. package/dist/runtime/types.js +1 -0
  68. package/dist/runtime/verify-record.d.ts +6 -0
  69. package/dist/runtime/verify-record.js +492 -0
  70. package/dist/runtime/versions.d.ts +63 -0
  71. package/dist/runtime/versions.js +86 -0
  72. package/dist/safety.d.ts +28 -0
  73. package/dist/safety.js +60 -0
  74. package/dist/schema.d.ts +5 -0
  75. package/dist/schema.js +52 -0
  76. package/dist/schemas.d.ts +9 -0
  77. package/dist/schemas.js +16 -0
  78. package/dist/sign.d.ts +20 -0
  79. package/dist/sign.js +55 -0
  80. package/dist/sqlite/auth.d.ts +33 -0
  81. package/dist/sqlite/auth.js +973 -0
  82. package/dist/sqlite/catalog-store.d.ts +20 -0
  83. package/dist/sqlite/catalog-store.js +370 -0
  84. package/dist/sqlite/destination-guard.d.ts +24 -0
  85. package/dist/sqlite/destination-guard.js +140 -0
  86. package/dist/sqlite/generation-store.d.ts +12 -0
  87. package/dist/sqlite/generation-store.js +721 -0
  88. package/dist/sqlite/guarded-fetch.d.ts +24 -0
  89. package/dist/sqlite/guarded-fetch.js +626 -0
  90. package/dist/sqlite/index.d.ts +5 -0
  91. package/dist/sqlite/index.js +5 -0
  92. package/dist/sqlite/oauth-resource.d.ts +2 -0
  93. package/dist/sqlite/oauth-resource.js +15 -0
  94. package/dist/sqlite/release-completion.d.ts +5 -0
  95. package/dist/sqlite/release-completion.js +80 -0
  96. package/dist/stdio/action-broker.d.ts +15 -0
  97. package/dist/stdio/action-broker.js +136 -0
  98. package/dist/stdio/authorizer.d.ts +30 -0
  99. package/dist/stdio/authorizer.js +484 -0
  100. package/dist/stdio/config.d.ts +77 -0
  101. package/dist/stdio/config.js +144 -0
  102. package/dist/stdio/exact-policy.d.ts +41 -0
  103. package/dist/stdio/exact-policy.js +361 -0
  104. package/dist/stdio/index.d.ts +6 -0
  105. package/dist/stdio/index.js +148 -0
  106. package/dist/stdio/render.d.ts +8 -0
  107. package/dist/stdio/render.js +253 -0
  108. package/dist/stdio/request-state.d.ts +18 -0
  109. package/dist/stdio/request-state.js +79 -0
  110. package/dist/stdio/search.d.ts +10 -0
  111. package/dist/stdio/search.js +76 -0
  112. package/dist/stdio/server.d.ts +29 -0
  113. package/dist/stdio/server.js +309 -0
  114. package/dist/types.d.ts +32 -0
  115. package/dist/types.js +1 -0
  116. package/package.json +131 -0
package/LICENSE-APACHE 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/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Knitli Inc.
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,362 @@
1
+ # @knitli/openapi-mcp
2
+
3
+ Compile OpenAPI documents into immutable, signed SQLite catalogs. The local MCP
4
+ server exposes `search`, `read`, and `action`; it verifies the catalog, request,
5
+ destination, credentials, and any required action authorization before dispatch.
6
+
7
+ The executable artifact format is **5**, runtime contract **1**, and prepared-call
8
+ format **2**. This package is compiled TypeScript, separate from the Toolshed
9
+ prompt plugins.
10
+
11
+ ## Install and check the runtime
12
+
13
+ Local serving requires Node `>=24.16.0 <25`. Packed consumers exercise Node 24
14
+ and Bun 1.4 compiler/SQLite imports. Bun HTTP socket-adapter support has not been
15
+ established; use Node for `serve`. `/runtime` and `/conformance` pass an isolated
16
+ WebWorker-only declaration check and browser bundle. This is not evidence of an
17
+ actual Cloudflare D1 deployment or D1 conformance.
18
+
19
+ The source version is `0.0.0`. Registry publication, trusted publishing, and
20
+ registry provenance verification remain release gates, not claims made by this
21
+ README. For a locally built and tested tarball, install its absolute path from a
22
+ clean consumer directory:
23
+
24
+ ```sh
25
+ npm install --ignore-scripts /absolute/path/to/openapi-mcp.tgz
26
+ node --version
27
+ ```
28
+
29
+ After a real stable version is observed in npm, pin that exact verified version
30
+ with `npm install --save-exact @knitli/openapi-mcp@<verified-version>`. A bootstrap
31
+ `0.0.0` publication, if needed, uses the `bootstrap` dist-tag and is not a stable
32
+ release. The CLI examples below use the consumer's `node_modules/.bin` binary.
33
+
34
+ ## Generate a signing key and compile a release
35
+
36
+ Use a private operator directory. The generation-state parent must be owned by
37
+ the serving user and mode `0700`; retain that state across upgrades and restarts.
38
+
39
+ ```sh
40
+ mkdir -m 700 operator operator/keys operator/releases operator/state
41
+ ./node_modules/.bin/openapi-mcp keygen --out ./operator/keys
42
+ ./node_modules/.bin/openapi-mcp compile-release \
43
+ --spec ./openapi.yaml --source-label widgets-spec --source-revision revision-1 \
44
+ --catalog widgets --release widgets-1 --generation 1 \
45
+ --issuer example-operator --key-id signing-1 --policy-id local-policy-1 \
46
+ --allowed-origin https://api.example.com \
47
+ --out ./operator/releases --sign-key ./operator/keys/openapi-mcp.key
48
+ ```
49
+
50
+ Replace the spec, provenance, identifiers, and origin with your reviewed inputs.
51
+ `--source-uri <https-uri>` is an alternative to `--source-label`. Compilation
52
+ does not grant permission to call the API. Local references can be bounded with
53
+ `--reference-root` and `--reference-map`; do not treat remote spec fetching as a
54
+ runtime feature. `--permissions` accepts the permissions dataset used by the
55
+ legacy compiler, but permissions annotations are advisory, not authorization.
56
+
57
+ Keep each v5 SQLite payload beside its matching `.manifest.json` and
58
+ `.manifest.sig` files with the same filename stem. Local executable ingress
59
+ checks bounded, matching sidecars and admits only a complete manifest-last
60
+ bundle. Startup proves every configured release's full record inventory before
61
+ starting its conditional generation admissions. A valid signature alone does
62
+ not admit a release with missing, malformed, or digest-mismatched records.
63
+
64
+ The command publishes `widgets-1.sqlite`, `widgets-1.manifest.json`, and
65
+ `widgets-1.manifest.sig` under the output directory without replacing an existing
66
+ release. `keygen` refuses to overwrite existing files and writes the private key
67
+ with mode `0600`. Keep the private key out of runtime deployments. Obtain the
68
+ base64url SPKI public key for the config with:
69
+
70
+ ```sh
71
+ node --input-type=module -e 'import {readFileSync} from "node:fs"; import {createPublicKey} from "node:crypto"; console.log(createPublicKey(readFileSync("operator/keys/openapi-mcp.pub")).export({type:"spki",format:"der"}).toString("base64url"))'
72
+ ```
73
+
74
+ ## Configure and start the local MCP server
75
+
76
+ Save this as `operator/config.json`, substituting absolute paths, the public key,
77
+ and the origin present in the signed catalog. Config objects are strict: unknown
78
+ fields, duplicate identifiers, unresolved profile references, and invalid limits
79
+ are rejected. Origins must be HTTPS origins without credentials, paths, or query
80
+ strings. Do not put bearer tokens or API keys in this file; use environment
81
+ variable names. Supply those variables through your process supervisor or secret
82
+ manager before starting the process.
83
+
84
+ ```json
85
+ {
86
+ "version": 1,
87
+ "generationStatePath": "/absolute/path/operator/state/generations.json",
88
+ "catalogs": [{
89
+ "catalogId": "widgets", "releaseId": "widgets-1",
90
+ "path": "/absolute/path/operator/releases/widgets-1.sqlite",
91
+ "profileId": "widgets-user"
92
+ }],
93
+ "trust": {
94
+ "releaseKeys": [{"issuer": "example-operator", "keyId": "signing-1", "publicKey": "REPLACE_WITH_BASE64URL_SPKI"}],
95
+ "rollbackKeys": []
96
+ },
97
+ "allowedOrigins": ["https://api.example.com"],
98
+ "profiles": [{
99
+ "profileId": "widgets-user", "revision": 1,
100
+ "allowedOrigins": ["https://api.example.com"],
101
+ "auth": {"type": "bearer-env", "env": "WIDGETS_TOKEN"}
102
+ }]
103
+ }
104
+ ```
105
+
106
+ ```sh
107
+ ./node_modules/.bin/openapi-mcp serve --config /absolute/path/operator/config.json
108
+ ```
109
+
110
+ This speaks MCP on stdio. Startup errors go to stderr; keep stdout reserved for
111
+ the protocol. A client configuration using the installed Node CLI can be:
112
+
113
+ ```json
114
+ {
115
+ "mcpServers": {
116
+ "widgets": {
117
+ "command": "/absolute/path/to/node",
118
+ "args": ["/absolute/path/to/node_modules/@knitli/openapi-mcp/dist/cli.js", "serve", "--config", "/absolute/path/operator/config.json"]
119
+ }
120
+ }
121
+ }
122
+ ```
123
+
124
+ An API-key profile uses `{"type":"api-key-env","env":"WIDGETS_API_KEY",
125
+ "placement":"header","name":"X-API-Key"}` (query placement is also supported).
126
+ OAuth uses `{"type":"oauth2-pkce","authorizationEndpoint":"https://auth.example.com/authorize",
127
+ "tokenEndpoint":"https://auth.example.com/token","clientId":"public-client-id",
128
+ "scopes":["widgets.read"]}` with optional `resource`. The resource is a fixed
129
+ absolute URI without a fragment, including identifiers such as
130
+ `urn:example:widgets`; it is audience metadata, not a credential destination or
131
+ token-claim validation. Authorization and token endpoints remain HTTPS URLs.
132
+ These endpoints and client
133
+ registration must be configured by the operator. The server uses authorization
134
+ code PKCE with S256 and a temporary `127.0.0.1` callback listener on an ephemeral
135
+ port at `/oauth/callback`; the identity provider must support that redirect.
136
+ The client needs URL elicitation for OAuth and form elicitation for confirmation.
137
+ Open the offered authorization URL, finish login, then follow the client's resume
138
+ flow. Unsupported elicitation fails closed.
139
+
140
+ ## Use the three tools
141
+
142
+ These are tool names and input objects, not shell commands. Use the opaque
143
+ `operation` returned by search unchanged; it binds the release and manifest.
144
+
145
+ ```json
146
+ {"name":"search","arguments":{"query":"list widgets","limit":5}}
147
+ ```
148
+
149
+ ```json
150
+ {"name":"read","arguments":{"operation":"<operation returned by search>","arguments":{"query":{"limit":10}}}}
151
+ ```
152
+
153
+ ```json
154
+ {"name":"action","arguments":{"operation":"<action operation returned by search>","arguments":{"path":{"id":"widget-1"},"body":{"label":"Reviewed label"}}}}
155
+ ```
156
+
157
+ Choose arguments from the returned input outline and your API's schema. An API
158
+ namespace can be supplied as `search.api` when advertised by the mounted catalog.
159
+ Read pagination uses the returned opaque `pageToken`; do not construct one.
160
+ Upstream response content is untrusted data and cannot authorize further calls.
161
+
162
+ Each search shares one candidate, record-proof, store-call, work, and response
163
+ budget across catalogs. It can authenticate and completely prove at most eight
164
+ candidate releases; broad matches or exhausted budgets produce safe omission
165
+ warnings. Narrowing the query or selecting an API can reach later configured
166
+ catalogs, including catalogs sharing an API namespace. Results are a bounded
167
+ ranked sample, not an exhaustive catalog listing. Deprecation demotion and the
168
+ requested result limit apply across the combined candidates.
169
+
170
+ Successful search results, including the MCP content wrapper, trust text, and
171
+ warnings, obey the configured `limits.maxResponseBytes`. A smaller-than-minimum
172
+ result budget returns a bounded `RESPONSE_LIMIT_EXCEEDED` control error; the
173
+ server does not raise the supplied limit to manufacture a successful result.
174
+ When embedding `createOpenApiMcpServer`, provide its required `searchRuntime`
175
+ port backed by one semantic search context, alongside `routes`, `authorizer`,
176
+ and the same reduction-only `limits`. A single-catalog embedding can pass its
177
+ existing runtime as `searchRuntime`; the CLI assembles shared search itself.
178
+
179
+ If an action reports `UPSTREAM_OUTCOME_UNKNOWN`, its error includes the exact
180
+ `details.preparedCallDigest` and `retryable: false`. Use that digest to reconcile
181
+ the uncertain outcome; the server has consumed the authorization and does not
182
+ automatically retry the action.
183
+
184
+ Actions require server-controlled authorization bound to the prepared request,
185
+ credential profile, release, and argument digest. Review the elicited destination,
186
+ operation, effect, and arguments, then explicitly confirm. Rejection, cancellation,
187
+ expiry, a changed request, or a changed credential binding prevents dispatch.
188
+ Destructive operations require the stronger destructive acknowledgment. An operator
189
+ may supply narrowly bound `exactPolicies` for eligible create/update operations;
190
+ they are not broad scopes or a general confirmation bypass. Do not construct policy
191
+ digests from model-supplied values. Policies expire and must match the verified
192
+ manifest, operation, credentials, cardinality, and constrained arguments exactly.
193
+
194
+ ## Rotate credentials, keys, and catalogs
195
+
196
+ Access and refresh tokens are held in process memory. OAuth refresh is supported;
197
+ closing or restarting the process clears its token state and pending authorization
198
+ flows. Environment credentials are still present if the process supervisor
199
+ injects them again. Process restart is local cleanup, not upstream revocation:
200
+ revoke the credential at the identity provider/API, remove or rotate its source,
201
+ increment the profile revision, then restart the server. The library credential
202
+ provider also exposes local revocation; it does not imply provider-side revocation.
203
+
204
+ For a signing-key rotation, distribute the new public key through the trusted
205
+ operator config, compile a new immutable release with a higher generation and the
206
+ new key ID, validate it, update the catalog selection, and restart. Remove the old
207
+ trust key when no retained approved release needs it. Keep rollback-authority keys
208
+ separate from routine release keys. Never overwrite a catalog or reset/delete the
209
+ generation state to make an old signature pass.
210
+
211
+ To disable a catalog, stop the server, remove that catalog from `catalogs`, and
212
+ restart with the remaining valid catalogs. Config requires at least one catalog;
213
+ leave the server stopped if disabling the last one. Removing a file while the
214
+ process is using it is not a reliable disable procedure.
215
+
216
+ ## Recover from a bad release
217
+
218
+ Before release, record the prior **observed package version**, its tarball digest,
219
+ the prior immutable catalog ID/release ID/generation/manifest digest, and the
220
+ generation-state location. No prior published package version is asserted here.
221
+ After a stable predecessor exists, the downgrade command is
222
+ `npm install --save-exact @knitli/openapi-mcp@<recorded-known-good-version>` from the
223
+ consumer directory. Restart with the retained catalog and state. Package downgrade
224
+ alone does not authorize a signed-data rollback.
225
+
226
+ The packed Node/Bun exercise compiles generations 1 and 2 with fresh fixture keys.
227
+ A damaged generation-2 signature is rejected while generation 1 still searches
228
+ and its operation record verifies. After valid generation 2 is admitted, generation
229
+ 1 is rejected until the separate rollback authority signs the existing v1 rollback
230
+ authorization. Activation retains the highest generation at 2, changes the active
231
+ generation to 1, consumes the authorization ID, and survives reopening the same
232
+ `FileGenerationStore`. This is fixture evidence, not a production rollback.
233
+
234
+ The stdio config accepts rollback trust keys but does **not** accept an attached
235
+ rollback envelope. An operator can activate a pre-signed authorization through the
236
+ public API while the server is stopped, then restart stdio against the retained
237
+ catalog and the same state. Save the following as `activate-rollback.mjs` inside
238
+ an installed consumer. The input authorization must come from your separate
239
+ rollback authority; this procedure does not generate or weaken its signature.
240
+
241
+ ```js
242
+ import { readFile } from "node:fs/promises";
243
+ import { admitManifest } from "@knitli/openapi-mcp/runtime";
244
+ import { FileGenerationStore, SqliteCatalogStore } from "@knitli/openapi-mcp/sqlite";
245
+ import { parseOpenApiStdioConfig } from "@knitli/openapi-mcp/stdio";
246
+
247
+ const [configPath, catalogId, authorizationPath] = process.argv.slice(2);
248
+ const config = parseOpenApiStdioConfig(await readFile(configPath, "utf8"));
249
+ const selected = config.catalogs.find((entry) => entry.catalogId === catalogId);
250
+ if (!selected) throw new Error("Catalog is not configured");
251
+ const store = new SqliteCatalogStore(selected.path);
252
+ try {
253
+ const envelope = await store.getManifest(selected.catalogId, selected.releaseId);
254
+ if (!envelope) throw new Error("Manifest not found");
255
+ const rollback = JSON.parse(await readFile(authorizationPath, "utf8"));
256
+ const admitted = await admitManifest({ ...envelope, rollback }, config.trust,
257
+ new FileGenerationStore(config.generationStatePath));
258
+ console.log({ releaseId: admitted.manifest.releaseId, generation: admitted.manifest.generation });
259
+ } finally {
260
+ store.close();
261
+ }
262
+ ```
263
+
264
+ ```sh
265
+ node activate-rollback.mjs /absolute/path/operator/config.json widgets /absolute/path/operator/approved-rollback.json
266
+ ```
267
+
268
+ Select the prior catalog in the config before running this command. The existing
269
+ authorization binds the catalog, issuer, current highest generation, target
270
+ generation and manifest digest, expiry, unique ID, reason, and authorized key ID.
271
+ It is Ed25519 over `knitli.openapi-mcp.rollback-authorization.v1` followed by a NUL
272
+ byte and canonical JSON of the unsigned authorization. The runtime validates that
273
+ contract and replay/state constraints. Use the packed consumer fixture as an
274
+ executable example for a nonproduction signing exercise; never copy its generated
275
+ keys into operator trust.
276
+
277
+ ## Migrate older artifacts
278
+
279
+ Legacy `compile --spec ... --api ... --out ... [--sign-key ...]` still creates v3
280
+ artifacts; `verify --artifact ... --sig ... --pub ...` verifies the exact SQLite
281
+ file signature. V3 is inventory-only and does not gain executable trust from that
282
+ signature. Recompile the reviewed source with `compile-release` for v5 execution.
283
+ Do not relabel or mutate a v3 database as a v5 release.
284
+
285
+ Strict historical v4 manifests support their tagless read compatibility contract.
286
+ Do not add v5 tags to a historical v4 signed record or describe historical v4 as
287
+ the current compiler output. V5 signs the manifest and record digests; the legacy
288
+ exact-file `verify` command is not a v5 admission test. Use `admitManifest` and the
289
+ runtime/store checks when validating release trust.
290
+
291
+ ## Troubleshoot and verify a build
292
+
293
+ `MANIFEST_INVALID` calls for checking the selected release, exact envelope, and
294
+ trusted issuer/key. `MANIFEST_ROLLBACK_REJECTED` requires the recovery procedure,
295
+ not a generation-state reset. A generation-state permission error means its
296
+ parent must be a real, owner-only directory. Generic startup errors are deliberate
297
+ to avoid exposing config secrets; validate with `parseOpenApiStdioConfig` in a
298
+ controlled operator process. Missing environment credentials or OAuth elicitation
299
+ must be resolved before a call can proceed. An action refused for lack of
300
+ confirmation needs an elicitation-capable client or an eligible reviewed exact
301
+ policy. Do not retry a changed action with old approval state.
302
+
303
+ From the repository, the package checks are:
304
+
305
+ ```sh
306
+ mise exec -- bun run --cwd packages/openapi-mcp build
307
+ mise exec -- bun test packages/openapi-mcp
308
+ mise exec -- bun run --cwd packages/openapi-mcp test:node-transport
309
+ mise exec -- bun run --cwd packages/openapi-mcp test:node-stdio
310
+ mise exec -- bun scripts/generate.mts --check
311
+ mise exec -- bun run validate
312
+ (cd packages/openapi-mcp && mise exec -- bun pm pack --dry-run)
313
+ ```
314
+
315
+ `tests/package-consumers.test.ts` builds/packs once, installs that tarball in fresh
316
+ Node, Bun, and Worker directories outside the repository, executes the fixtures
317
+ there, and prints the artifact path, SHA-256, and evidence directory. Set
318
+ `OPENAPI_MCP_TARBALL` to an absolute tarball path to verify those exact bytes.
319
+ The tarball includes all five public subpaths, declarations, the CLI, README, and
320
+ unmodified MIT and Apache 2.0 licenses. Test specs, credentials, fixture databases,
321
+ and consumer scripts are excluded. The exported conformance fixture module is
322
+ part of the public `/conformance` API and does ship.
323
+
324
+ Phase 3 must run the exported `runRuntimeConformanceSuite` against actual D1 in
325
+ a Workers test environment and verify the deployed integration. A structural D1
326
+ fake, portable declarations, or a browser bundle does not establish that result.
327
+ The optional large Microsoft Graph corpus check remains skipped when its local
328
+ fixture is absent; no large-corpus performance claim is made here.
329
+
330
+ ## Release gates
331
+
332
+ Only the protected `npmrelease` GitHub environment may publish this package.
333
+ Steady-state npm trusted publishing must bind exactly `knitli/toolshed`,
334
+ `.github/workflows/release.yml` (publisher workflow name `release.yml`), and
335
+ `npmrelease`, with `id-token: write`. It must not receive `NPM_TOKEN` or
336
+ `NODE_AUTH_TOKEN`. The release adapter tests a Bun-packed artifact and invokes
337
+ npm with that exact tarball from a clean directory under `RUNNER_TEMP`.
338
+ `OPENAPI_MCP_OIDC_READY` is operator-controlled release enablement, not proof of
339
+ publisher configuration or provenance. Set it to `true` only after recording the
340
+ external setup and bootstrap-cleanup gates. Until then, build/test/validation
341
+ still run and publication is explicitly reported as pending. A real build,
342
+ publication, or audit failure continues to fail the job and its dependents.
343
+
344
+ If the package does not yet exist, bootstrap is a separate exception requiring
345
+ recorded named owner approval and protected-environment approval. It publishes
346
+ only `0.0.0`, with `--access public --tag bootstrap --provenance`; it does not run
347
+ semantic-release or create a Git tag/release. A short-lived granular token may be
348
+ injected only into that protected job, never into local files, logs, commits, or
349
+ artifacts. After bootstrap, configure the exact trusted publisher, remove token
350
+ variables and the GitHub secret, revoke the token, and commit the OIDC-only
351
+ workflow before allowing the first real `latest` release.
352
+
353
+ For bootstrap and every stable release, retain a fresh public install's
354
+ `npm audit signatures --json --include-attestations` output in the protected job
355
+ artifact, along with its SHA-256. Require successful cryptographic verification
356
+ and verify package identity/integrity, source commit, repository, workflow, and
357
+ CI run against the release being approved. Registry metadata from `npm view`
358
+ alone is insufficient. Record CI and semantic-release completion, registry
359
+ version/dist-tag visibility, the matching stable Git tag/release, protected
360
+ environment and publisher configuration, bootstrap cleanup/revocation when used,
361
+ and the exact-version public consumer result. Any unobserved or failed gate stays
362
+ pending. Local tests and workflow code are not evidence of publication.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};