mirror of
https://github.com/BrowserMCP/mcp.git
synced 2025-05-04 16:21:43 +03:00
chore: version 0.1.3
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@browsermcp/mcp",
|
||||
"version": "0.1.0",
|
||||
"version": "0.1.3",
|
||||
"description": "MCP server for browser automation using Browser MCP",
|
||||
"author": "Browser MCP",
|
||||
"homepage": "https://browsermcp.io",
|
||||
|
||||
@@ -28,10 +28,10 @@ export class Context {
|
||||
async sendSocketMessage<T extends MessageType<SocketMessageMap>>(
|
||||
type: T,
|
||||
payload: MessagePayload<SocketMessageMap, T>,
|
||||
options: { timeoutMs?: number } = { timeoutMs: 30000 }
|
||||
options: { timeoutMs?: number } = { timeoutMs: 30000 },
|
||||
) {
|
||||
const { sendSocketMessage } = createSocketMessageSender<SocketMessageMap>(
|
||||
this.ws
|
||||
this.ws,
|
||||
);
|
||||
try {
|
||||
return await sendSocketMessage(type, payload, options);
|
||||
|
||||
@@ -24,7 +24,7 @@ function setupExitWatchdog(server: Server) {
|
||||
|
||||
const commonTools: Tool[] = [common.pressKey, common.wait];
|
||||
|
||||
const customTools: Tool[] = [custom.getConsoleLogs];
|
||||
const customTools: Tool[] = [custom.getConsoleLogs, custom.screenshot];
|
||||
|
||||
const snapshotTools: Tool[] = [
|
||||
common.navigate(true),
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { zodToJsonSchema } from "zod-to-json-schema";
|
||||
|
||||
import { GetConsoleLogsTool } from "@repo/types/mcp/tool";
|
||||
import { GetConsoleLogsTool, ScreenshotTool } from "@repo/types/mcp/tool";
|
||||
|
||||
import { Tool } from "./tool";
|
||||
|
||||
@@ -23,3 +23,26 @@ export const getConsoleLogs: Tool = {
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
export const screenshot: Tool = {
|
||||
schema: {
|
||||
name: ScreenshotTool.shape.name.value,
|
||||
description: ScreenshotTool.shape.description.value,
|
||||
inputSchema: zodToJsonSchema(ScreenshotTool.shape.arguments),
|
||||
},
|
||||
handle: async (context, _params) => {
|
||||
const screenshot = await context.sendSocketMessage(
|
||||
"browser_screenshot",
|
||||
{},
|
||||
);
|
||||
return {
|
||||
content: [
|
||||
{
|
||||
type: "image",
|
||||
data: screenshot,
|
||||
mimeType: "image/png",
|
||||
},
|
||||
],
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -13,11 +13,15 @@ export async function isPortInUse(port: number): Promise<boolean> {
|
||||
}
|
||||
|
||||
export function killProcessOnPort(port: number) {
|
||||
if (process.platform === "win32") {
|
||||
execSync(
|
||||
`FOR /F "tokens=5" %a in ('netstat -ano ^| findstr :${port}') do taskkill /F /PID %a`,
|
||||
);
|
||||
} else {
|
||||
execSync(`lsof -ti:${port} | xargs kill -9`);
|
||||
try {
|
||||
if (process.platform === "win32") {
|
||||
execSync(
|
||||
`FOR /F "tokens=5" %a in ('netstat -ano ^| findstr :${port}') do taskkill /F /PID %a`,
|
||||
);
|
||||
} else {
|
||||
execSync(`lsof -ti:${port} | xargs kill -9`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to kill process on port ${port}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user