@burtthecoder/mcp-shodan 1.0.4 → 1.0.5

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.
Files changed (2) hide show
  1. package/build/index.js +13 -5
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -7,8 +7,11 @@ import dotenv from "dotenv";
7
7
  import { z } from "zod";
8
8
  import { zodToJsonSchema } from "zod-to-json-schema";
9
9
  import fs from "fs";
10
+ import path from "path";
11
+ import os from "os";
10
12
  dotenv.config();
11
- const logFilePath = "E:/dev/shodan-mcp/server.log";
13
+ // Use os.tmpdir() for the log file to ensure we have write permissions
14
+ const logFilePath = path.join(os.tmpdir(), "mcp-shodan-server.log");
12
15
  const SHODAN_API_KEY = process.env.SHODAN_API_KEY;
13
16
  if (!SHODAN_API_KEY) {
14
17
  throw new Error("SHODAN_API_KEY environment variable is required.");
@@ -16,10 +19,15 @@ if (!SHODAN_API_KEY) {
16
19
  const API_BASE_URL = "https://api.shodan.io";
17
20
  // Logging Helper Function
18
21
  function logToFile(message) {
19
- const timestamp = new Date().toISOString();
20
- const formattedMessage = `[${timestamp}] ${message}\n`;
21
- fs.appendFileSync(logFilePath, formattedMessage, "utf8");
22
- console.error(formattedMessage.trim()); // Use stderr for logging to avoid interfering with stdout
22
+ try {
23
+ const timestamp = new Date().toISOString();
24
+ const formattedMessage = `[${timestamp}] ${message}\n`;
25
+ fs.appendFileSync(logFilePath, formattedMessage, "utf8");
26
+ console.error(formattedMessage.trim()); // Use stderr for logging to avoid interfering with stdout
27
+ }
28
+ catch (error) {
29
+ console.error(`Failed to write to log file: ${error}`);
30
+ }
23
31
  }
24
32
  // Tool Schemas
25
33
  const IpLookupArgsSchema = z.object({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@burtthecoder/mcp-shodan",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "description": "A Model Context Protocol server for Shodan API queries.",
6
6
  "main": "./build/index.js",
7
7
  "bin": {