feat(auth): implement user authentication system
This commit is contained in:
parent
4847ab793a
commit
25cea4fbe8
12051 changed files with 1462377 additions and 0 deletions
28
backend/node_modules/playwright/lib/mcp/sdk/exports.js
generated
vendored
Normal file
28
backend/node_modules/playwright/lib/mcp/sdk/exports.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var exports_exports = {};
|
||||
module.exports = __toCommonJS(exports_exports);
|
||||
__reExport(exports_exports, require("./inProcessTransport"), module.exports);
|
||||
__reExport(exports_exports, require("./server"), module.exports);
|
||||
__reExport(exports_exports, require("./tool"), module.exports);
|
||||
__reExport(exports_exports, require("./http"), module.exports);
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
...require("./inProcessTransport"),
|
||||
...require("./server"),
|
||||
...require("./tool"),
|
||||
...require("./http")
|
||||
});
|
||||
152
backend/node_modules/playwright/lib/mcp/sdk/http.js
generated
vendored
Normal file
152
backend/node_modules/playwright/lib/mcp/sdk/http.js
generated
vendored
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var http_exports = {};
|
||||
__export(http_exports, {
|
||||
addressToString: () => addressToString,
|
||||
startMcpHttpServer: () => startMcpHttpServer
|
||||
});
|
||||
module.exports = __toCommonJS(http_exports);
|
||||
var import_assert = __toESM(require("assert"));
|
||||
var import_crypto = __toESM(require("crypto"));
|
||||
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
||||
var mcpBundle = __toESM(require("playwright-core/lib/mcpBundle"));
|
||||
var import_utils = require("playwright-core/lib/utils");
|
||||
var mcpServer = __toESM(require("./server"));
|
||||
const testDebug = (0, import_utilsBundle.debug)("pw:mcp:test");
|
||||
async function startMcpHttpServer(config, serverBackendFactory, allowedHosts) {
|
||||
const httpServer = (0, import_utils.createHttpServer)();
|
||||
await (0, import_utils.startHttpServer)(httpServer, config);
|
||||
return await installHttpTransport(httpServer, serverBackendFactory, allowedHosts);
|
||||
}
|
||||
function addressToString(address, options) {
|
||||
(0, import_assert.default)(address, "Could not bind server socket");
|
||||
if (typeof address === "string")
|
||||
throw new Error("Unexpected address type: " + address);
|
||||
let host = address.family === "IPv4" ? address.address : `[${address.address}]`;
|
||||
if (options.normalizeLoopback && (host === "0.0.0.0" || host === "[::]" || host === "[::1]" || host === "127.0.0.1"))
|
||||
host = "localhost";
|
||||
return `${options.protocol}://${host}:${address.port}`;
|
||||
}
|
||||
async function installHttpTransport(httpServer, serverBackendFactory, allowedHosts) {
|
||||
const url = addressToString(httpServer.address(), { protocol: "http", normalizeLoopback: true });
|
||||
const host = new URL(url).host;
|
||||
allowedHosts = (allowedHosts || [host]).map((h) => h.toLowerCase());
|
||||
const allowAnyHost = allowedHosts.includes("*");
|
||||
const sseSessions = /* @__PURE__ */ new Map();
|
||||
const streamableSessions = /* @__PURE__ */ new Map();
|
||||
httpServer.on("request", async (req, res) => {
|
||||
if (!allowAnyHost) {
|
||||
const host2 = req.headers.host?.toLowerCase();
|
||||
if (!host2) {
|
||||
res.statusCode = 400;
|
||||
return res.end("Missing host");
|
||||
}
|
||||
if (!allowedHosts.includes(host2)) {
|
||||
res.statusCode = 403;
|
||||
return res.end("Access is only allowed at " + allowedHosts.join(", "));
|
||||
}
|
||||
}
|
||||
const url2 = new URL(`http://localhost${req.url}`);
|
||||
if (url2.pathname === "/killkillkill" && req.method === "GET") {
|
||||
res.statusCode = 200;
|
||||
res.end("Killing process");
|
||||
process.emit("SIGINT");
|
||||
return;
|
||||
}
|
||||
if (url2.pathname.startsWith("/sse"))
|
||||
await handleSSE(serverBackendFactory, req, res, url2, sseSessions);
|
||||
else
|
||||
await handleStreamable(serverBackendFactory, req, res, streamableSessions);
|
||||
});
|
||||
return url;
|
||||
}
|
||||
async function handleSSE(serverBackendFactory, req, res, url, sessions) {
|
||||
if (req.method === "POST") {
|
||||
const sessionId = url.searchParams.get("sessionId");
|
||||
if (!sessionId) {
|
||||
res.statusCode = 400;
|
||||
return res.end("Missing sessionId");
|
||||
}
|
||||
const transport = sessions.get(sessionId);
|
||||
if (!transport) {
|
||||
res.statusCode = 404;
|
||||
return res.end("Session not found");
|
||||
}
|
||||
return await transport.handlePostMessage(req, res);
|
||||
} else if (req.method === "GET") {
|
||||
const transport = new mcpBundle.SSEServerTransport("/sse", res);
|
||||
sessions.set(transport.sessionId, transport);
|
||||
testDebug(`create SSE session: ${transport.sessionId}`);
|
||||
await mcpServer.connect(serverBackendFactory, transport, false);
|
||||
res.on("close", () => {
|
||||
testDebug(`delete SSE session: ${transport.sessionId}`);
|
||||
sessions.delete(transport.sessionId);
|
||||
});
|
||||
return;
|
||||
}
|
||||
res.statusCode = 405;
|
||||
res.end("Method not allowed");
|
||||
}
|
||||
async function handleStreamable(serverBackendFactory, req, res, sessions) {
|
||||
const sessionId = req.headers["mcp-session-id"];
|
||||
if (sessionId) {
|
||||
const transport = sessions.get(sessionId);
|
||||
if (!transport) {
|
||||
res.statusCode = 404;
|
||||
res.end("Session not found");
|
||||
return;
|
||||
}
|
||||
return await transport.handleRequest(req, res);
|
||||
}
|
||||
if (req.method === "POST") {
|
||||
const transport = new mcpBundle.StreamableHTTPServerTransport({
|
||||
sessionIdGenerator: () => import_crypto.default.randomUUID(),
|
||||
onsessioninitialized: async (sessionId2) => {
|
||||
testDebug(`create http session: ${transport.sessionId}`);
|
||||
await mcpServer.connect(serverBackendFactory, transport, true);
|
||||
sessions.set(sessionId2, transport);
|
||||
}
|
||||
});
|
||||
transport.onclose = () => {
|
||||
if (!transport.sessionId)
|
||||
return;
|
||||
sessions.delete(transport.sessionId);
|
||||
testDebug(`delete http session: ${transport.sessionId}`);
|
||||
};
|
||||
await transport.handleRequest(req, res);
|
||||
return;
|
||||
}
|
||||
res.statusCode = 400;
|
||||
res.end("Invalid request");
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
addressToString,
|
||||
startMcpHttpServer
|
||||
});
|
||||
71
backend/node_modules/playwright/lib/mcp/sdk/inProcessTransport.js
generated
vendored
Normal file
71
backend/node_modules/playwright/lib/mcp/sdk/inProcessTransport.js
generated
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var inProcessTransport_exports = {};
|
||||
__export(inProcessTransport_exports, {
|
||||
InProcessTransport: () => InProcessTransport
|
||||
});
|
||||
module.exports = __toCommonJS(inProcessTransport_exports);
|
||||
class InProcessTransport {
|
||||
constructor(server) {
|
||||
this._connected = false;
|
||||
this._server = server;
|
||||
this._serverTransport = new InProcessServerTransport(this);
|
||||
}
|
||||
async start() {
|
||||
if (this._connected)
|
||||
throw new Error("InprocessTransport already started!");
|
||||
await this._server.connect(this._serverTransport);
|
||||
this._connected = true;
|
||||
}
|
||||
async send(message, options) {
|
||||
if (!this._connected)
|
||||
throw new Error("Transport not connected");
|
||||
this._serverTransport._receiveFromClient(message);
|
||||
}
|
||||
async close() {
|
||||
if (this._connected) {
|
||||
this._connected = false;
|
||||
this.onclose?.();
|
||||
this._serverTransport.onclose?.();
|
||||
}
|
||||
}
|
||||
_receiveFromServer(message, extra) {
|
||||
this.onmessage?.(message, extra);
|
||||
}
|
||||
}
|
||||
class InProcessServerTransport {
|
||||
constructor(clientTransport) {
|
||||
this._clientTransport = clientTransport;
|
||||
}
|
||||
async start() {
|
||||
}
|
||||
async send(message, options) {
|
||||
this._clientTransport._receiveFromServer(message);
|
||||
}
|
||||
async close() {
|
||||
this.onclose?.();
|
||||
}
|
||||
_receiveFromClient(message) {
|
||||
this.onmessage?.(message);
|
||||
}
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
InProcessTransport
|
||||
});
|
||||
223
backend/node_modules/playwright/lib/mcp/sdk/server.js
generated
vendored
Normal file
223
backend/node_modules/playwright/lib/mcp/sdk/server.js
generated
vendored
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var server_exports = {};
|
||||
__export(server_exports, {
|
||||
allRootPaths: () => allRootPaths,
|
||||
connect: () => connect,
|
||||
createServer: () => createServer,
|
||||
firstRootPath: () => firstRootPath,
|
||||
start: () => start,
|
||||
wrapInClient: () => wrapInClient,
|
||||
wrapInProcess: () => wrapInProcess
|
||||
});
|
||||
module.exports = __toCommonJS(server_exports);
|
||||
var import_url = require("url");
|
||||
var import_utilsBundle = require("playwright-core/lib/utilsBundle");
|
||||
var mcpBundle = __toESM(require("playwright-core/lib/mcpBundle"));
|
||||
var import_http = require("./http");
|
||||
var import_inProcessTransport = require("./inProcessTransport");
|
||||
const serverDebug = (0, import_utilsBundle.debug)("pw:mcp:server");
|
||||
const serverDebugResponse = (0, import_utilsBundle.debug)("pw:mcp:server:response");
|
||||
async function connect(factory, transport, runHeartbeat) {
|
||||
const server = createServer(factory.name, factory.version, factory.create(), runHeartbeat);
|
||||
await server.connect(transport);
|
||||
}
|
||||
function wrapInProcess(backend) {
|
||||
const server = createServer("Internal", "0.0.0", backend, false);
|
||||
return new import_inProcessTransport.InProcessTransport(server);
|
||||
}
|
||||
async function wrapInClient(backend, options) {
|
||||
const server = createServer("Internal", "0.0.0", backend, false);
|
||||
const transport = new import_inProcessTransport.InProcessTransport(server);
|
||||
const client = new mcpBundle.Client({ name: options.name, version: options.version });
|
||||
await client.connect(transport);
|
||||
await client.ping();
|
||||
return client;
|
||||
}
|
||||
function createServer(name, version, backend, runHeartbeat) {
|
||||
const server = new mcpBundle.Server({ name, version }, {
|
||||
capabilities: {
|
||||
tools: {}
|
||||
}
|
||||
});
|
||||
server.setRequestHandler(mcpBundle.ListToolsRequestSchema, async () => {
|
||||
serverDebug("listTools");
|
||||
const tools = await backend.listTools();
|
||||
return { tools };
|
||||
});
|
||||
let initializePromise;
|
||||
server.setRequestHandler(mcpBundle.CallToolRequestSchema, async (request, extra) => {
|
||||
serverDebug("callTool", request);
|
||||
const progressToken = request.params._meta?.progressToken;
|
||||
let progressCounter = 0;
|
||||
const progress = progressToken ? (params) => {
|
||||
extra.sendNotification({
|
||||
method: "notifications/progress",
|
||||
params: {
|
||||
progressToken,
|
||||
progress: params.progress ?? ++progressCounter,
|
||||
total: params.total,
|
||||
message: params.message
|
||||
}
|
||||
}).catch(serverDebug);
|
||||
} : () => {
|
||||
};
|
||||
try {
|
||||
if (!initializePromise)
|
||||
initializePromise = initializeServer(server, backend, runHeartbeat);
|
||||
await initializePromise;
|
||||
const toolResult = await backend.callTool(request.params.name, request.params.arguments || {}, progress);
|
||||
const mergedResult = mergeTextParts(toolResult);
|
||||
serverDebugResponse("callResult", mergedResult);
|
||||
return mergedResult;
|
||||
} catch (error) {
|
||||
return {
|
||||
content: [{ type: "text", text: "### Result\n" + String(error) }],
|
||||
isError: true
|
||||
};
|
||||
}
|
||||
});
|
||||
addServerListener(server, "close", () => backend.serverClosed?.(server));
|
||||
return server;
|
||||
}
|
||||
const initializeServer = async (server, backend, runHeartbeat) => {
|
||||
const capabilities = server.getClientCapabilities();
|
||||
let clientRoots = [];
|
||||
if (capabilities?.roots) {
|
||||
const { roots } = await server.listRoots().catch((e) => {
|
||||
serverDebug(e);
|
||||
return { roots: [] };
|
||||
});
|
||||
clientRoots = roots;
|
||||
}
|
||||
const clientInfo = {
|
||||
name: server.getClientVersion()?.name ?? "unknown",
|
||||
version: server.getClientVersion()?.version ?? "unknown",
|
||||
roots: clientRoots,
|
||||
timestamp: Date.now()
|
||||
};
|
||||
await backend.initialize?.(clientInfo);
|
||||
if (runHeartbeat)
|
||||
startHeartbeat(server);
|
||||
};
|
||||
const startHeartbeat = (server) => {
|
||||
const beat = () => {
|
||||
Promise.race([
|
||||
server.ping(),
|
||||
new Promise((_, reject) => setTimeout(() => reject(new Error("ping timeout")), 5e3))
|
||||
]).then(() => {
|
||||
setTimeout(beat, 3e3);
|
||||
}).catch(() => {
|
||||
void server.close();
|
||||
});
|
||||
};
|
||||
beat();
|
||||
};
|
||||
function addServerListener(server, event, listener) {
|
||||
const oldListener = server[`on${event}`];
|
||||
server[`on${event}`] = () => {
|
||||
oldListener?.();
|
||||
listener();
|
||||
};
|
||||
}
|
||||
async function start(serverBackendFactory, options) {
|
||||
if (options.port === void 0) {
|
||||
await connect(serverBackendFactory, new mcpBundle.StdioServerTransport(), false);
|
||||
return;
|
||||
}
|
||||
const url = await (0, import_http.startMcpHttpServer)(options, serverBackendFactory, options.allowedHosts);
|
||||
const mcpConfig = { mcpServers: {} };
|
||||
mcpConfig.mcpServers[serverBackendFactory.nameInConfig] = {
|
||||
url: `${url}/mcp`
|
||||
};
|
||||
const message = [
|
||||
`Listening on ${url}`,
|
||||
"Put this in your client config:",
|
||||
JSON.stringify(mcpConfig, void 0, 2),
|
||||
"For legacy SSE transport support, you can use the /sse endpoint instead."
|
||||
].join("\n");
|
||||
console.error(message);
|
||||
}
|
||||
function firstRootPath(clientInfo) {
|
||||
if (clientInfo.roots.length === 0)
|
||||
return void 0;
|
||||
const firstRootUri = clientInfo.roots[0]?.uri;
|
||||
const url = firstRootUri ? new URL(firstRootUri) : void 0;
|
||||
try {
|
||||
return url ? (0, import_url.fileURLToPath)(url) : void 0;
|
||||
} catch (error) {
|
||||
serverDebug(error);
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
function allRootPaths(clientInfo) {
|
||||
const paths = [];
|
||||
for (const root of clientInfo.roots) {
|
||||
try {
|
||||
const url = new URL(root.uri);
|
||||
const path = (0, import_url.fileURLToPath)(url);
|
||||
if (path)
|
||||
paths.push(path);
|
||||
} catch (error) {
|
||||
serverDebug(error);
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
function mergeTextParts(result) {
|
||||
const content = [];
|
||||
const testParts = [];
|
||||
for (const part of result.content) {
|
||||
if (part.type === "text") {
|
||||
testParts.push(part.text);
|
||||
continue;
|
||||
}
|
||||
if (testParts.length > 0) {
|
||||
content.push({ type: "text", text: testParts.join("\n") });
|
||||
testParts.length = 0;
|
||||
}
|
||||
content.push(part);
|
||||
}
|
||||
if (testParts.length > 0)
|
||||
content.push({ type: "text", text: testParts.join("\n") });
|
||||
return {
|
||||
...result,
|
||||
content
|
||||
};
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
allRootPaths,
|
||||
connect,
|
||||
createServer,
|
||||
firstRootPath,
|
||||
start,
|
||||
wrapInClient,
|
||||
wrapInProcess
|
||||
});
|
||||
47
backend/node_modules/playwright/lib/mcp/sdk/tool.js
generated
vendored
Normal file
47
backend/node_modules/playwright/lib/mcp/sdk/tool.js
generated
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var tool_exports = {};
|
||||
__export(tool_exports, {
|
||||
defineToolSchema: () => defineToolSchema,
|
||||
toMcpTool: () => toMcpTool
|
||||
});
|
||||
module.exports = __toCommonJS(tool_exports);
|
||||
var import_mcpBundle = require("playwright-core/lib/mcpBundle");
|
||||
function toMcpTool(tool) {
|
||||
const readOnly = tool.type === "readOnly" || tool.type === "assertion";
|
||||
return {
|
||||
name: tool.name,
|
||||
description: tool.description,
|
||||
inputSchema: import_mcpBundle.z.toJSONSchema(tool.inputSchema),
|
||||
annotations: {
|
||||
title: tool.title,
|
||||
readOnlyHint: readOnly,
|
||||
destructiveHint: !readOnly,
|
||||
openWorldHint: true
|
||||
}
|
||||
};
|
||||
}
|
||||
function defineToolSchema(tool) {
|
||||
return tool;
|
||||
}
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
defineToolSchema,
|
||||
toMcpTool
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue