2025-03-25 14:46:39 -07:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2025-04-30 23:06:56 +02:00
|
|
|
import { createServerWithTools } from './server.js';
|
|
|
|
import common from './tools/common.js';
|
|
|
|
import console from './tools/console.js';
|
|
|
|
import dialogs from './tools/dialogs.js';
|
|
|
|
import files from './tools/files.js';
|
|
|
|
import install from './tools/install.js';
|
|
|
|
import keyboard from './tools/keyboard.js';
|
|
|
|
import navigate from './tools/navigate.js';
|
|
|
|
import network from './tools/network.js';
|
|
|
|
import pdf from './tools/pdf.js';
|
|
|
|
import snapshot from './tools/snapshot.js';
|
|
|
|
import tabs from './tools/tabs.js';
|
|
|
|
import screen from './tools/screen.js';
|
2025-05-02 17:41:58 -07:00
|
|
|
import testing from './tools/testing.js';
|
2025-04-30 23:06:56 +02:00
|
|
|
import type { Tool } from './tools/tool.js';
|
|
|
|
import type { Config } from '../config.js';
|
2025-03-25 14:46:39 -07:00
|
|
|
import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
|
|
|
2025-04-22 13:24:38 +02:00
|
|
|
const snapshotTools: Tool<any>[] = [
|
2025-04-15 01:09:48 +02:00
|
|
|
...common(true),
|
2025-04-15 18:01:59 -07:00
|
|
|
...console,
|
2025-04-17 14:03:13 -07:00
|
|
|
...dialogs(true),
|
2025-04-04 17:14:30 -07:00
|
|
|
...files(true),
|
2025-04-04 15:22:00 -07:00
|
|
|
...install,
|
|
|
|
...keyboard(true),
|
|
|
|
...navigate(true),
|
2025-04-22 16:04:25 -07:00
|
|
|
...network,
|
2025-04-04 15:22:00 -07:00
|
|
|
...pdf,
|
|
|
|
...snapshot,
|
|
|
|
...tabs(true),
|
2025-05-02 17:41:58 -07:00
|
|
|
...testing,
|
2025-03-25 14:46:39 -07:00
|
|
|
];
|
|
|
|
|
2025-04-22 13:24:38 +02:00
|
|
|
const screenshotTools: Tool<any>[] = [
|
2025-04-15 01:09:48 +02:00
|
|
|
...common(false),
|
2025-04-15 18:01:59 -07:00
|
|
|
...console,
|
2025-04-17 14:03:13 -07:00
|
|
|
...dialogs(false),
|
2025-04-04 17:14:30 -07:00
|
|
|
...files(false),
|
2025-04-04 15:22:00 -07:00
|
|
|
...install,
|
|
|
|
...keyboard(false),
|
|
|
|
...navigate(false),
|
2025-04-22 16:04:25 -07:00
|
|
|
...network,
|
2025-04-04 15:22:00 -07:00
|
|
|
...pdf,
|
|
|
|
...screen,
|
|
|
|
...tabs(false),
|
2025-05-02 17:41:58 -07:00
|
|
|
...testing,
|
2025-03-25 14:46:39 -07:00
|
|
|
];
|
|
|
|
|
2025-04-30 23:06:56 +02:00
|
|
|
import packageJSON from '../package.json' with { type: 'json' };
|
2025-03-25 14:46:39 -07:00
|
|
|
|
2025-04-28 16:14:16 -07:00
|
|
|
export async function createServer(config: Config = {}): Promise<Server> {
|
|
|
|
const allTools = config.vision ? screenshotTools : snapshotTools;
|
|
|
|
const tools = allTools.filter(tool => !config.capabilities || tool.capability === 'core' || config.capabilities.includes(tool.capability));
|
2025-03-26 15:02:45 -07:00
|
|
|
return createServerWithTools({
|
|
|
|
name: 'Playwright',
|
|
|
|
version: packageJSON.version,
|
|
|
|
tools,
|
2025-04-28 16:14:16 -07:00
|
|
|
}, config);
|
2025-04-15 16:39:52 -07:00
|
|
|
}
|