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