UNPKG

@mcp-shark/mcp-shark

Version:

Aggregate multiple Model Context Protocol (MCP) servers into a single unified interface with a powerful monitoring UI. Prov deep visibility into every request and response.

43 lines (36 loc) 1.22 kB
import { existsSync, readFileSync, writeFileSync } from 'node:fs'; import { getWorkingDirectory, prepareAppDataSpaces } from 'mcp-shark-common/configs/index.js'; import { join } from 'node:path'; const SMART_SCAN_TOKEN_NAME = 'smart-scan-token.json'; function getSmartScanTokenPath() { return join(getWorkingDirectory(), SMART_SCAN_TOKEN_NAME); } export function readSmartScanToken() { try { const tokenPath = getSmartScanTokenPath(); if (existsSync(tokenPath)) { const content = readFileSync(tokenPath, 'utf8'); const data = JSON.parse(content); return data.token || null; } return null; } catch (error) { console.error('Error reading Smart Scan token:', error); return null; } } export function writeSmartScanToken(token) { try { const tokenPath = getSmartScanTokenPath(); prepareAppDataSpaces(); // Ensure directory exists const data = { token: token || null, updatedAt: new Date().toISOString(), }; writeFileSync(tokenPath, JSON.stringify(data, null, 2), { mode: 0o600 }); // Read/write for owner only return true; } catch (error) { console.error('Error writing Smart Scan token:', error); return false; } }