1
1
#!/usr/bin/env node
2
- import os from 'os'
2
+ import os from "os" ;
3
3
4
4
import { Server } from "@modelcontextprotocol/sdk/server/index.js" ;
5
5
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" ;
@@ -16,7 +16,7 @@ import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
16
16
import { runCommand } from "./run-command.js" ;
17
17
18
18
import { createRequire } from "module" ;
19
- import { always_log } from "./always_log.js" ;
19
+ import { verbose_log } from "./always_log.js" ;
20
20
const require = createRequire ( import . meta. url ) ;
21
21
const {
22
22
name : package_name ,
@@ -26,12 +26,6 @@ const {
26
26
// TODO use .promises? in node api
27
27
const execAsync = promisify ( exec ) ;
28
28
29
- let verbose = false ;
30
- // check CLI args:
31
- if ( process . argv . includes ( "--verbose" ) ) {
32
- verbose = true ;
33
- }
34
-
35
29
const server = new Server (
36
30
{
37
31
name : package_name ,
@@ -48,54 +42,14 @@ const server = new Server(
48
42
}
49
43
) ;
50
44
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
-
92
45
server . setRequestHandler ( ListToolsRequestSchema , async ( ) => {
93
46
verbose_log ( "INFO: ListTools" ) ;
94
47
return {
95
48
tools : [
96
49
{
97
50
name : "run_command" ,
98
- description : "Run a command on this " + os . platform ( ) + " machine" ,
51
+ description :
52
+ "Run a command on this " + os . platform ( ) + " machine" ,
99
53
inputSchema : {
100
54
type : "object" ,
101
55
properties : {
0 commit comments