-
Notifications
You must be signed in to change notification settings - Fork 5.5k
feat(mcp): expose preview list and close #10559
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
juliusmarminge
merged 1 commit into
agents/mcp-thin/conversation-transfer
from
agents/mcp-thin/preview
Sep 7, 2026
Merged
Changes from all commits
Commits
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
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,41 @@ | ||
| import { OrchestratorMcpFailure } from "@t3tools/contracts"; | ||
| import * as Effect from "effect/Effect"; | ||
| import * as Preview from "../../../preview/Manager.ts"; | ||
| import * as ServerSettings from "../../../serverSettings.ts"; | ||
| import { requireMcpCapability } from "../../McpInvocationContext.ts"; | ||
| import { unavailable } from "../../threadAccess.ts"; | ||
| import { PreviewControlsToolkit } from "./tools.ts"; | ||
|
|
||
| const access = Effect.gen(function* () { | ||
| const scope = yield* requireMcpCapability("preview"); | ||
| const settings = yield* ServerSettings.ServerSettingsService; | ||
| const current = yield* settings.getSettings.pipe(Effect.mapError(unavailable)); | ||
| if (!current.enableAgentBrowserAccess) | ||
| return yield* new OrchestratorMcpFailure({ | ||
| code: "capability_denied", | ||
| message: "Agent browser access is disabled.", | ||
| }); | ||
| return { scope, manager: yield* Preview.PreviewManager }; | ||
| }); | ||
| export const PreviewControlsHandlersLive = PreviewControlsToolkit.toLayer({ | ||
| t3_preview_list: (input) => | ||
| Effect.gen(function* () { | ||
| const { scope, manager } = yield* access; | ||
| const result = yield* manager.list({ threadId: scope.threadId }); | ||
| const start = input.cursor ?? 0; | ||
| const end = start + (input.limit ?? 20); | ||
| return { | ||
| ...result, | ||
| sessions: result.sessions.slice(start, end), | ||
| nextCursor: end < result.sessions.length ? end : null, | ||
| }; | ||
| }), | ||
| t3_preview_close: (input) => | ||
| Effect.gen(function* () { | ||
| const { scope, manager } = yield* access; | ||
| yield* manager | ||
| .close({ threadId: scope.threadId, tabId: input.tabId }) | ||
| .pipe(Effect.mapError(unavailable)); | ||
| return {}; | ||
| }), | ||
| }); | ||
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,41 @@ | ||
| import { | ||
| NonNegativeInt, | ||
| OrchestratorMcpFailure, | ||
| PreviewAutomationUnavailableError, | ||
| PreviewListResult, | ||
| PreviewTabId, | ||
| } from "@t3tools/contracts"; | ||
| import * as Schema from "effect/Schema"; | ||
| import { Tool, Toolkit } from "effect/unstable/ai"; | ||
| import { PreviewManager } from "../../../preview/Manager.ts"; | ||
| import { ServerSettingsService } from "../../../serverSettings.ts"; | ||
| import { McpInvocationContext } from "../../McpInvocationContext.ts"; | ||
|
|
||
| const shared = { | ||
| failure: Schema.Union([OrchestratorMcpFailure, PreviewAutomationUnavailableError]), | ||
| failureMode: "return" as const, | ||
| dependencies: [McpInvocationContext, PreviewManager, ServerSettingsService], | ||
| }; | ||
| export const PreviewListTool = Tool.make("t3_preview_list", { | ||
| ...shared, | ||
| description: | ||
| "List this thread's preview tabs. Pages reflect the current server state and may shift as tabs change.", | ||
| parameters: Schema.Struct({ | ||
| cursor: Schema.optional(NonNegativeInt), | ||
| limit: Schema.optional(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 50 }))), | ||
| }), | ||
| success: Schema.Struct({ | ||
| ...PreviewListResult.fields, | ||
| nextCursor: Schema.NullOr(NonNegativeInt), | ||
| }), | ||
| }) | ||
| .annotate(Tool.Readonly, true) | ||
| .annotate(Tool.Destructive, false); | ||
| export const PreviewCloseTool = Tool.make("t3_preview_close", { | ||
| ...shared, | ||
| description: | ||
| "Close one preview tab owned by this thread through the normal server/host tab lifecycle. This does not wait for renderer cleanup.", | ||
| parameters: Schema.Struct({ tabId: PreviewTabId }), | ||
| success: Schema.Struct({}), | ||
| }).annotate(Tool.Destructive, true); | ||
| export const PreviewControlsToolkit = Toolkit.make(PreviewListTool, PreviewCloseTool); |
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.
Uh oh!
There was an error while loading. Please reload this page.