I'm writing a script to use this MCP server. Sometime LLM forgets to call browser_close and my script calls close() method on MCP client. Then, MCP server looks closing browser (probably by signal propagation) but MCP server itself hangs so that my script waits forever.
This is the minimal code to reproduce this issue. This script waits for something. If you uncomment browser_close, it properly exits, though.
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
const transport = new StdioClientTransport({
command: "npx",
args: ["@playwright/mcp@latest"],
});
const client = new Client({
name: "playwright",
version: "1.0.0",
});
await client.connect(transport);
await client.callTool({
name: "browser_navigate",
arguments: {
url: "https://example.com",
},
});
await client.callTool({
name: "browser_wait",
arguments: {
time: 3,
},
});
//await client.callTool({
// name: "browser_close",
// arguments: {},
//});
await client.close();
I'm writing a script to use this MCP server. Sometime LLM forgets to call browser_close and my script calls
close()method on MCP client. Then, MCP server looks closing browser (probably by signal propagation) but MCP server itself hangs so that my script waits forever.This is the minimal code to reproduce this issue. This script waits for something. If you uncomment
browser_close, it properly exits, though.