Repository navigation
MCP: Update Node SDK to 0.148.0 #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9f2d990
Carry MCP coverage for Node SDK 0.133.0-0.140.0 onto main
masnwilliams cabb8fd
Update Node SDK to 0.148.0 and MCP coverage
kernel-internal[bot] 9746ee5
Format files from the 0.148.0 coverage update
masnwilliams 15ed638
Shorten manage_browsers and manage_vault_wallets descriptions
masnwilliams 4f1448f
Shorten manage_vault_items and manage_vault_cards descriptions
masnwilliams e17fd0f
Allow fingerprint overrides without explicit headless and gpu false
masnwilliams fd87e15
Default control live views to a 24-hour ttl
masnwilliams 508e235
Guard tool description size, tools/list size, and destructive hints
masnwilliams File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import type { Tool } from "@modelcontextprotocol/server"; | ||
| import { connectTestMcp } from "@/lib/mcp/mcp-test-fixtures"; | ||
| import { registerMcpCapabilities } from "@/lib/mcp/register"; | ||
|
|
||
| // Every client loads every tool description, so long descriptions cost context on | ||
| // each request. Per-action detail belongs in parameter descriptions or in the | ||
| // response guidance and notes returned after a call. | ||
| const MAX_DESCRIPTION_CHARS = 3_000; | ||
|
|
||
| // Temporary exceptions, capped near their current size so they cannot grow. Lower | ||
| // a cap when a description shrinks; do not raise one without moving detail out. | ||
| const DESCRIPTION_CHAR_EXCEPTIONS: Record<string, number> = { | ||
| // Credential and payment safety rules (consent, secret handling, recovery) that | ||
| // must be read before the first call. Remaining per-provider detail should move | ||
| // to item guidance. | ||
| manage_vault_items: 10_000, | ||
| manage_vault_cards: 8_000, | ||
| manage_vault_credentials: 6_100, | ||
| // Reference for the helper functions available inside the repl. | ||
| browser_repl: 7_200, | ||
| }; | ||
|
|
||
| // The whole tools/list payload, including input schemas, with every toolset enabled. | ||
| const MAX_TOOLS_LIST_CHARS = 230_000; | ||
|
|
||
| async function listAllTools() { | ||
| const mcp = await connectTestMcp((server) => { | ||
| registerMcpCapabilities(server, { | ||
| mcpApps: true, | ||
| vaults: true, | ||
| search: true, | ||
| }); | ||
| }, {}); | ||
| try { | ||
| return await mcp.client.listTools(); | ||
| } finally { | ||
| await mcp.close(); | ||
| } | ||
| } | ||
|
|
||
| function actionValues(tool: Tool): string[] { | ||
| const action = tool.inputSchema.properties?.action as | ||
| | { enum?: string[]; anyOf?: Array<{ enum?: string[] }> } | ||
| | undefined; | ||
| return [ | ||
| ...(action?.enum ?? []), | ||
| ...(action?.anyOf ?? []).flatMap(({ enum: values }) => values ?? []), | ||
| ]; | ||
| } | ||
|
|
||
| describe("tool contract", () => { | ||
| test("tool descriptions stay within their size budget", async () => { | ||
| const { tools } = await listAllTools(); | ||
| const oversized = tools.flatMap((tool) => { | ||
| const limit = | ||
| DESCRIPTION_CHAR_EXCEPTIONS[tool.name] ?? MAX_DESCRIPTION_CHARS; | ||
| const length = (tool.description ?? "").length; | ||
| return length > limit ? [`${tool.name}: ${length} > ${limit}`] : []; | ||
| }); | ||
| expect(oversized).toEqual([]); | ||
| for (const name of Object.keys(DESCRIPTION_CHAR_EXCEPTIONS)) { | ||
| expect(tools.map((tool) => tool.name)).toContain(name); | ||
| } | ||
| }); | ||
|
|
||
| test("tools/list stays within its size budget", async () => { | ||
| const result = await listAllTools(); | ||
| expect(JSON.stringify(result).length).toBeLessThanOrEqual( | ||
| MAX_TOOLS_LIST_CHARS, | ||
| ); | ||
| }); | ||
|
|
||
| test("tools with delete or remove actions are marked destructive", async () => { | ||
| const { tools } = await listAllTools(); | ||
| const destructive = tools.filter((tool) => | ||
| actionValues(tool).some( | ||
| (action) => action.includes("delete") || action.includes("remove"), | ||
| ), | ||
| ); | ||
| expect(destructive.length).toBeGreaterThan(0); | ||
| const unmarked = destructive | ||
| .filter((tool) => tool.annotations?.destructiveHint !== true) | ||
| .map((tool) => tool.name); | ||
| expect(unmarked).toEqual([]); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @hiroTamada