11#!/usr/bin/env node
2- import os from 'os'
2+ import os from "os" ;
33
44import { Server } from "@modelcontextprotocol/sdk/server/index.js" ;
55import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" ;
@@ -16,7 +16,7 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
1616import { runCommand } from "./run-command.js" ;
1717
1818import { createRequire } from "module" ;
19- import { always_log } from "./always_log.js" ;
19+ import { verbose_log } from "./always_log.js" ;
2020const require = createRequire ( import . meta. url ) ;
2121const {
2222 name : package_name ,
@@ -26,12 +26,6 @@ const {
2626// TODO use .promises? in node api
2727const execAsync = promisify ( exec ) ;
2828
29- let verbose = false ;
30- // check CLI args:
31- if ( process . argv . includes ( "--verbose" ) ) {
32- verbose = true ;
33- }
34-
3529const server = new Server (
3630 {
3731 name : package_name ,
@@ -48,54 +42,14 @@ const server = new Server(
4842 }
4943) ;
5044
51- if ( verbose ) {
52- always_log ( "INFO: verbose logging enabled" ) ;
53- } else {
54- always_log ( "INFO: verbose logging disabled, enable it with --verbose" ) ;
55- }
56-
57- function verbose_log ( message : string , data ?: any ) {
58- // https://modelcontextprotocol.io/docs/tools/debugging - mentions various ways to debug/troubleshoot (including dev tools)
59- //
60- // remember STDIO transport means can't log over STDOUT (client expects JSON messages per the spec)
61- // https://modelcontextprotocol.io/docs/tools/debugging#implementing-logging
62- // mentions STDERR is captured by the host app (i.e. Claude Desktop app)
63- // server.sendLoggingMessage is captured by MCP client (not Claude Desktop app)
64- // SO, IIUC use STDERR for logging into Claude Desktop app logs in:
65- // '~/Library/Logs/Claude/mcp.log'
66- if ( verbose ) {
67- always_log ( message , data ) ;
68- }
69- // inspector, catches these logs and shows them on left hand side of screen (sidebar)
70-
71- // TODO add verbose parameter (CLI arg?)
72-
73- // IF I wanted to log via MCP client logs (not sure what those are/do):
74- // I do not see inspector catching these logs :(, there is a server notifications section and it remains empty
75- //server.sendLoggingMessage({
76- // level: "info",
77- // data: message,
78- //});
79- // which results in something like:
80- //server.notification({
81- // method: "notifications/message",
82- // params: {
83- // level: "warning",
84- // logger: "mcp-server-commands",
85- // data: "ListToolsRequest2",
86- // },
87- //});
88- //
89- // FYI client should also requets a log level from the server, so that needs to be here at some point too
90- }
91-
9245server . setRequestHandler ( ListToolsRequestSchema , async ( ) => {
9346 verbose_log ( "INFO: ListTools" ) ;
9447 return {
9548 tools : [
9649 {
9750 name : "run_command" ,
98- description : "Run a command on this " + os . platform ( ) + " machine" ,
51+ description :
52+ "Run a command on this " + os . platform ( ) + " machine" ,
9953 inputSchema : {
10054 type : "object" ,
10155 properties : {
0 commit comments