Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
"@rollup/plugin-node-resolve": "^16.0.3",
"@stylistic/eslint-plugin": "^5.4.0",
"@toon-format/toon": "^2.2.0",
"@types/debug": "^4.1.12",
"@types/filesystem": "^0.0.36",
"@types/node": "^26.0.0",
"@types/semver": "^7.7.1",
Expand All @@ -66,7 +65,6 @@
"@typescript-eslint/parser": "^8.43.0",
"chrome-devtools-frontend": "1.0.1652307",
"core-js": "3.49.0",
"debug": "4.4.3",
"eslint": "^9.35.0",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-import": "^2.32.0",
Expand Down
26 changes: 16 additions & 10 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,23 @@
*/

import fs from 'node:fs';
import {debuglog} from 'node:util';

import {debug} from './third_party/index.js';
import type {Logger} from './types.js';

const mcpDebugNamespace = 'mcp:log';

const namespacesToEnable = [
mcpDebugNamespace,
...(process.env['DEBUG'] ? [process.env['DEBUG']] : []),
];
const nodeDebugLogger = debuglog(mcpDebugNamespace);

export function saveLogsToFile(fileName: string): fs.WriteStream {
// Enable overrides everything so we need to add them
debug.enable(namespacesToEnable.join(','));
let fileLogger: ((...args: unknown[]) => void) | null = null;

export function saveLogsToFile(fileName: string): fs.WriteStream {
const logFile = fs.createWriteStream(fileName, {flags: 'a+'});
debug.log = function (...chunks: any[]) {

fileLogger = (...chunks: unknown[]) => {
logFile.write(`${chunks.join(' ')}\n`);
};

logFile.on('error', function (error) {
console.error(`Error when opening/writing to log file: ${error.message}`);
logFile.end();
Expand All @@ -45,4 +43,12 @@ export function flushLogs(
});
}

export const logger: Logger = debug(mcpDebugNamespace) as Logger;
let logger: Logger|undefined;

if (fileLogger) {
logger = fileLogger;
} else if (nodeDebugLogger.enabled) {
logger = nodeDebugLogger as unknown as Logger;
}

export {logger};
3 changes: 1 addition & 2 deletions src/third_party/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export type {Options as YargsOptions} from 'yargs';
export {default as yargs} from 'yargs';
export {hideBin} from 'yargs/helpers';
export {default as semver} from 'semver';
export {default as debug} from 'debug';
export type {Debugger} from 'debug';

export {McpServer} from '@modelcontextprotocol/sdk/server/mcp.js';
export {type ShapeOutput} from '@modelcontextprotocol/sdk/server/zod-compat.js';
export {StdioServerTransport} from '@modelcontextprotocol/sdk/server/stdio.js';
Expand Down
95 changes: 0 additions & 95 deletions tests/third_party_notices.test.js.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -345,101 +345,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


-------------------- DEPENDENCY DIVIDER --------------------

Name: debug
URL: git://github.com/debug-js/debug.git
Version: <VERSION>
License: MIT

(The MIT License)

Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca>
Copyright (c) 2018-2021 Josh Junon

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the 'Software'), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



-------------------- DEPENDENCY DIVIDER --------------------

Name: ms
URL: vercel/ms
Version: <VERSION>
License: MIT

The MIT License (MIT)

Copyright (c) 2020 Vercel, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


-------------------- DEPENDENCY DIVIDER --------------------

Name: has-flag
URL: sindresorhus/has-flag
Version: <VERSION>
License: MIT

MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


-------------------- DEPENDENCY DIVIDER --------------------

Name: supports-color
URL: chalk/supports-color
Version: <VERSION>
License: MIT

MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


-------------------- DEPENDENCY DIVIDER --------------------

Name: zod
Expand Down
3 changes: 1 addition & 2 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {spawn} from 'node:child_process';
import path from 'node:path';

import type {CallToolResult} from '@modelcontextprotocol/sdk/types.js';
import logger from 'debug';
import type {Browser} from 'puppeteer';
import puppeteer, {Locator} from 'puppeteer';
import type {
Expand Down Expand Up @@ -132,7 +131,7 @@ export async function withMcpContext(
}
context = await McpContext.from(
browser,
logger('test'),
undefined,
{
experimentalDevToolsDebugging: false,
performanceCrux: options.performanceCrux ?? true,
Expand Down
Loading