[codex] feat: add hosted MCP toolkit#253
Open
MathewYoussef wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new configurable “Hosted MCP” toolkit that connects to a remote MCP server, discovers tools at request time, and improves UI rendering for dynamic/unknown tool invocations.
Changes:
- Introduces a new
mcptoolkit (client + server) with parameters for server URL and optional JSON headers. - Discovers remote MCP tools via the official MCP SDK and proxies tool calls through a short-lived MCP client connection.
- Adds a UI fallback renderer so dynamically discovered tools don’t render as broken/raw UI.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/toolkits/toolkits/shared.ts | Registers the new mcp toolkit in shared enums/types. |
| src/toolkits/toolkits/server.ts | Wires mcpToolkitServer into the server toolkit registry. |
| src/toolkits/toolkits/mcp/server.ts | Implements tool discovery and proxy execution via MCP SDK with timeouts/cleanup. |
| src/toolkits/toolkits/mcp/base.ts | Defines MCP toolkit parameter schema (server URL + headers). |
| src/toolkits/toolkits/mcp/client.tsx | Adds the client-side “Hosted MCP” toolkit metadata for the UI. |
| src/toolkits/toolkits/mcp/form.tsx | Adds configuration form inputs for URL and headers. |
| src/toolkits/toolkits/client.ts | Wires mcpClientToolkit into the client toolkit registry. |
| src/app/api/chat/route.ts | Adjusts tool map construction to use Object.entries (supports dynamic tool records cleanly). |
| src/app/(general)/_components/chat/messages/message-tool.tsx | Adds fallback rendering when a tool invocation can’t be matched to a known tool config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+30
to
+33
| export const mcpParameters = z.object({ | ||
| serverUrl: z.string().trim().url(), | ||
| headers: headersSchema, | ||
| }); |
Comment on lines
+38
to
+43
| acc[localName] = { | ||
| description: [ | ||
| tool.description ?? `Call the ${tool.name} MCP tool.`, | ||
| `Remote MCP tool name: ${tool.name}.`, | ||
| `Input JSON schema: ${inputSchema}`, | ||
| ].join("\n"), |
Comment on lines
+84
to
+92
| try { | ||
| const operation = (async () => { | ||
| await client.connect(transport); | ||
| return callback(client); | ||
| })(); | ||
|
|
||
| operation.catch(() => undefined); | ||
|
|
||
| return await Promise.race([ |
b3065b2 to
b1b5f1f
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Validation
./node_modules/.bin/tsc --noEmit./node_modules/.bin/eslint ..../node_modules/.bin/prettier --check ...git diff --checkNODE_PATH=/private/tmp/toolkit.dev/node_modules ./node_modules/.bin/tsx /private/tmp/toolkit-mcp-stress.tsRelated to #82