-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add ctx-zip tools to tools registry - MCP Code Mode/CodeAct #10447
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
base: main
Are you sure you want to change the base?
Conversation
| }, | ||
| ], | ||
| standardTools: { | ||
| weather: weatherTool, |
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.
The code example references an undefined variable weatherTool that is never imported or defined, making the example code incomplete and broken.
View Details
📝 Patch Details
diff --git a/content/tools-registry/registry.ts b/content/tools-registry/registry.ts
index b2ffd5c2a..a1bd89edb 100644
--- a/content/tools-registry/registry.ts
+++ b/content/tools-registry/registry.ts
@@ -129,8 +129,10 @@ console.log(text);`,
yarn: 'yarn add ctx-zip',
bun: 'bun add ctx-zip',
},
- codeExample: `import { gateway, generateText, stepCountIs } from 'ai';
+ codeExample: `import { gateway, generateText, stepCountIs, tool } from 'ai';
import { createVercelSandboxCodeMode, SANDBOX_SYSTEM_PROMPT } from "ctx-zip";
+import { z } from 'zod';
+
const { tools, manager } = await createVercelSandboxCodeMode({
servers: [
{
@@ -143,7 +145,16 @@ const { tools, manager } = await createVercelSandboxCodeMode({
},
],
standardTools: {
- weather: weatherTool,
+ weather: tool({
+ description: "Get the weather for a location",
+ parameters: z.object({
+ location: z.string().describe("The city and state, e.g. San Francisco, CA"),
+ }),
+ execute: async ({ location }) => {
+ // Mock weather data - replace with real API call
+ return { location, temperature: 72, condition: "Sunny" };
+ },
+ }),
},
});
Analysis
Undefined weatherTool in ctx-zip code example
What fails: The codeExample for the ctx-zip tool in content/tools-registry/registry.ts references an undefined variable weatherTool in the standardTools configuration, causing a ReferenceError at runtime.
How to reproduce:
// Code from registry.ts codeExample (before fix):
const { tools, manager } = await createVercelSandboxCodeMode({
standardTools: {
weather: weatherTool, // ReferenceError: weatherTool is not defined
},
});Result: ReferenceError: weatherTool is not defined when the code is executed, as weatherTool is never imported or defined anywhere in the example.
Expected: According to the ctx-zip documentation, standardTools should receive objects created using the tool() function from the 'ai' package. The example should either import weatherTool from a valid source or define it using the tool() helper function with appropriate schema and execution logic.
Fix: Updated the code example to:
- Import the
toolfunction from 'ai' andzfrom 'zod' - Replace the undefined
weatherToolreference with a properly constructed tool definition usingtool()function - Include schema definition and execution logic, matching the documented pattern for ctx-zip's standardTools parameter
| slug: 'ctx-zip', | ||
| name: 'MCP Code Mode', | ||
| description: | ||
| 'Transform MCP tools and AI SDK tools into code, write it to a Vercel sandbox file system and have the agent import the tools, write code, and execute it. Learn more about MCP Code Mode [here](https://www.anthropic.com/engineering/code-execution-with-mcp).', | ||
| packageName: 'ctx-zip', | ||
| tags: ['code-execution', 'sandbox', 'mcp', 'code-mode'], | ||
| apiKeyEnvName: 'VERCEL_OIDC_TOKEN', | ||
| installCommand: { | ||
| pnpm: 'pnpm install ctx-zip', | ||
| npm: 'npm install ctx-zip', | ||
| yarn: 'yarn add ctx-zip', | ||
| bun: 'bun add ctx-zip', | ||
| }, | ||
| codeExample: `import { gateway, generateText, stepCountIs } from 'ai'; | ||
| import { createVercelSandboxCodeMode, SANDBOX_SYSTEM_PROMPT } from "ctx-zip"; | ||
| const { tools, manager } = await createVercelSandboxCodeMode({ | ||
| servers: [ | ||
| { | ||
| name: "vercel", | ||
| url: "https://mcp.vercel.com", | ||
| useSSE: false, | ||
| headers: { | ||
| Authorization: \`Bearer \${process.env.VERCEL_API_KEY}\`, | ||
| }, | ||
| }, | ||
| ], | ||
| standardTools: { | ||
| weather: weatherTool, | ||
| }, | ||
| }); | ||
| const { text } = await generateText({ | ||
| model: gateway('openai/gpt-4.1-mini'), | ||
| tools, | ||
| stopWhen: stepCountIs(20), | ||
| system: SANDBOX_SYSTEM_PROMPT, | ||
| messages: [ | ||
| { | ||
| role: "user", | ||
| content: "What tools are available from the Vercel MCP server?", | ||
| }, | ||
| ], | ||
| }); | ||
| console.log(text);`, | ||
| docsUrl: 'https://github.com/karthikscale3/ctx-zip/blob/main/README.md', | ||
| apiKeyUrl: 'https://vercel.com/docs/vercel-sandbox#authentication', | ||
| websiteUrl: 'https://github.com/karthikscale3/ctx-zip/blob/main/README.md', | ||
| npmUrl: 'https://www.npmjs.com/package/ctx-zip', |
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.
The new ctx-zip entry has inconsistent indentation - all properties use 8 spaces instead of 6 spaces, breaking the established pattern used by other entries in the registry.
View Details
📝 Patch Details
diff --git a/content/tools-registry/registry.ts b/content/tools-registry/registry.ts
index b2ffd5c2a..19916f43f 100644
--- a/content/tools-registry/registry.ts
+++ b/content/tools-registry/registry.ts
@@ -116,20 +116,20 @@ console.log(text);`,
npmUrl: 'https://www.npmjs.com/package/@parallel-web/ai-sdk-tools',
},
{
- slug: 'ctx-zip',
- name: 'MCP Code Mode',
- description:
- 'Transform MCP tools and AI SDK tools into code, write it to a Vercel sandbox file system and have the agent import the tools, write code, and execute it. Learn more about MCP Code Mode [here](https://www.anthropic.com/engineering/code-execution-with-mcp).',
- packageName: 'ctx-zip',
- tags: ['code-execution', 'sandbox', 'mcp', 'code-mode'],
- apiKeyEnvName: 'VERCEL_OIDC_TOKEN',
- installCommand: {
- pnpm: 'pnpm install ctx-zip',
- npm: 'npm install ctx-zip',
- yarn: 'yarn add ctx-zip',
- bun: 'bun add ctx-zip',
- },
- codeExample: `import { gateway, generateText, stepCountIs } from 'ai';
+ slug: 'ctx-zip',
+ name: 'MCP Code Mode',
+ description:
+ 'Transform MCP tools and AI SDK tools into code, write it to a Vercel sandbox file system and have the agent import the tools, write code, and execute it. Learn more about MCP Code Mode [here](https://www.anthropic.com/engineering/code-execution-with-mcp).',
+ packageName: 'ctx-zip',
+ tags: ['code-execution', 'sandbox', 'mcp', 'code-mode'],
+ apiKeyEnvName: 'VERCEL_OIDC_TOKEN',
+ installCommand: {
+ pnpm: 'pnpm install ctx-zip',
+ npm: 'npm install ctx-zip',
+ yarn: 'yarn add ctx-zip',
+ bun: 'bun add ctx-zip',
+ },
+ codeExample: `import { gateway, generateText, stepCountIs } from 'ai';
import { createVercelSandboxCodeMode, SANDBOX_SYSTEM_PROMPT } from "ctx-zip";
const { tools, manager } = await createVercelSandboxCodeMode({
servers: [
@@ -161,9 +161,9 @@ const { text } = await generateText({
});
console.log(text);`,
- docsUrl: 'https://github.com/karthikscale3/ctx-zip/blob/main/README.md',
- apiKeyUrl: 'https://vercel.com/docs/vercel-sandbox#authentication',
- websiteUrl: 'https://github.com/karthikscale3/ctx-zip/blob/main/README.md',
- npmUrl: 'https://www.npmjs.com/package/ctx-zip',
- }
+ docsUrl: 'https://github.com/karthikscale3/ctx-zip/blob/main/README.md',
+ apiKeyUrl: 'https://vercel.com/docs/vercel-sandbox#authentication',
+ websiteUrl: 'https://github.com/karthikscale3/ctx-zip/blob/main/README.md',
+ npmUrl: 'https://www.npmjs.com/package/ctx-zip',
+ },
];
Analysis
Incorrect indentation in ctx-zip registry entry breaks code style consistency
What fails: The ctx-zip entry in content/tools-registry/registry.ts (lines 119-167) uses 6 spaces for property indentation, while all other entries in the tools registry use 4 spaces, violating the project's Prettier formatting standard.
How to reproduce:
pnpm prettier --check "content/tools-registry/registry.ts"Result (before fix):
[warn] content/tools-registry/registry.ts
[warn] Code style issues found in the above file. Run Prettier with --write to fix.
Expected: All files should pass Prettier's code style check. According to the Prettier configuration in package.json, the project uses tabWidth: 2, which results in 4-space indentation for top-level object properties.
Verification: After fixing the indentation from 6 spaces to 4 spaces to match other registry entries:
pnpm prettier --check "content/tools-registry/registry.ts"
# Result: All matched files use Prettier code style!
Background
Adding MCP Code Mode using ctx-zip to the Tools Registry
Summary
Updated tools registry to include ctx-zip
Manual Verification
Checklist
pnpm changesetin the project root)Future Work
Related Issues