mcp-config.ts
1 import fs from 'fs'; 2 import os from 'os'; 3 import path from 'path'; 4 5 const CONFIG_FILENAME = 'gnosis-mcp-config.json'; 6 7 export function writeMcpConfig(githubToken: string): string { 8 const configPath = path.join(os.tmpdir(), CONFIG_FILENAME); 9 const config = { 10 mcpServers: { 11 github: { 12 command: 'npx', 13 args: ['-y', '@modelcontextprotocol/server-github'], 14 env: { 15 GITHUB_PERSONAL_ACCESS_TOKEN: githubToken, 16 }, 17 }, 18 }, 19 }; 20 fs.writeFileSync(configPath, JSON.stringify(config, null, 2), { encoding: 'utf-8', mode: 0o600 }); 21 return configPath; 22 } 23 24 export function cleanupMcpConfig(configPath: string): void { 25 try { 26 if (fs.existsSync(configPath)) fs.unlinkSync(configPath); 27 } catch { 28 // best-effort cleanup 29 } 30 }