Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/tools/custom.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { z } from "zod";
import { zodToJsonSchema } from "zod-to-json-schema";

import { GetConsoleLogsTool, ScreenshotTool } from "@repo/types/mcp/tool";

import { Tool } from "./tool";

const ScreenshotToolArgs = ScreenshotTool.shape.arguments.extend({
fullPage: z
.boolean()
.optional()
.default(false)
.describe(
"Whether to capture the full scrollable page instead of just the visible viewport",
),
});

export const getConsoleLogs: Tool = {
schema: {
name: GetConsoleLogsTool.shape.name.value,
Expand All @@ -28,12 +39,13 @@ export const screenshot: Tool = {
schema: {
name: ScreenshotTool.shape.name.value,
description: ScreenshotTool.shape.description.value,
inputSchema: zodToJsonSchema(ScreenshotTool.shape.arguments),
inputSchema: zodToJsonSchema(ScreenshotToolArgs),
},
handle: async (context, _params) => {
handle: async (context, params) => {
const { fullPage } = ScreenshotToolArgs.parse(params);
const screenshot = await context.sendSocketMessage(
"browser_screenshot",
{},
{ fullPage } as any,
);
return {
content: [
Expand Down