Lines 1729-1784javascript
1729 const tools = await fetchTools();
1730 activeTools.clear();
1731 for (const t of tools) {
1732 if (t.group === 'core' && !BUILT_IN_NAMES.has(t.name)) activeTools.set(t.name, t);
1735 await server.sendToolListChanged();
1736 log(`Switched to workspace "${slug}", ${activeTools.size} core tools loaded`);
1739 content: [{ type: 'text', text: `Switched to workspace "${slug}". Loaded ${tools.length} tools (${activeTools.size} core active). Use search_tools to activate more.` }],
1742 return { content: [{ type: 'text', text: `Error switching workspace: ${err.message}` }], isError: true };
1746// ─── Bootstrap ───────────────────────────────────────────────────────────────
1748// ─── Auto-update from git ────────────────────────────────────────────────────
1750import { execSync } from 'child_process';
1751import { dirname } from 'path';
1752import { fileURLToPath } from 'url';
1754const __dirname = dirname(fileURLToPath(import.meta.url));
1755const AUTO_UPDATE_INTERVAL = 60 * 60 * 1000; // check every hour
1757function tryAutoUpdate() {
1759 execSync('git rev-parse --git-dir', { cwd: __dirname, stdio: 'ignore' });
1760 const before = execSync('git rev-parse HEAD', { cwd: __dirname, encoding: 'utf8' }).trim();
1761 execSync('git pull --ff-only', { cwd: __dirname, stdio: 'ignore', timeout: 15000 });
1762 const after = execSync('git rev-parse HEAD', { cwd: __dirname, encoding: 'utf8' }).trim();
1763 if (before !== after) {
1764 log(`Updated ${before.slice(0, 7)} → ${after.slice(0, 7)}, restarting...`);
1765 try { execSync('npm install --omit=dev', { cwd: __dirname, stdio: 'ignore', timeout: 30000 }); } catch {}
1766 // Allow pending responses to drain before exit
HighRuntime Package Install
Package source invokes a package manager install command at runtime.
index.jsView on unpkg · L1764 1767 log('Shutting down gracefully...');
1768 setTimeout(() => process.exit(0), 2000);
1770 } catch { /* not a git repo or offline — skip */ }
1773async function main() {
1775 setInterval(tryAutoUpdate, AUTO_UPDATE_INTERVAL);
1777 log(`Connecting to ${BASE_URL}, workspace "${workspace || '(not set)'}"`);
1782 // 2. Fetch tool definitions (if workspace is set)
1784 const tools = await fetchTools();