-
Notifications
You must be signed in to change notification settings - Fork 3.1k
feat(cli): add experimental MCP Apps support with resource/tool HTTP endpoints #13271
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
marius-kilocode
merged 7 commits into
Kilo-Org:main
from
romulorosa:feat/mcp-apps-experimental
Aug 20, 2026
+162
−3
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
36c57c1
feat(cli): add experimental MCP Apps support with resource/tool HTTP …
romulorosa c02134a
fix(cli): annotate MCP Apps changes, tighten callTool error handling
romulorosa 7ff184b
chore(cli): remove unrelated docs and bun.lock changes from MCP Apps PR
romulorosa b706992
refactor(cli): move MCP Apps logic into Kilo-owned module
romulorosa fa6d547
Merge branch 'main' into feat/mcp-apps-experimental
romulorosa b29f011
test(cli): add httpapi exerciser scenarios for MCP Apps endpoints
romulorosa 3452fa1
Merge branch 'main' into feat/mcp-apps-experimental
romulorosa 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
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,80 @@ | ||
| import { Effect, Schema } from "effect" | ||
| import { HttpApiError } from "effect/unstable/httpapi" | ||
| import type { MCP } from "@/mcp" | ||
| import type { RuntimeFlags } from "@/effect/runtime-flags" | ||
|
|
||
| /** | ||
| * MCP Apps lets MCP servers advertise UI resources alongside their tools. This module owns all the | ||
| * Kilo-specific behavior for that experimental feature so the shared upstream files only need to | ||
| * register the endpoints and call these helpers. | ||
| */ | ||
| export namespace McpApps { | ||
| export const ReadResourcePayload = Schema.Struct({ | ||
| uri: Schema.String, | ||
| server: Schema.String, | ||
| }) | ||
|
|
||
| export const ReadResourceContent = Schema.Struct({ | ||
| uri: Schema.String, | ||
| mimeType: Schema.optional(Schema.String), | ||
| text: Schema.optional(Schema.String), | ||
| blob: Schema.optional(Schema.String), | ||
| }) | ||
|
|
||
| export const CallToolPayload = Schema.Struct({ | ||
| server: Schema.String, | ||
| name: Schema.String, | ||
| arguments: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)), | ||
| }) | ||
|
|
||
| export const CallToolResponse = Schema.Struct({ | ||
| content: Schema.Array(Schema.Unknown), | ||
| isError: Schema.optional(Schema.Boolean), | ||
| structuredContent: Schema.optional(Schema.Record(Schema.String, Schema.Unknown)), | ||
| }) | ||
|
|
||
| /** Read a resource from a connected MCP server by URI. Used by MCP Apps to load UI resources. */ | ||
| export const readResource = (mcp: MCP.Interface, flags: RuntimeFlags.Info) => | ||
| Effect.fn("McpHttpApi.readResource")(function* (ctx: { payload: typeof ReadResourcePayload.Type }) { | ||
| if (!flags.experimentalMcpApps) return yield* Effect.fail(new HttpApiError.NotFound({})) | ||
| const result = yield* mcp.readResource(ctx.payload.server, ctx.payload.uri) | ||
| const content = result?.contents[0] | ||
| if (!content) return yield* Effect.fail(new HttpApiError.NotFound({})) | ||
| return { | ||
| uri: content.uri, | ||
| ...(content.mimeType ? { mimeType: content.mimeType } : {}), | ||
| ...("text" in content && content.text ? { text: content.text } : {}), | ||
| ...("blob" in content && content.blob ? { blob: content.blob } : {}), | ||
| } | ||
| }) | ||
|
|
||
| /** Call a tool on a connected MCP server. Used by MCP Apps for widget-initiated tool calls. */ | ||
| export const callTool = (mcp: MCP.Interface, flags: RuntimeFlags.Info) => | ||
| Effect.fn("McpHttpApi.callTool")(function* (ctx: { payload: typeof CallToolPayload.Type }) { | ||
| if (!flags.experimentalMcpApps) return yield* Effect.fail(new HttpApiError.NotFound({})) | ||
| const client = (yield* mcp.clients())[ctx.payload.server] | ||
| if (!client) return yield* Effect.fail(new HttpApiError.NotFound({})) | ||
| const result = yield* Effect.tryPromise(() => | ||
| client.callTool({ name: ctx.payload.name, arguments: ctx.payload.arguments ?? {} }), | ||
| ).pipe( | ||
| Effect.tapError((err) => Effect.logError("MCP callTool failed", { error: err })), | ||
| Effect.mapError(() => new HttpApiError.BadRequest({})), | ||
| ) | ||
| return { | ||
| content: result.content ?? [], | ||
| ...(result.isError ? { isError: true } : {}), | ||
| ...(result.structuredContent ? { structuredContent: result.structuredContent } : {}), | ||
| } | ||
| }) | ||
|
|
||
| /** | ||
| * Metadata a tool call should carry so hosts can preload the tool's MCP App UI resource. | ||
| * Returns undefined when the feature is disabled or the tool advertises no UI resource. | ||
| */ | ||
| export const toolMetadata = (entry: MCP.McpTool, flags: RuntimeFlags.Info) => { | ||
| if (!flags.experimentalMcpApps) return undefined | ||
| const ui = (entry.def._meta as { ui?: { resourceUri?: string } } | undefined)?.ui | ||
| if (!ui?.resourceUri) return undefined | ||
| return { mcpApp: { resourceUri: ui.resourceUri, serverId: entry.clientName } } | ||
| } | ||
| } | ||
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
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.
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.
[WARNING]: Widget-initiated MCP tool calls skip permission, sandbox, and timeout controls
Session MCP tool execution goes through
SandboxPolicy.executeMcpandctx.askbeforeclient.callTool, andMcpCatalog.convertToolalways passes the configured timeout, abort signal, andCallToolResultSchema. This HTTP path invokesclient.callToolwith only a name and arguments, so an authenticated client (or an unsecuredkilo serve) can run any connected MCP tool with no permission prompt, no sandbox network check, and no timeout. Consider routing through the same execution path as session/code-mode tool calls, or at least applying permission + timeout here.Reply with
@kilocode-bot fix itto have Kilo Code address this issue.