1
0
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:
Namu
2025-04-25 05:49:00 +08:00
parent 31baf72b83
commit 9db12f2b4f
5 changed files with 38 additions and 11 deletions

View File

@@ -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",

View File

@@ -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);

View File

@@ -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),

View File

@@ -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",
},
],
};
},
};

View File

@@ -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);
}
}