Skip to content

Commit 10e4530

Browse files
ksinderclaude
andauthored
Harden the vendored OpenAPI->MCP fork (#317)
The src/openapi-mcp-server/ tree is a vendored fork of snaggle-ai/ openapi-mcp-server v1 (MIT; upstream went an incompatible direction in v2, so there's no upgrade path). This makes ownership of it deliberate and safe rather than incidental: - License compliance: add the upstream MIT LICENSE/copyright (Jan Wilmake) in the vendored dir, as the MIT terms require. It was previously dropped. - Regression guard: snapshot the MCP tool surface generated from the real scripts/notion-openapi.json (names, HTTP method, descriptions, params), so any future change to the converter — or a swap to a different engine — is caught with a reviewable diff. - Dead code: remove the unused convertToOpenAITools / convertToAnthropicTools converters (and the now-orphaned convertOperationToJsonSchema helper and FunctionParameters type). This drops the only uses of the `openai` and `@anthropic-ai/sdk` devDependencies, which are removed. - Document why it's forked and how to change it safely. No runtime behavior change. Build + full test suite pass (83 tests). Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 06803ef commit 10e4530

7 files changed

Lines changed: 489 additions & 339 deletions

File tree

package-lock.json

Lines changed: 0 additions & 219 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"zod": "3.24.1"
3535
},
3636
"devDependencies": {
37-
"@anthropic-ai/sdk": "^0.33.1",
3837
"@types/express": "^5.0.0",
3938
"@types/js-yaml": "^4.0.9",
4039
"@types/json-schema": "^7.0.15",
@@ -44,7 +43,6 @@
4443
"@vitest/coverage-v8": "^4.0.18",
4544
"esbuild": "^0.25.2",
4645
"multer": "1.4.5-lts.1",
47-
"openai": "^4.91.1",
4846
"tsx": "^4.19.3",
4947
"typescript": "^5.8.2",
5048
"vitest": "^4.0.18"

src/openapi-mcp-server/LICENSE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
The code in this directory is a vendored fork of v1 of
2+
https://github.com/snaggle-ai/openapi-mcp-server, used under the MIT License.
3+
Its original license and copyright notice are reproduced below, as required by
4+
the MIT License. Modifications made by Notion Labs, Inc. are likewise released
5+
under the MIT License (see the LICENSE file at the repository root).
6+
7+
----------------------------------------------------------------------
8+
9+
MIT License
10+
11+
Copyright (c) 2025 Jan Wilmake
12+
13+
Permission is hereby granted, free of charge, to any person obtaining a copy
14+
of this software and associated documentation files (the "Software"), to deal
15+
in the Software without restriction, including without limitation the rights
16+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17+
copies of the Software, and to permit persons to whom the Software is
18+
furnished to do so, subject to the following conditions:
19+
20+
The above copyright notice and this permission notice shall be included in all
21+
copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29+
SOFTWARE.

src/openapi-mcp-server/README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1-
Note: This is a fork from v1 of https://github.com/snaggle-ai/openapi-mcp-server. The library took a different direction with v2 which is not compatible with our development approach.
1+
# openapi-mcp-server (vendored)
22

3-
Forked to upgrade vulnerable dependencies and easier setup.
3+
This directory converts Notion's OpenAPI spec into MCP tools and executes the
4+
underlying API calls. It is a **vendored fork** of v1 of
5+
[`snaggle-ai/openapi-mcp-server`](https://github.com/snaggle-ai/openapi-mcp-server)
6+
(MIT). See [`LICENSE`](./LICENSE) for the upstream copyright notice.
7+
8+
## Why it's vendored (and why we keep it)
9+
10+
Upstream took a different direction in v2 — it became an API *discovery*
11+
meta-tool and is no longer a one-tool-per-endpoint converter — so there is no
12+
upgrade path. We own this code deliberately. It is small, has no external
13+
runtime dependencies of its own beyond what the server already ships, and
14+
encodes **Notion-specific behavior** that off-the-shelf OpenAPI→MCP libraries do
15+
not reproduce:
16+
17+
- `"Notion | "` prefix on tool descriptions (`parser.ts`, `getDescription`).
18+
- Tolerance for clients that double-serialize nested JSON params: complex
19+
schemas are widened to `anyOf: [schema, string]` (`parser.ts`,
20+
`withStringFallback`) and decoded at call time (`proxy.ts`, `deserializeParams`).
21+
See issues [#176](https://github.com/makenotion/notion-mcp-server/issues/176)
22+
and [#208](https://github.com/makenotion/notion-mcp-server/issues/208).
23+
- `readOnly` / `destructive` tool annotations derived from the HTTP method
24+
(`proxy.ts`).
25+
- Multipart/file-upload operations mapped to local-file-path string params
26+
(`parser.ts` binary handling, `file-upload.ts`).
27+
- 64-char tool-name truncation with a uniqueness suffix (`parser.ts`,
28+
`ensureUniqueName`).
29+
30+
## Changing it safely
31+
32+
`openapi/__tests__/notion-spec.snapshot.test.ts` snapshots the tools generated
33+
from the real `scripts/notion-openapi.json` spec (names, descriptions, parameter
34+
surface). If a change alters the public tool surface, that snapshot will fail —
35+
review the diff and update with `vitest -u` only if the change is intentional.

0 commit comments

Comments
 (0)