Skip to content

Commit a01af85

Browse files
author
Piotr Paulski
committed
refactor: bundle modelcontextprotocol-sdk
1 parent 41d6a10 commit a01af85

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

scripts/post-build.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7+
import { execSync } from 'node:child_process';
78
import * as fs from 'node:fs';
89
import * as path from 'node:path';
910

@@ -59,6 +60,10 @@ function copyThirdPartyLicenseFiles() {
5960
}
6061
}
6162

63+
async function bundle(path: string): Promise<void> {
64+
execSync(`npx esbuild ${path} --bundle --outfile=${path} --platform=node --allow-overwrite --target=es2022 --format=esm`);
65+
}
66+
6267
function main(): void {
6368
const devtoolsThirdPartyPath =
6469
'node_modules/chrome-devtools-frontend/front_end/third_party';
@@ -183,6 +188,8 @@ export const hostConfig = {};
183188
fs.copyFileSync(devtoolsLicenseFileSource, devtoolsLicenseFileDestination);
184189

185190
copyThirdPartyLicenseFiles();
191+
192+
bundle('./build/src/third_party/modelcontextprotocol-sdk/index.js');
186193
}
187194

188195
main();

src/McpResponse.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
* Copyright 2025 Google LLC
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
import type {
7-
ImageContent,
8-
TextContent,
9-
} from '@modelcontextprotocol/sdk/types.js';
106
import type {ConsoleMessage, ResourceType} from 'puppeteer-core';
117

128
import {formatConsoleEvent} from './formatters/consoleFormatter.js';
@@ -19,6 +15,10 @@ import {
1915
} from './formatters/networkFormatter.js';
2016
import {formatA11ySnapshot} from './formatters/snapshotFormatter.js';
2117
import type {McpContext} from './McpContext.js';
18+
import type {
19+
ImageContent,
20+
TextContent,
21+
} from './third_party/modelcontextprotocol-sdk/index.js';
2222
import {handleDialog} from './tools/pages.js';
2323
import type {ImageContentData, Response} from './tools/ToolDefinition.js';
2424
import {paginate, type PaginationOptions} from './utils/pagination.js';

src/main.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@
66

77
import './polyfill.js';
88

9-
import {McpServer} from '@modelcontextprotocol/sdk/server/mcp.js';
10-
import {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
11-
import type {CallToolResult} from '@modelcontextprotocol/sdk/types.js';
12-
import {SetLevelRequestSchema} from '@modelcontextprotocol/sdk/types.js';
13-
149
import type {Channel} from './browser.js';
1510
import {ensureBrowserConnected, ensureBrowserLaunched} from './browser.js';
1611
import {parseArguments} from './cli.js';
1712
import {logger, saveLogsToFile} from './logger.js';
1813
import {McpContext} from './McpContext.js';
1914
import {McpResponse} from './McpResponse.js';
2015
import {Mutex} from './Mutex.js';
16+
import {McpServer,StdioServerTransport,type CallToolResult,SetLevelRequestSchema} from './third_party/modelcontextprotocol-sdk/index.js';
2117
import * as consoleTools from './tools/console.js';
2218
import * as emulationTools from './tools/emulation.js';
2319
import * as inputTools from './tools/input.js';
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
export {McpServer} from '@modelcontextprotocol/sdk/server/mcp.js';
8+
export {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
9+
export {
10+
type CallToolResult,
11+
SetLevelRequestSchema,
12+
type ImageContent,
13+
type TextContent,
14+
} from '@modelcontextprotocol/sdk/types.js';

0 commit comments

Comments
 (0)