mcp-server-commands 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/logging.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import fs from 'fs';
2
+ import path from 'path';
2
3
  export let is_verbose = false;
3
4
  if (process.argv.includes("--verbose")) {
4
5
  is_verbose = true;
@@ -7,6 +8,10 @@ const isJest = typeof process !== 'undefined' && !!process.env.JEST_WORKER_ID;
7
8
  if (isJest) {
8
9
  // is_verbose = true; // comment out to disable verbose logging in JEST test runner
9
10
  }
11
+ // CLI option to override log file location: e.g. --logFile=/tmp/mcp.log
12
+ const cliLogFile = process.argv
13
+ .find((arg) => arg.startsWith("--logFile="))
14
+ ?.split("=")[1];
10
15
  if (is_verbose) {
11
16
  always_log("INFO: verbose logging enabled");
12
17
  }
@@ -42,10 +47,12 @@ export function always_log(message, data) {
42
47
  // * all transports => server side log file
43
48
  const timestamp = new Date().toISOString();
44
49
  const logMessage = `[${timestamp}] ${message}${data ? ": " + JSON.stringify(data) : ""}`;
45
- const shareDir = process.env.HOME + "/.local/share/mcp-server-commands/";
46
- const logFile = shareDir + "/commands.log";
47
- fs.mkdirSync(shareDir, { recursive: true });
48
- fs.appendFileSync(logFile, logMessage + "\n");
50
+ const defaultShareDir = process.env.HOME + "/.local/share/mcp-server-commands/";
51
+ const defaultLogFile = defaultShareDir + "/commands.log";
52
+ const targetLogFile = cliLogFile ?? defaultLogFile;
53
+ const targetDir = cliLogFile ? path.dirname(cliLogFile) : defaultShareDir;
54
+ fs.mkdirSync(targetDir, { recursive: true });
55
+ fs.appendFileSync(targetLogFile, logMessage + "\n");
49
56
  // TODO any hail mary if this logging fails? just use console.error then?
50
57
  // else still can get seemingly hung tool calls
51
58
  }
package/build/tools.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import os from "os";
2
2
  import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
3
3
  import { verbose_log } from "./logging.js";
4
- import { runProcess } from "./exec-utils.js";
4
+ import { runProcess } from "./run_process.js";
5
5
  export function registerTools(server) {
6
6
  server.setRequestHandler(ListToolsRequestSchema, async () => {
7
7
  verbose_log("INFO: ListTools");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-server-commands",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "An MCP server to run arbitrary commands",
5
5
  "private": false,
6
6
  "type": "module",
File without changes