contextguard 0.2.1 → 0.2.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/dist/cli.js CHANGED
@@ -251,9 +251,7 @@ async function main() {
251
251
  agentId: process.env.AGENT_ID || "default-agent",
252
252
  }
253
253
  : undefined;
254
- if (supabaseConfig) {
255
- console.log(`✓ Supabase integration enabled (Agent ID: ${supabaseConfig.agentId})`);
256
- }
254
+ // Supabase integration is configured silently to avoid polluting stderr
257
255
  // Start REST-based heartbeat if CONTEXTGUARD_API_KEY is set
258
256
  const cgApiKey = process.env.CONTEXTGUARD_API_KEY;
259
257
  if (cgApiKey) {
@@ -283,7 +281,7 @@ async function main() {
283
281
  sendHeartbeat();
284
282
  const interval = setInterval(sendHeartbeat, 30000);
285
283
  interval.unref();
286
- console.log(`✓ ContextGuard monitoring enabled (Agent ID: ${agentId})`);
284
+ // Heartbeat configured silently to avoid polluting stderr
287
285
  }
288
286
  // Create and start agent
289
287
  const agent = (0, agent_1.createAgent)(parseCommand(serverCommand), config, supabaseConfig);
package/dist/logger.js CHANGED
@@ -41,6 +41,8 @@ var __importStar = (this && this.__importStar) || (function () {
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.createLogger = void 0;
43
43
  const fs = __importStar(require("fs"));
44
+ const os = __importStar(require("os"));
45
+ const path = __importStar(require("path"));
44
46
  const MAX_STORED_EVENTS = 1000;
45
47
  /**
46
48
  * Count events by a specific field
@@ -77,7 +79,7 @@ const fireWebhookAlert = (webhookUrl, event) => {
77
79
  * @param alertOnSeverity - Severity levels that trigger webhook alerts
78
80
  * @returns Logger functions
79
81
  */
80
- const createLogger = (logFile = "mcp_security.log", supabaseClient, agentId = "", alertWebhook, alertOnSeverity = ["HIGH", "CRITICAL"]) => {
82
+ const createLogger = (logFile = path.join(os.homedir(), ".contextguard", "mcp_security.log"), supabaseClient, agentId = "", alertWebhook, alertOnSeverity = ["HIGH", "CRITICAL"]) => {
81
83
  let events = [];
82
84
  return {
83
85
  /**
@@ -99,12 +101,14 @@ const createLogger = (logFile = "mcp_security.log", supabaseClient, agentId = ""
99
101
  if (events.length > MAX_STORED_EVENTS) {
100
102
  events = events.slice(-MAX_STORED_EVENTS);
101
103
  }
102
- // Write to log file
104
+ // Write to log file (silently fail if filesystem is read-only)
103
105
  try {
106
+ fs.mkdirSync(path.dirname(logFile), { recursive: true });
104
107
  fs.appendFileSync(logFile, JSON.stringify(event) + "\n");
105
108
  }
106
- catch (error) {
107
- console.error("Failed to write to log file:", error);
109
+ catch {
110
+ // Silently ignore filesystem errors to avoid polluting stderr
111
+ // This can happen in read-only environments like Claude Desktop
108
112
  }
109
113
  // Alert on high/critical severity
110
114
  if (severity === "HIGH" || severity === "CRITICAL") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contextguard",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Security monitoring wrapper for MCP servers with enterprise features",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -67,4 +67,4 @@
67
67
  "@anthropic-ai/sdk": "^0.54.0",
68
68
  "@supabase/supabase-js": "^2.79.0"
69
69
  }
70
- }
70
+ }