@asynkor/mcp 0.1.0

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.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,678 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { loadConfig, resolveConfig, initConfig, ConfigError } from './config.js';
4
+ import { AsynkorMcpProxy } from './proxy.js';
5
+ import readline from 'node:readline';
6
+ import fs from 'node:fs';
7
+ import path from 'node:path';
8
+ import os from 'node:os';
9
+ const [, , command, ...rest] = process.argv;
10
+ function parseFlags(args) {
11
+ const flags = {};
12
+ for (let i = 0; i < args.length; i++) {
13
+ if (args[i].startsWith('--') && i + 1 < args.length && !args[i + 1].startsWith('--')) {
14
+ flags[args[i].slice(2)] = args[i + 1];
15
+ i++;
16
+ }
17
+ }
18
+ return flags;
19
+ }
20
+ const ASYNKOR_WORKFLOW = `You are connected to a team via Asynkor — the shared brain for agent orchestrators.
21
+
22
+ Required workflow (every session, no exceptions):
23
+ 1. FIRST: call asynkor_briefing to see what teammates are working on.
24
+ 2. Before starting work: call asynkor_start with plan + paths (files you expect to touch). If the server returns an overlap or zone warning, stop and coordinate.
25
+ 3. Before editing files: call asynkor_check with the file paths. Respect any warnings.
26
+ 4. When you learn something important: call asynkor_remember to save it to the team brain.
27
+ 5. When done: call asynkor_finish with result, learnings, decisions, files_touched, and follow-ups.
28
+
29
+ Every asynkor_finish and asynkor_remember enriches the team's shared brain. Be generous — your decisions persist beyond your session and are inherited by every future agent.`;
30
+ const ASYNKOR_CLAUDE_MD = `## Asynkor — team coordination
31
+
32
+ You are connected to a team via Asynkor. This workflow is MANDATORY, not advisory.
33
+
34
+ ### Required workflow — follow this EVERY session, NO EXCEPTIONS
35
+
36
+ 1. **Session start**: Call \`asynkor_briefing\` FIRST, before anything else. This gives you the full team state: active work, recent decisions, open follow-ups, rules, zones, and team memory. Do not skip this.
37
+
38
+ 2. **Before starting work**: Call \`asynkor_start\` with:
39
+ - \`plan\`: what you're about to do, in plain language
40
+ - \`paths\`: comma-separated list of files you expect to touch (critical for overlap detection)
41
+ - \`followup_id\`: if you're picking up an open follow-up from the briefing
42
+
43
+ **CRITICAL — OVERLAP AND ZONE WARNINGS:**
44
+ If \`asynkor_start\` returns ANY overlap or zone warning, you MUST:
45
+ - **STOP IMMEDIATELY.** Do NOT proceed with the work.
46
+ - **Do NOT say "I'll proceed carefully"** — that defeats the entire purpose.
47
+ - **Tell the user exactly what the overlap is**: who is working on what, which files conflict.
48
+ - **Ask the user for an explicit go-ahead** before doing anything else.
49
+ - **If the user says to wait or change scope, obey.** Adjust your plan and call \`asynkor_start\` again with the new scope.
50
+
51
+ This is non-negotiable. Ignoring overlap warnings causes the exact problem Asynkor exists to prevent.
52
+
53
+ 3. **Before editing files**: Call \`asynkor_check\` with the file paths you plan to modify. This returns active overlaps, applicable rules, protected zones, and relevant team memory. If there are warnings, follow the same STOP protocol as step 2.
54
+
55
+ 4. **When you learn something important**: Call \`asynkor_remember\` to save it to the team brain. Good candidates: architectural decisions, gotchas, business logic insights, debugging discoveries, patterns found, conventions established. **Be generous — call this often.** Every memory you save makes the next agent smarter.
56
+
57
+ 5. **When done — MANDATORY, NEVER SKIP**: Call \`asynkor_finish\` with:
58
+ - \`result\`: what was accomplished
59
+ - \`learnings\`: key things learned (architectural insights, gotchas, patterns)
60
+ - \`decisions\`: important choices made and why
61
+ - \`files_touched\`: comma-separated list of files modified
62
+ - \`followups\`: JSON array of follow-up tasks for teammates
63
+
64
+ **You MUST call \`asynkor_finish\` before ending the conversation.** If the user says "thanks" or "done" or stops responding, call \`asynkor_finish\` with whatever you have. Incomplete finish is better than no finish.
65
+
66
+ ### Memory — capture aggressively
67
+
68
+ Call \`asynkor_remember\` whenever you:
69
+ - Make or discover an architectural decision
70
+ - Find a gotcha or non-obvious behavior
71
+ - Establish a pattern or convention
72
+ - Fix a bug with a non-obvious root cause
73
+ - Learn something about the codebase that would save a future agent time
74
+
75
+ One memory per insight. Short, specific, actionable.
76
+
77
+ ### Parallel work and sub-agents
78
+
79
+ If the briefing shows multiple open follow-ups that can be done in parallel (independent files, no overlap), consider using the Agent tool to spawn sub-agents for each one. Each sub-agent should:
80
+ - Call \`asynkor_start\` with its own plan and paths
81
+ - Do the work
82
+ - Call \`asynkor_remember\` with any learnings
83
+ - Call \`asynkor_finish\` with its results
84
+
85
+ If a sub-agent's \`asynkor_start\` returns an overlap warning, it MUST stop and surface the conflict — same rules as above, no exceptions.
86
+
87
+ ### Why this matters
88
+
89
+ Every call to \`asynkor_finish\` and \`asynkor_remember\` enriches the team's shared brain. If you skip \`asynkor_finish\` or don't call \`asynkor_remember\`, the next agent starts from scratch on everything you already figured out. That's wasted work for the entire team.`;
90
+ const AUTO_APPROVE_TOOLS = [
91
+ 'mcp__asynkor__asynkor_briefing',
92
+ 'mcp__asynkor__asynkor_start',
93
+ 'mcp__asynkor__asynkor_finish',
94
+ 'mcp__asynkor__asynkor_check',
95
+ 'mcp__asynkor__asynkor_remember',
96
+ ];
97
+ async function fetchJoinLink(url) {
98
+ const res = await fetch(url, {
99
+ headers: { Accept: 'application/json' },
100
+ });
101
+ if (!res.ok) {
102
+ const status = res.status;
103
+ if (status === 404 || status === 410) {
104
+ throw new Error('This join link has expired or has already been claimed.');
105
+ }
106
+ throw new Error(`Failed to fetch join link (HTTP ${status}).`);
107
+ }
108
+ return (await res.json());
109
+ }
110
+ function writeAsynkorJson(data) {
111
+ const target = path.join(process.cwd(), '.asynkor.json');
112
+ fs.writeFileSync(target, JSON.stringify(data, null, 2) + '\n');
113
+ }
114
+ function writeClaudeMd(content) {
115
+ const claudeMdPath = path.join(process.cwd(), 'CLAUDE.md');
116
+ const section = content || ASYNKOR_CLAUDE_MD;
117
+ if (fs.existsSync(claudeMdPath)) {
118
+ const existing = fs.readFileSync(claudeMdPath, 'utf8');
119
+ if (!existing.includes('Asynkor')) {
120
+ fs.appendFileSync(claudeMdPath, '\n' + section + '\n');
121
+ }
122
+ }
123
+ else {
124
+ fs.writeFileSync(claudeMdPath, section + '\n');
125
+ }
126
+ }
127
+ // Hooks injected by init so the Asynkor workflow is enforced, not just
128
+ // advisory. PreToolUse on Edit/Write reminds the agent to check for
129
+ // conflicts before touching files. UserPromptSubmit reminds the agent
130
+ // to call briefing at the start of each conversation turn when it
131
+ // hasn't done so yet this session.
132
+ const ASYNKOR_HOOKS = {
133
+ PreToolUse: [
134
+ {
135
+ matcher: 'Edit|Write',
136
+ hooks: [
137
+ {
138
+ type: 'command',
139
+ command: 'echo "⚠️ ASYNKOR: Have you called asynkor_check on these paths? If asynkor_start returned an overlap warning, STOP and ask the user. Do NOT proceed carefully — STOP."',
140
+ },
141
+ ],
142
+ },
143
+ ],
144
+ Stop: [
145
+ {
146
+ hooks: [
147
+ {
148
+ type: 'command',
149
+ command: 'echo "⚠️ ASYNKOR: You MUST call asynkor_finish before ending. Include result, learnings, decisions, files_touched, and followups. Also call asynkor_remember for any insights discovered during this session."',
150
+ },
151
+ ],
152
+ },
153
+ ],
154
+ };
155
+ function updateClaudeSettings() {
156
+ const claudeDir = path.join(process.cwd(), '.claude');
157
+ if (!fs.existsSync(claudeDir))
158
+ fs.mkdirSync(claudeDir, { recursive: true });
159
+ const settingsPath = path.join(claudeDir, 'settings.json');
160
+ let settings = {};
161
+ if (fs.existsSync(settingsPath)) {
162
+ try {
163
+ settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
164
+ }
165
+ catch { }
166
+ }
167
+ // Auto-approve all asynkor tools so the agent never hits a
168
+ // permission dialog during the workflow.
169
+ const perms = settings.permissions ?? {};
170
+ const allow = perms.allow ?? [];
171
+ for (const p of AUTO_APPROVE_TOOLS) {
172
+ if (!allow.includes(p))
173
+ allow.push(p);
174
+ }
175
+ settings.permissions = { ...perms, allow };
176
+ // Merge the asynkor hooks. Preserves any existing hooks the user has
177
+ // configured — we only add our entries, never overwrite theirs.
178
+ const existingHooks = settings.hooks ?? {};
179
+ for (const [event, hookEntries] of Object.entries(ASYNKOR_HOOKS)) {
180
+ const existing = existingHooks[event] ?? [];
181
+ // Skip if there's already a asynkor-related hook for this event
182
+ // so we don't duplicate on re-init.
183
+ const alreadyHasAsynkor = existing.some(h => typeof h === 'object' && h !== null && 'hooks' in h &&
184
+ JSON.stringify(h).includes('asynkor'));
185
+ if (!alreadyHasAsynkor) {
186
+ existingHooks[event] = [...existing, ...hookEntries];
187
+ }
188
+ }
189
+ settings.hooks = existingHooks;
190
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
191
+ }
192
+ async function cmdStart(args) {
193
+ const flags = parseFlags(args);
194
+ if (flags['server-url'])
195
+ process.env.ASYNKOR_SERVER_URL = flags['server-url'];
196
+ if (flags['api-key'])
197
+ process.env.ASYNKOR_API_KEY = flags['api-key'];
198
+ // Use resolveConfig() instead of loadConfig() so we can start even
199
+ // without a key. The proxy's hot-reload mechanism will detect when
200
+ // .asynkor.json appears (e.g. after the user runs init in another
201
+ // terminal) and connect automatically — no Claude Code restart needed.
202
+ const { config } = resolveConfig();
203
+ const proxy = new AsynkorMcpProxy(config);
204
+ let server;
205
+ try {
206
+ server = await proxy.createStdioServer();
207
+ }
208
+ catch (err) {
209
+ if (config) {
210
+ process.stderr.write(`[asynkor] Failed to connect to server at ${config.serverUrl}: ${err}\n`);
211
+ process.stderr.write('[asynkor] Make sure the Asynkor server is running.\n');
212
+ }
213
+ // Don't exit — the proxy will retry via scheduleReconnect.
214
+ // If there was no config, createStdioServer succeeds in disconnected
215
+ // mode and the proxy waits for config to appear.
216
+ if (!config) {
217
+ process.stderr.write('[asynkor] Starting in disconnected mode. Tools will return errors until an API key is configured.\n');
218
+ }
219
+ else {
220
+ process.exit(1);
221
+ }
222
+ }
223
+ const transport = new StdioServerTransport();
224
+ await server.connect(transport);
225
+ }
226
+ function generateIdeConfig(ide, apiKey) {
227
+ const mcpServersJson = JSON.stringify({
228
+ mcpServers: {
229
+ asynkor: {
230
+ command: 'npx',
231
+ args: ['-y', '@asynkor/mcp', 'start'],
232
+ env: { ASYNKOR_API_KEY: apiKey },
233
+ },
234
+ },
235
+ }, null, 2);
236
+ const vscodeJson = JSON.stringify({
237
+ servers: {
238
+ asynkor: {
239
+ command: 'npx',
240
+ args: ['-y', '@asynkor/mcp', 'start'],
241
+ env: { ASYNKOR_API_KEY: apiKey },
242
+ },
243
+ },
244
+ }, null, 2);
245
+ switch (ide) {
246
+ case 'vscode':
247
+ return {
248
+ file: path.join(process.cwd(), '.vscode', 'mcp.json'),
249
+ content: vscodeJson,
250
+ instructions: 'Reload VS Code (Developer: Reload Window). Asynkor tools appear in Copilot Chat agent mode.',
251
+ };
252
+ case 'cursor':
253
+ return {
254
+ file: path.join(process.cwd(), '.cursor', 'mcp.json'),
255
+ content: mcpServersJson,
256
+ rulesFile: path.join(process.cwd(), '.cursorrules'),
257
+ rulesContent: ASYNKOR_WORKFLOW,
258
+ instructions: 'Restart Cursor. Check Settings > MCP for a green dot.',
259
+ };
260
+ case 'windsurf': {
261
+ const home = os.homedir();
262
+ return {
263
+ file: path.join(home, '.codeium', 'windsurf', 'mcp_config.json'),
264
+ content: mcpServersJson,
265
+ rulesFile: path.join(process.cwd(), '.windsurfrules'),
266
+ rulesContent: ASYNKOR_WORKFLOW,
267
+ instructions: 'Refresh MCP servers in Cascade (hammer icon) or restart Windsurf.',
268
+ };
269
+ }
270
+ case 'zed': {
271
+ const home = os.homedir();
272
+ const zedConfig = JSON.stringify({
273
+ context_servers: {
274
+ asynkor: {
275
+ command: 'npx',
276
+ args: ['-y', '@asynkor/mcp', 'start'],
277
+ env: { ASYNKOR_API_KEY: apiKey },
278
+ },
279
+ },
280
+ }, null, 2);
281
+ return {
282
+ file: path.join(home, '.config', 'zed', 'settings.json'),
283
+ content: zedConfig,
284
+ instructions: 'Merge the context_servers block into your existing Zed settings.json. Tools appear in the Agent Panel.',
285
+ };
286
+ }
287
+ case 'jetbrains':
288
+ return {
289
+ file: path.join(process.cwd(), '.junie', 'mcp.json'),
290
+ content: mcpServersJson,
291
+ instructions: 'Restart your IDE. Check Settings > Tools > AI Assistant > MCP Servers.',
292
+ };
293
+ case 'codex': {
294
+ const home = os.homedir();
295
+ const toml = `[mcp_servers.asynkor]\ncommand = "npx"\nargs = ["-y", "@asynkor/mcp", "start"]\nenv = { "ASYNKOR_API_KEY" = "${apiKey}" }\n\n[mcp_servers.asynkor.tools.asynkor_briefing]\napproval_mode = "auto"\n\n[mcp_servers.asynkor.tools.asynkor_check]\napproval_mode = "auto"\n`;
296
+ return {
297
+ file: path.join(home, '.codex', 'config.toml'),
298
+ content: toml,
299
+ instructions: 'Restart Codex CLI. asynkor_briefing and asynkor_check are auto-approved.',
300
+ };
301
+ }
302
+ case 'trae':
303
+ return {
304
+ file: path.join(process.cwd(), '.trae', 'mcp.json'),
305
+ content: mcpServersJson,
306
+ instructions: 'Restart Trae. Asynkor tools appear in the AI assistant.',
307
+ };
308
+ case 'antigravity':
309
+ return {
310
+ file: path.join(process.cwd(), '.antigravity', 'mcp_config.json'),
311
+ content: mcpServersJson,
312
+ instructions: 'Asynkor tools are now available in Antigravity, including Manager View.',
313
+ };
314
+ default:
315
+ return {
316
+ file: path.join(process.cwd(), '.asynkor.json'),
317
+ content: JSON.stringify({ api_key: apiKey, server_url: 'https://mcp.asynkor.com' }, null, 2),
318
+ instructions: 'Run: claude mcp add asynkor -- npx @asynkor/mcp start',
319
+ };
320
+ }
321
+ }
322
+ function writeIdeConfig(ide, apiKey) {
323
+ const config = generateIdeConfig(ide, apiKey);
324
+ const dir = path.dirname(config.file);
325
+ if (!fs.existsSync(dir))
326
+ fs.mkdirSync(dir, { recursive: true });
327
+ if (ide === 'zed' || ide === 'codex') {
328
+ if (fs.existsSync(config.file)) {
329
+ console.log(`\nIMPORTANT: ${config.file} already exists.`);
330
+ console.log('Merge this config manually:');
331
+ console.log('');
332
+ console.log(config.content);
333
+ console.log('');
334
+ console.log(config.instructions);
335
+ return;
336
+ }
337
+ }
338
+ if (ide === 'windsurf' && fs.existsSync(config.file)) {
339
+ try {
340
+ const existing = JSON.parse(fs.readFileSync(config.file, 'utf8'));
341
+ const incoming = JSON.parse(config.content);
342
+ existing.mcpServers = { ...existing.mcpServers, ...incoming.mcpServers };
343
+ fs.writeFileSync(config.file, JSON.stringify(existing, null, 2) + '\n');
344
+ }
345
+ catch {
346
+ fs.writeFileSync(config.file, config.content + '\n');
347
+ }
348
+ }
349
+ else {
350
+ fs.writeFileSync(config.file, config.content + '\n');
351
+ }
352
+ console.log(`\u2713 ${config.file}`);
353
+ if (config.rulesFile && config.rulesContent) {
354
+ if (fs.existsSync(config.rulesFile)) {
355
+ const existing = fs.readFileSync(config.rulesFile, 'utf8');
356
+ if (!existing.includes('asynkor_briefing')) {
357
+ fs.appendFileSync(config.rulesFile, '\n' + config.rulesContent + '\n');
358
+ console.log(`\u2713 ${config.rulesFile} (appended)`);
359
+ }
360
+ else {
361
+ console.log(`\u2713 ${config.rulesFile} (already has Asynkor instructions)`);
362
+ }
363
+ }
364
+ else {
365
+ fs.writeFileSync(config.rulesFile, config.rulesContent + '\n');
366
+ console.log(`\u2713 ${config.rulesFile}`);
367
+ }
368
+ }
369
+ console.log('');
370
+ console.log(config.instructions);
371
+ }
372
+ async function cmdInit(args) {
373
+ const flags = parseFlags(args);
374
+ const linkUrl = flags['link'];
375
+ if (linkUrl) {
376
+ await setupFromJoinLink(linkUrl);
377
+ return;
378
+ }
379
+ const ideFlag = flags['ide'];
380
+ if (ideFlag && ideFlag !== 'claude-code') {
381
+ const validIdes = ['vscode', 'cursor', 'windsurf', 'zed', 'jetbrains', 'codex', 'trae', 'antigravity'];
382
+ if (!validIdes.includes(ideFlag)) {
383
+ console.error(`Unknown IDE: ${ideFlag}`);
384
+ console.error(`Supported: ${validIdes.join(', ')}`);
385
+ process.exit(1);
386
+ }
387
+ const apiKey = process.env.ASYNKOR_API_KEY?.trim() || flags['api-key']?.trim();
388
+ if (!apiKey) {
389
+ console.error('API key required. Set ASYNKOR_API_KEY or pass --api-key cf_live_...');
390
+ process.exit(1);
391
+ }
392
+ console.log(`Asynkor setup for ${ideFlag}`);
393
+ console.log('─'.repeat(40));
394
+ writeIdeConfig(ideFlag, apiKey);
395
+ initConfig({ apiKey, serverUrl: process.env.ASYNKOR_SERVER_URL?.trim() || 'https://mcp.asynkor.com' });
396
+ console.log('\u2713 .asynkor.json created');
397
+ return;
398
+ }
399
+ // Non-interactive path: if ASYNKOR_API_KEY is set in the environment, skip
400
+ // the prompts entirely. The docs at /docs tell users to do exactly this.
401
+ const envApiKey = process.env.ASYNKOR_API_KEY?.trim();
402
+ if (envApiKey) {
403
+ const serverUrl = process.env.ASYNKOR_SERVER_URL?.trim() || 'https://mcp.asynkor.com';
404
+ const team = process.env.ASYNKOR_TEAM?.trim() || undefined;
405
+ initConfig({ apiKey: envApiKey, serverUrl, team });
406
+ updateClaudeSettings();
407
+ writeClaudeMd(ASYNKOR_CLAUDE_MD);
408
+ console.log('Asynkor setup (from environment)');
409
+ console.log('─────────────────────────────────────');
410
+ console.log('✓ .asynkor.json created');
411
+ console.log('✓ .claude/settings.json updated (all asynkor tools auto-approved)');
412
+ console.log('✓ CLAUDE.md updated with Asynkor instructions');
413
+ console.log('\nAdd to Claude Code:');
414
+ console.log(' claude mcp add asynkor -- npx @asynkor/mcp start');
415
+ return;
416
+ }
417
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
418
+ const ask = (q) => new Promise((resolve) => rl.question(q, resolve));
419
+ console.log('Asynkor setup');
420
+ console.log('─────────────────────────────────────');
421
+ const apiKey = (await ask('API key (cf_live_...): ')).trim();
422
+ if (!apiKey) {
423
+ console.error('API key is required.');
424
+ rl.close();
425
+ process.exit(1);
426
+ }
427
+ const serverUrlInput = (await ask('Server URL [https://mcp.asynkor.com]: ')).trim();
428
+ const serverUrl = serverUrlInput || 'https://mcp.asynkor.com';
429
+ const team = (await ask('Team slug (optional): ')).trim();
430
+ rl.close();
431
+ initConfig({ apiKey, serverUrl, team: team || undefined });
432
+ updateClaudeSettings();
433
+ writeClaudeMd(ASYNKOR_CLAUDE_MD);
434
+ console.log('\n✓ .asynkor.json created');
435
+ console.log('✓ .claude/settings.json updated (all asynkor tools auto-approved)');
436
+ console.log('✓ CLAUDE.md updated with Asynkor instructions');
437
+ console.log('\nAdd to Claude Code:');
438
+ console.log(' claude mcp add asynkor -- npx @asynkor/mcp start');
439
+ }
440
+ async function setupFromJoinLink(url) {
441
+ let data;
442
+ try {
443
+ data = await fetchJoinLink(url);
444
+ }
445
+ catch (err) {
446
+ const msg = err instanceof Error ? err.message : String(err);
447
+ console.error(`Error: ${msg}`);
448
+ process.exit(1);
449
+ }
450
+ writeAsynkorJson(data.setup.asynkor_json);
451
+ writeClaudeMd(data.setup.claude_md || ASYNKOR_CLAUDE_MD);
452
+ updateClaudeSettings();
453
+ const teamName = data.team.name;
454
+ const teamSlug = data.team.slug;
455
+ const mcpInstall = data.setup.mcp_install || 'claude mcp add asynkor -- npx @asynkor/mcp start';
456
+ console.log(`\nConnected to team "${teamName}" (${teamSlug})`);
457
+ console.log('');
458
+ console.log('Config written to .asynkor.json');
459
+ console.log('Instructions written to CLAUDE.md');
460
+ console.log('Tools auto-approved in .claude/settings.json');
461
+ console.log('');
462
+ console.log('To complete setup, run:');
463
+ console.log(` ${mcpInstall}`);
464
+ console.log('');
465
+ console.log('Then restart your Claude Code session.');
466
+ }
467
+ async function cmdSetup(args) {
468
+ const url = args.find((a) => !a.startsWith('--'));
469
+ if (!url) {
470
+ console.error('Usage: asynkor setup <join-link-url>');
471
+ console.error('Example: asynkor setup https://asynkor.com/join/abc123');
472
+ process.exit(1);
473
+ }
474
+ await setupFromJoinLink(url);
475
+ }
476
+ async function cmdLogin(args) {
477
+ const flags = parseFlags(args);
478
+ const serverUrl = flags['server-url'] || process.env.ASYNKOR_SERVER_URL?.trim() || 'https://asynkor.com';
479
+ const http = await import('node:http');
480
+ const { execSync } = await import('node:child_process');
481
+ const port = await new Promise((resolve) => {
482
+ const srv = http.createServer();
483
+ srv.listen(0, '127.0.0.1', () => {
484
+ const addr = srv.address();
485
+ srv.close(() => resolve(addr.port));
486
+ });
487
+ });
488
+ let callbackResolve;
489
+ const callbackPromise = new Promise((resolve) => {
490
+ callbackResolve = resolve;
491
+ });
492
+ const server = http.createServer((req, res) => {
493
+ const url = new URL(req.url ?? '/', `http://127.0.0.1:${port}`);
494
+ if (url.pathname === '/callback') {
495
+ res.writeHead(200, { 'Content-Type': 'text/html', 'Access-Control-Allow-Origin': '*' });
496
+ res.end('<html><body><p>Done. You can close this tab.</p></body></html>');
497
+ callbackResolve(url.searchParams);
498
+ }
499
+ else {
500
+ res.writeHead(404);
501
+ res.end();
502
+ }
503
+ });
504
+ server.listen(port, '127.0.0.1');
505
+ const authUrl = `${serverUrl}/v1/auth/cli?port=${port}`;
506
+ console.log('Opening browser...');
507
+ console.log(`If it doesn't open, go to: ${authUrl}`);
508
+ console.log('');
509
+ console.log('Waiting for authorization...');
510
+ try {
511
+ const platform = process.platform;
512
+ if (platform === 'darwin')
513
+ execSync(`open "${authUrl}"`);
514
+ else if (platform === 'win32')
515
+ execSync(`start "" "${authUrl}"`);
516
+ else
517
+ execSync(`xdg-open "${authUrl}"`);
518
+ }
519
+ catch {
520
+ // browser open failed, user can use the printed URL
521
+ }
522
+ const timeout = setTimeout(() => {
523
+ console.error('Timed out waiting for authorization (5 minutes).');
524
+ server.close();
525
+ process.exit(1);
526
+ }, 300_000);
527
+ const params = await callbackPromise;
528
+ clearTimeout(timeout);
529
+ server.close();
530
+ const apiKey = params.get('api_key');
531
+ const team = params.get('team');
532
+ if (!apiKey) {
533
+ console.error('Authorization failed — no API key received.');
534
+ process.exit(1);
535
+ }
536
+ const configDir = path.join(os.homedir(), '.asynkor');
537
+ if (!fs.existsSync(configDir))
538
+ fs.mkdirSync(configDir, { recursive: true });
539
+ const configPath = path.join(configDir, 'config.json');
540
+ let existing = {};
541
+ if (fs.existsSync(configPath)) {
542
+ try {
543
+ existing = JSON.parse(fs.readFileSync(configPath, 'utf8'));
544
+ }
545
+ catch { }
546
+ }
547
+ existing.api_key = apiKey;
548
+ existing.server_url = 'https://mcp.asynkor.com';
549
+ if (team)
550
+ existing.team = team;
551
+ fs.writeFileSync(configPath, JSON.stringify(existing, null, 2) + '\n');
552
+ console.log('');
553
+ console.log(`Logged in${team ? ` (team: ${team})` : ''}`);
554
+ console.log(`API key saved to ${configPath}`);
555
+ console.log('');
556
+ console.log('Next steps:');
557
+ console.log(' claude mcp add asynkor -- npx @asynkor/mcp start');
558
+ }
559
+ async function cmdStatus() {
560
+ let cfg;
561
+ try {
562
+ cfg = loadConfig();
563
+ }
564
+ catch (err) {
565
+ if (err instanceof ConfigError) {
566
+ console.error(err.message);
567
+ process.exit(1);
568
+ }
569
+ throw err;
570
+ }
571
+ const { Client } = await import('@modelcontextprotocol/sdk/client/index.js');
572
+ const { SSEClientTransport } = await import('@modelcontextprotocol/sdk/client/sse.js');
573
+ const transport = new SSEClientTransport(new URL('/sse', cfg.serverUrl), {
574
+ requestInit: { headers: { Authorization: `Bearer ${cfg.apiKey}` } },
575
+ });
576
+ const client = new Client({ name: '@asynkor/mcp', version: '0.1.0' });
577
+ try {
578
+ await client.connect(transport);
579
+ }
580
+ catch (err) {
581
+ console.error(`Cannot connect to ${cfg.serverUrl}: ${err}`);
582
+ process.exit(1);
583
+ }
584
+ try {
585
+ const result = await client.callTool({ name: 'asynkor_briefing', arguments: {} });
586
+ const content = result.content;
587
+ const text = content.find((c) => c.type === 'text')?.text ?? '';
588
+ console.log(text || '(empty briefing)');
589
+ }
590
+ catch (err) {
591
+ console.error(`Failed to fetch briefing: ${err}`);
592
+ process.exitCode = 1;
593
+ }
594
+ finally {
595
+ await client.close();
596
+ }
597
+ }
598
+ function printHelp() {
599
+ console.log(`
600
+ @asynkor/mcp — Asynkor MCP client
601
+
602
+ Usage:
603
+ asynkor login Sign in via browser and get your API key automatically
604
+ asynkor start [flags] Start the MCP proxy server
605
+ asynkor init Set up .asynkor.json (interactive, or non-interactive if ASYNKOR_API_KEY is set)
606
+ asynkor init --ide <name> Set up for a specific IDE
607
+ asynkor init --link <url> Set up from a one-time join link
608
+ asynkor setup <url> Set up from a one-time join link (alias)
609
+ asynkor status Show current team briefing
610
+ asynkor help Show this help
611
+
612
+ Supported IDEs (--ide flag):
613
+ vscode VS Code / GitHub Copilot (.vscode/mcp.json)
614
+ cursor Cursor (.cursor/mcp.json + .cursorrules)
615
+ windsurf Windsurf (~/.codeium/windsurf/mcp_config.json + .windsurfrules)
616
+ zed Zed (~/.config/zed/settings.json)
617
+ jetbrains IntelliJ / WebStorm / PyCharm (.junie/mcp.json)
618
+ codex OpenAI Codex CLI (~/.codex/config.toml)
619
+ trae Trae (.trae/mcp.json)
620
+ antigravity Google Antigravity (.antigravity/mcp_config.json)
621
+
622
+ Flags for start:
623
+ --server-url <url> MCP server URL (default: https://mcp.asynkor.com)
624
+ --api-key <key> API key
625
+
626
+ Claude Code setup:
627
+ claude mcp add asynkor -- npx @asynkor/mcp start
628
+
629
+ Environment variables:
630
+ ASYNKOR_API_KEY API key (used by start, and by init for non-interactive setup)
631
+ ASYNKOR_SERVER_URL Override server URL (default: https://mcp.asynkor.com)
632
+ ASYNKOR_TEAM Optional team slug used by init when ASYNKOR_API_KEY is set
633
+ `);
634
+ }
635
+ switch (command) {
636
+ case 'start':
637
+ cmdStart(rest).catch((err) => {
638
+ process.stderr.write(`[asynkor] Fatal: ${err}\n`);
639
+ process.exit(1);
640
+ });
641
+ break;
642
+ case 'init':
643
+ cmdInit(rest).catch((err) => {
644
+ console.error(err);
645
+ process.exit(1);
646
+ });
647
+ break;
648
+ case 'login':
649
+ cmdLogin(rest).catch((err) => {
650
+ console.error(err);
651
+ process.exit(1);
652
+ });
653
+ break;
654
+ case 'setup':
655
+ cmdSetup(rest).catch((err) => {
656
+ console.error(err);
657
+ process.exit(1);
658
+ });
659
+ break;
660
+ case 'status':
661
+ cmdStatus().catch((err) => {
662
+ console.error(err);
663
+ process.exit(1);
664
+ });
665
+ break;
666
+ case 'help':
667
+ case '--help':
668
+ case '-h':
669
+ printHelp();
670
+ break;
671
+ default:
672
+ if (command) {
673
+ console.error(`Unknown command: ${command}`);
674
+ }
675
+ printHelp();
676
+ process.exit(command ? 1 : 0);
677
+ }
678
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,CAAC,EAAE,AAAD,EAAG,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;AAE5C,SAAS,UAAU,CAAC,IAAc;IAChC,MAAM,KAAK,GAA2B,EAAE,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAA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ACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QACH,MAAM;IACR,KAAK,QAAQ;QACX,SAAS,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACxB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QACH,MAAM;IACR,KAAK,MAAM,CAAC;IACZ,KAAK,QAAQ,CAAC;IACd,KAAK,IAAI;QACP,SAAS,EAAE,CAAC;QACZ,MAAM;IACR;QACE,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;QAC/C,CAAC;QACD,SAAS,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1,25 @@
1
+ export interface AsynkorConfig {
2
+ apiKey: string;
3
+ serverUrl: string;
4
+ team?: string;
5
+ }
6
+ export declare class ConfigError extends Error {
7
+ constructor(message: string);
8
+ }
9
+ /**
10
+ * resolveConfig reads all config sources (env → .asynkor.json → ~/.asynkor/config.json)
11
+ * and returns { config, configPath }. Returns a null apiKey if no key is found anywhere
12
+ * (instead of throwing). configPath is the resolved .asynkor.json path for hot-reload
13
+ * watching, or null if no file was found.
14
+ */
15
+ export declare function resolveConfig(): {
16
+ config: AsynkorConfig | null;
17
+ configPath: string | null;
18
+ };
19
+ export declare function loadConfig(): AsynkorConfig;
20
+ export declare function initConfig(options: {
21
+ apiKey: string;
22
+ serverUrl?: string;
23
+ team?: string;
24
+ }): void;
25
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAoBD;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI;IAAE,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAuC3F;AAED,wBAAgB,UAAU,IAAI,aAAa,CAU1C;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAS/F"}
package/dist/config.js ADDED
@@ -0,0 +1,83 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import os from 'node:os';
4
+ export class ConfigError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'ConfigError';
8
+ }
9
+ }
10
+ function findAsynkorJson(startDir) {
11
+ let dir = startDir;
12
+ for (let i = 0; i < 10; i++) {
13
+ const candidate = path.join(dir, '.asynkor.json');
14
+ if (fs.existsSync(candidate))
15
+ return candidate;
16
+ const parent = path.dirname(dir);
17
+ if (parent === dir)
18
+ break;
19
+ dir = parent;
20
+ }
21
+ return null;
22
+ }
23
+ /**
24
+ * resolveConfig reads all config sources (env → .asynkor.json → ~/.asynkor/config.json)
25
+ * and returns { config, configPath }. Returns a null apiKey if no key is found anywhere
26
+ * (instead of throwing). configPath is the resolved .asynkor.json path for hot-reload
27
+ * watching, or null if no file was found.
28
+ */
29
+ export function resolveConfig() {
30
+ const jsonPath = findAsynkorJson(process.cwd());
31
+ let fileConfig = {};
32
+ if (jsonPath) {
33
+ try {
34
+ fileConfig = JSON.parse(fs.readFileSync(jsonPath, 'utf-8'));
35
+ }
36
+ catch {
37
+ // ignore parse errors, fall through to env
38
+ }
39
+ }
40
+ const userConfigPath = path.join(os.homedir(), '.asynkor', 'config.json');
41
+ let userConfig = {};
42
+ if (fs.existsSync(userConfigPath)) {
43
+ try {
44
+ userConfig = JSON.parse(fs.readFileSync(userConfigPath, 'utf-8'));
45
+ }
46
+ catch { }
47
+ }
48
+ const apiKey = process.env.ASYNKOR_API_KEY ||
49
+ fileConfig.api_key ||
50
+ userConfig.api_key ||
51
+ '';
52
+ const serverUrl = process.env.ASYNKOR_SERVER_URL ||
53
+ fileConfig.server_url ||
54
+ userConfig.server_url ||
55
+ 'https://mcp.asynkor.com';
56
+ if (!apiKey) {
57
+ return { config: null, configPath: jsonPath };
58
+ }
59
+ return {
60
+ config: { apiKey, serverUrl, team: fileConfig.team || userConfig.team },
61
+ configPath: jsonPath,
62
+ };
63
+ }
64
+ export function loadConfig() {
65
+ const { config } = resolveConfig();
66
+ if (!config) {
67
+ throw new ConfigError('Asynkor API key not found.\n' +
68
+ 'Set ASYNKOR_API_KEY env var, or create .asynkor.json with {"api_key": "cf_live_..."}.\n' +
69
+ 'Get your key at: https://asynkor.com/dashboard');
70
+ }
71
+ return config;
72
+ }
73
+ export function initConfig(options) {
74
+ const config = {
75
+ api_key: options.apiKey,
76
+ server_url: options.serverUrl || 'https://mcp.asynkor.com',
77
+ };
78
+ if (options.team)
79
+ config.team = options.team;
80
+ const target = path.join(process.cwd(), '.asynkor.json');
81
+ fs.writeFileSync(target, JSON.stringify(config, null, 2) + '\n');
82
+ }
83
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAQzB,MAAM,OAAO,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAe;QACzB,KAAK,C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Aa,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AACnE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { loadConfig, initConfig, ConfigError } from './config.js';
2
+ export type { AsynkorConfig } from './config.js';
3
+ export { AsynkorMcpProxy } from './proxy.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { loadConfig, initConfig, ConfigError } from './config.js';
2
+ export { AsynkorMcpProxy } from './proxy.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
2
+ import type { AsynkorConfig } from './config.js';
3
+ export declare class AsynkorMcpProxy {
4
+ private cfg;
5
+ private readonly agentName;
6
+ private readonly agentVersion;
7
+ private goClient;
8
+ private reconnectAttempts;
9
+ private stopping;
10
+ private cachedTools;
11
+ private cachedResources;
12
+ private subscriptions;
13
+ private currentApiKey;
14
+ private currentServerUrl;
15
+ private lastConfigCheck;
16
+ constructor(cfg: AsynkorConfig | null, agentName?: string, agentVersion?: string);
17
+ private buildTransport;
18
+ private connectToGoServer;
19
+ private scheduleReconnect;
20
+ /**
21
+ * checkConfigReload re-reads the config from disk (at most once per
22
+ * CONFIG_CHECK_INTERVAL_MS) and reconnects the SSE client if the API
23
+ * key or server URL changed. This is the hot-reload mechanism that
24
+ * lets a developer write .asynkor.json mid-session without restarting
25
+ * Claude Code.
26
+ *
27
+ * Called at the top of every tool call and list handler. The stat()
28
+ * call is ~50μs on SSD, negligible compared to the network round-trip.
29
+ */
30
+ private checkConfigReload;
31
+ private startSubscriptionPoll;
32
+ private stopSubscriptionPoll;
33
+ createStdioServer(): Promise<Server>;
34
+ close(): Promise<void>;
35
+ }
36
+ //# sourceMappingURL=proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAenE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAWjD,qBAAa,eAAe;IAexB,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAhB/B,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,aAAa,CAAqD;IAI1E,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,eAAe,CAAK;gBAGlB,GAAG,EAAE,aAAa,GAAG,IAAI,EAChB,SAAS,GAAE,MAAsB,EACjC,YAAY,GAAE,MAAqD;IAMtF,OAAO,CAAC,cAAc;YAcR,iBAAiB;IAkB/B,OAAO,CAAC,iBAAiB;IA+BzB;;;;;;;;;OASG;YACW,iBAAiB;IAiD/B,OAAO,CAAC,qBAAqB;IAyB7B,OAAO,CAAC,oBAAoB;IAQtB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC;IAmIpC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAS7B"}
package/dist/proxy.js ADDED
@@ -0,0 +1,300 @@
1
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2
+ import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
3
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
+ import { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, SubscribeRequestSchema, UnsubscribeRequestSchema, ResourceUpdatedNotificationSchema, } from '@modelcontextprotocol/sdk/types.js';
5
+ import os from 'node:os';
6
+ import { resolveConfig } from './config.js';
7
+ const RECONNECT_BASE_MS = 3000;
8
+ const MAX_RECONNECT_ATTEMPTS = 10;
9
+ const SUBSCRIBE_POLL_MS = 3000;
10
+ // How often to stat the config file for changes. Cheap (~50μs on SSD)
11
+ // and negligible compared to the network round-trip of a tool call.
12
+ const CONFIG_CHECK_INTERVAL_MS = 3000;
13
+ export class AsynkorMcpProxy {
14
+ cfg;
15
+ agentName;
16
+ agentVersion;
17
+ goClient = null;
18
+ reconnectAttempts = 0;
19
+ stopping = false;
20
+ cachedTools = [];
21
+ cachedResources = [];
22
+ subscriptions = new Map();
23
+ // Hot-reload state: tracks what we're currently connected with so we
24
+ // can detect changes and reconnect without restarting the process.
25
+ currentApiKey;
26
+ currentServerUrl;
27
+ lastConfigCheck = 0;
28
+ constructor(cfg, agentName = 'claude-code', agentVersion = process.env.CLAUDE_CODE_VERSION ?? 'unknown') {
29
+ this.cfg = cfg;
30
+ this.agentName = agentName;
31
+ this.agentVersion = agentVersion;
32
+ this.currentApiKey = cfg?.apiKey ?? '';
33
+ this.currentServerUrl = cfg?.serverUrl ?? 'https://mcp.asynkor.com';
34
+ }
35
+ buildTransport() {
36
+ const sseUrl = new URL('/sse', this.currentServerUrl);
37
+ return new SSEClientTransport(sseUrl, {
38
+ requestInit: {
39
+ headers: {
40
+ Authorization: `Bearer ${this.currentApiKey}`,
41
+ 'X-Agent': this.agentName,
42
+ 'X-Agent-Version': this.agentVersion,
43
+ 'X-Hostname': os.hostname(),
44
+ },
45
+ },
46
+ });
47
+ }
48
+ async connectToGoServer() {
49
+ const transport = this.buildTransport();
50
+ const client = new Client({ name: '@asynkor/mcp', version: '0.1.0' });
51
+ client.onclose = () => {
52
+ if (!this.stopping) {
53
+ this.goClient = null;
54
+ this.scheduleReconnect();
55
+ }
56
+ };
57
+ await client.connect(transport);
58
+ this.reconnectAttempts = 0;
59
+ return client;
60
+ }
61
+ scheduleReconnect() {
62
+ if (this.reconnectAttempts >= MAX_RECONNECT_ATTEMPTS) {
63
+ process.stderr.write(`[asynkor] Gave up reconnecting after ${MAX_RECONNECT_ATTEMPTS} attempts.\n`);
64
+ return;
65
+ }
66
+ this.reconnectAttempts++;
67
+ const delay = RECONNECT_BASE_MS * Math.min(this.reconnectAttempts, 5);
68
+ process.stderr.write(`[asynkor] Connection lost. Reconnecting in ${delay / 1000}s (attempt ${this.reconnectAttempts})...\n`);
69
+ setTimeout(async () => {
70
+ try {
71
+ // Re-check config before reconnecting — the key may have changed
72
+ // while we were disconnected.
73
+ await this.checkConfigReload();
74
+ if (!this.currentApiKey) {
75
+ process.stderr.write('[asynkor] Still no API key. Waiting for .asynkor.json...\n');
76
+ this.scheduleReconnect();
77
+ return;
78
+ }
79
+ this.goClient = await this.connectToGoServer();
80
+ process.stderr.write('[asynkor] Reconnected.\n');
81
+ }
82
+ catch (err) {
83
+ process.stderr.write(`[asynkor] Reconnect failed: ${err}\n`);
84
+ this.scheduleReconnect();
85
+ }
86
+ }, delay);
87
+ }
88
+ /**
89
+ * checkConfigReload re-reads the config from disk (at most once per
90
+ * CONFIG_CHECK_INTERVAL_MS) and reconnects the SSE client if the API
91
+ * key or server URL changed. This is the hot-reload mechanism that
92
+ * lets a developer write .asynkor.json mid-session without restarting
93
+ * Claude Code.
94
+ *
95
+ * Called at the top of every tool call and list handler. The stat()
96
+ * call is ~50μs on SSD, negligible compared to the network round-trip.
97
+ */
98
+ async checkConfigReload() {
99
+ const now = Date.now();
100
+ if (now - this.lastConfigCheck < CONFIG_CHECK_INTERVAL_MS)
101
+ return;
102
+ this.lastConfigCheck = now;
103
+ const { config } = resolveConfig();
104
+ const newKey = config?.apiKey ?? '';
105
+ const newUrl = config?.serverUrl ?? 'https://mcp.asynkor.com';
106
+ if (newKey === this.currentApiKey && newUrl === this.currentServerUrl) {
107
+ return; // no change
108
+ }
109
+ const hadKey = !!this.currentApiKey;
110
+ this.currentApiKey = newKey;
111
+ this.currentServerUrl = newUrl;
112
+ this.cfg = config;
113
+ if (!newKey) {
114
+ process.stderr.write('[asynkor] Config changed but API key is empty. Waiting...\n');
115
+ return;
116
+ }
117
+ // Key appeared or changed — (re)connect.
118
+ if (hadKey) {
119
+ process.stderr.write('[asynkor] API key changed. Reconnecting...\n');
120
+ }
121
+ else {
122
+ process.stderr.write('[asynkor] API key detected. Connecting...\n');
123
+ }
124
+ try {
125
+ if (this.goClient) {
126
+ await this.goClient.close();
127
+ this.goClient = null;
128
+ }
129
+ this.goClient = await this.connectToGoServer();
130
+ this.cachedTools = (await this.goClient.listTools()).tools;
131
+ try {
132
+ this.cachedResources = (await this.goClient.listResources()).resources ?? [];
133
+ }
134
+ catch {
135
+ this.cachedResources = [];
136
+ }
137
+ process.stderr.write(`[asynkor] Connected with new key. ${this.cachedTools.length} tools available.\n`);
138
+ }
139
+ catch (err) {
140
+ process.stderr.write(`[asynkor] Failed to connect with new key: ${err}\n`);
141
+ this.scheduleReconnect();
142
+ }
143
+ }
144
+ startSubscriptionPoll(uri, server) {
145
+ if (this.subscriptions.has(uri))
146
+ return;
147
+ let lastHash = '';
148
+ const poll = async () => {
149
+ if (!this.goClient)
150
+ return;
151
+ try {
152
+ const result = await this.goClient.readResource({ uri });
153
+ const hash = JSON.stringify(result);
154
+ if (hash !== lastHash) {
155
+ lastHash = hash;
156
+ if (lastHash !== '') {
157
+ await server.sendResourceUpdated({ uri });
158
+ }
159
+ }
160
+ }
161
+ catch {
162
+ // ignore transient errors
163
+ }
164
+ };
165
+ const timer = setInterval(poll, SUBSCRIBE_POLL_MS);
166
+ this.subscriptions.set(uri, timer);
167
+ }
168
+ stopSubscriptionPoll(uri) {
169
+ const timer = this.subscriptions.get(uri);
170
+ if (timer) {
171
+ clearInterval(timer);
172
+ this.subscriptions.delete(uri);
173
+ }
174
+ }
175
+ async createStdioServer() {
176
+ // If we have a config, connect now. If not (no key yet), the server
177
+ // starts in disconnected mode and connects when checkConfigReload()
178
+ // detects the key appearing in .asynkor.json.
179
+ if (this.currentApiKey) {
180
+ this.goClient = await this.connectToGoServer();
181
+ this.cachedTools = (await this.goClient.listTools()).tools;
182
+ try {
183
+ this.cachedResources = (await this.goClient.listResources()).resources ?? [];
184
+ }
185
+ catch {
186
+ this.cachedResources = [];
187
+ }
188
+ }
189
+ else {
190
+ process.stderr.write('[asynkor] No API key found. Waiting for .asynkor.json to appear...\n' +
191
+ '[asynkor] Run: ASYNKOR_API_KEY=cf_live_... npx @asynkor/mcp init\n');
192
+ }
193
+ const server = new Server({ name: 'asynkor', version: '0.1.0' }, { capabilities: { tools: {}, resources: { subscribe: true } } });
194
+ // Forward notifications/resources/updated from Go server → Claude Code.
195
+ // Re-registered after each reconnect in checkConfigReload().
196
+ const setupNotificationForwarding = () => {
197
+ if (!this.goClient)
198
+ return;
199
+ this.goClient.setNotificationHandler(ResourceUpdatedNotificationSchema, async (notification) => {
200
+ try {
201
+ await server.sendResourceUpdated(notification.params);
202
+ }
203
+ catch {
204
+ // ignore if client is gone
205
+ }
206
+ });
207
+ };
208
+ setupNotificationForwarding();
209
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
210
+ await this.checkConfigReload();
211
+ if (this.goClient) {
212
+ try {
213
+ const result = await this.goClient.listTools();
214
+ this.cachedTools = result.tools;
215
+ return result;
216
+ }
217
+ catch {
218
+ // fall through to cached
219
+ }
220
+ }
221
+ return { tools: this.cachedTools };
222
+ });
223
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
224
+ const { name, arguments: args } = request.params;
225
+ // Hot-reload: pick up new config before the tool call. If the key
226
+ // just appeared (e.g. user ran init mid-session), this is where
227
+ // we connect for the first time.
228
+ await this.checkConfigReload();
229
+ if (!this.goClient) {
230
+ return {
231
+ content: [{
232
+ type: 'text',
233
+ text: JSON.stringify({
234
+ error: 'not_connected',
235
+ message: 'Asynkor is not connected yet. Make sure .asynkor.json exists with a valid api_key, or set ASYNKOR_API_KEY. The client will auto-connect within a few seconds.',
236
+ }),
237
+ }],
238
+ isError: true,
239
+ };
240
+ }
241
+ const result = await this.goClient.callTool({ name, arguments: args ?? {} });
242
+ return result;
243
+ });
244
+ server.setRequestHandler(ListResourcesRequestSchema, async () => {
245
+ await this.checkConfigReload();
246
+ if (this.goClient) {
247
+ try {
248
+ const result = await this.goClient.listResources();
249
+ this.cachedResources = result.resources ?? [];
250
+ return result;
251
+ }
252
+ catch {
253
+ // fall through to cached
254
+ }
255
+ }
256
+ return { resources: this.cachedResources };
257
+ });
258
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
259
+ const { uri } = request.params;
260
+ await this.checkConfigReload();
261
+ if (!this.goClient) {
262
+ return {
263
+ contents: [{ uri, mimeType: 'application/json', text: JSON.stringify({ error: 'disconnected' }) }],
264
+ };
265
+ }
266
+ const result = await this.goClient.readResource({ uri });
267
+ return result;
268
+ });
269
+ server.setRequestHandler(SubscribeRequestSchema, async (request) => {
270
+ const { uri } = request.params;
271
+ this.startSubscriptionPoll(uri, server);
272
+ return {};
273
+ });
274
+ server.setRequestHandler(UnsubscribeRequestSchema, async (request) => {
275
+ const { uri } = request.params;
276
+ this.stopSubscriptionPoll(uri);
277
+ return {};
278
+ });
279
+ // Start a background config watcher so we pick up key changes even
280
+ // when no tool calls are coming in (e.g. idle session where the
281
+ // user is running init in another terminal).
282
+ const configWatcher = setInterval(() => this.checkConfigReload(), CONFIG_CHECK_INTERVAL_MS);
283
+ const origClose = this.close.bind(this);
284
+ this.close = async () => {
285
+ clearInterval(configWatcher);
286
+ await origClose();
287
+ };
288
+ return server;
289
+ }
290
+ async close() {
291
+ this.stopping = true;
292
+ for (const timer of this.subscriptions.values()) {
293
+ clearInterval(timer);
294
+ }
295
+ this.subscriptions.clear();
296
+ await this.goClient?.close();
297
+ this.goClient = null;
298
+ }
299
+ }
300
+ //# sourceMappingURL=proxy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../src/proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,wBAAwB,EACxB,iCAAiC,GAGlC,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAC/B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAE/B,sEAAsE;AACtE,oEAAoE;AACpE,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAEtC,MAAM,OAAO,eAAe;IAehB;IACS;IACA;IAhBX,QAAQ,GAAkB,IAAI,CAAC;IAC/B,iBAAiB,GAAG,CAAC,CAAC;IACtB,QAAQ,GAAG,KAAK,CAAC;IACjB,WAAW,GAAW,EAAE,CAAC;IACzB,eAAe,GAAe,EAAE,CAAC;IACjC,aAAa,GAAG,IAAI,GAAG,EAA0C,CAAC;IAE1E,qEAAqE;IACrE,mEAAmE;IA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;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC;YAChD,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QACD,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QAC3B,MAAM,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@asynkor/mcp",
3
+ "version": "0.1.0",
4
+ "description": "Asynkor MCP client — real-time agent coordination for AI coding teams",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "asynkor": "./dist/cli.js"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "import": "./dist/index.js",
15
+ "types": "./dist/index.d.ts"
16
+ }
17
+ },
18
+ "files": ["dist", "README.md"],
19
+ "scripts": {
20
+ "build": "tsc",
21
+ "dev": "tsc --watch",
22
+ "start": "node dist/cli.js start",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "dependencies": {
26
+ "@modelcontextprotocol/sdk": "^1.10.0",
27
+ "zod": "^3.24.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.0.0",
31
+ "typescript": "^5.7.0"
32
+ },
33
+ "engines": {
34
+ "node": ">=18.0.0"
35
+ },
36
+ "keywords": ["mcp", "asynkor", "ai", "agents", "claude", "coordination"]
37
+ }