feat(browser): add MCP tool dispatch

This commit is contained in:
Peter Steinberger
2025-12-19 23:57:26 +00:00
parent 0ac7a93c28
commit fa54950d2e
19 changed files with 2991 additions and 1243 deletions

View File

@@ -21,6 +21,11 @@ export type BrowserTab = {
type?: string;
};
export type BrowserToolResponse = {
ok: true;
[key: string]: unknown;
};
export type ScreenshotResult = {
ok: true;
path: string;
@@ -354,3 +359,23 @@ export async function browserClickRef(
},
);
}
export async function browserTool(
baseUrl: string,
opts: {
name: string;
args?: Record<string, unknown>;
targetId?: string;
},
): Promise<BrowserToolResponse> {
return await fetchJson<BrowserToolResponse>(`${baseUrl}/tool`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
name: opts.name,
args: opts.args ?? {},
targetId: opts.targetId,
}),
timeoutMs: 20000,
});
}