mirror of
https://github.com/microsoft/playwright-mcp.git
synced 2025-07-26 16:42:27 +08:00
chore: change import assert to readFile (#368)
This commit is contained in:
parent
35e6c49d7c
commit
91ae93c167
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -37,7 +37,8 @@ jobs:
|
|||||||
- name: Use Node.js 18
|
- name: Use Node.js 18
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '18'
|
# https://github.com/microsoft/playwright-mcp/issues/344
|
||||||
|
node-version: '18.19'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
@ -18,14 +18,12 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|||||||
import { CallToolRequestSchema, ListToolsRequestSchema, Tool as McpTool } from '@modelcontextprotocol/sdk/types.js';
|
import { CallToolRequestSchema, ListToolsRequestSchema, Tool as McpTool } from '@modelcontextprotocol/sdk/types.js';
|
||||||
import { zodToJsonSchema } from 'zod-to-json-schema';
|
import { zodToJsonSchema } from 'zod-to-json-schema';
|
||||||
|
|
||||||
import { Context } from './context.js';
|
import { Context, packageJSON } from './context.js';
|
||||||
import { snapshotTools, screenshotTools } from './tools.js';
|
import { snapshotTools, screenshotTools } from './tools.js';
|
||||||
|
|
||||||
import type { Config } from '../config.js';
|
import type { Config } from '../config.js';
|
||||||
import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
|
import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
|
||||||
|
|
||||||
import packageJSON from '../package.json' with { type: 'json' };
|
|
||||||
|
|
||||||
export async function createConnection(config: Config): Promise<Connection> {
|
export async function createConnection(config: Config): Promise<Connection> {
|
||||||
const allTools = config.vision ? screenshotTools : snapshotTools;
|
const allTools = config.vision ? screenshotTools : snapshotTools;
|
||||||
const tools = allTools.filter(tool => !config.capabilities || tool.capability === 'core' || config.capabilities.includes(tool.capability));
|
const tools = allTools.filter(tool => !config.capabilities || tool.capability === 'core' || config.capabilities.includes(tool.capability));
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
|
import url from 'node:url';
|
||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
|
||||||
@ -381,3 +382,6 @@ async function createUserDataDir(browserConfig: Config['browser']) {
|
|||||||
export async function generateLocator(locator: playwright.Locator): Promise<string> {
|
export async function generateLocator(locator: playwright.Locator): Promise<string> {
|
||||||
return (locator as any)._generateLocatorString();
|
return (locator as any)._generateLocatorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const __filename = url.fileURLToPath(import.meta.url);
|
||||||
|
export const packageJSON = JSON.parse(fs.readFileSync(path.join(path.dirname(__filename), '..', 'package.json'), 'utf8'));
|
||||||
|
@ -20,8 +20,7 @@ import { startHttpTransport, startStdioTransport } from './transport.js';
|
|||||||
import { resolveConfig } from './config.js';
|
import { resolveConfig } from './config.js';
|
||||||
|
|
||||||
import type { Connection } from './connection.js';
|
import type { Connection } from './connection.js';
|
||||||
|
import { packageJSON } from './context.js';
|
||||||
import packageJSON from '../package.json' with { type: 'json' };
|
|
||||||
|
|
||||||
program
|
program
|
||||||
.version('Version ' + packageJSON.version)
|
.version('Version ' + packageJSON.version)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user