Skip to content

[codex] feat: add hosted MCP toolkit#253

Open
MathewYoussef wants to merge 1 commit into
jasonhedman:mainfrom
MathewYoussef:codex/hosted-mcp-toolkit
Open

[codex] feat: add hosted MCP toolkit#253
MathewYoussef wants to merge 1 commit into
jasonhedman:mainfrom
MathewYoussef:codex/hosted-mcp-toolkit

Conversation

@MathewYoussef
Copy link
Copy Markdown

Summary

  • add a configurable Hosted MCP toolkit that accepts a server URL and optional JSON headers
  • discover remote MCP tools at request time and proxy calls through the official MCP SDK
  • add fallback rendering for dynamic toolkit tool invocations so discovered MCP tools do not fall back to raw broken UI

Validation

  • ./node_modules/.bin/tsc --noEmit
  • targeted ./node_modules/.bin/eslint ...
  • targeted ./node_modules/.bin/prettier --check ...
  • git diff --check
  • NODE_PATH=/private/tmp/toolkit.dev/node_modules ./node_modules/.bin/tsx /private/tmp/toolkit-mcp-stress.ts

Related to #82

@MathewYoussef MathewYoussef marked this pull request as ready for review May 11, 2026 14:22
Copilot AI review requested due to automatic review settings May 11, 2026 14:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 mcp toolkit (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([
@MathewYoussef MathewYoussef force-pushed the codex/hosted-mcp-toolkit branch from b3065b2 to b1b5f1f Compare May 11, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants