@first-to-fly/orchestrator-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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAEA,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC;IAC/B,OAAO,CAAC,QAAQ,CAAC,CAAA;AACnB,CAAC;KAAM,CAAC;IACN,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAC3C,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,GAAQ,EAAE,EAAE;QAC/B,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAA;QACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;AACJ,CAAC"}
package/dist/init.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":""}
package/dist/init.js ADDED
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const readline = __importStar(require("readline"));
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const PRODUCTION_API_URL = 'https://orchestrator-api.firsttofly.com/api/v1';
40
+ const ORCHESTRATOR_PROTOCOL = `## Orchestrator Protocol
41
+
42
+ ### Session Start
43
+ - Context is auto-injected via hook (last session + recalled memory)
44
+ - Call \`recall_context\` with your task description for relevant knowledge
45
+
46
+ ### Progressive Retrieval
47
+ - \`recall_context\` and \`search_memory\` return summaries by default
48
+ - Use \`get_entity(type, id)\` only for entities you need full content from
49
+
50
+ ### Error Resolution
51
+ - Call \`check_error\` before debugging from scratch — it may have a known fix
52
+
53
+ ### Save Triggers
54
+ | Trigger | Entity Type |
55
+ |---------|------------|
56
+ | Architectural choice | \`decision\` |
57
+ | Reusable pattern found | \`pattern\` |
58
+ | Bug fixed | \`error\` |
59
+ | Task completed | \`task\` |
60
+ | Module created | \`module\` |
61
+ | Requirement clarified | \`requirement\` |
62
+ | Quick insight | \`observation\` |
63
+
64
+ ### Relationships
65
+ Link related entities: \`depends_on\`, \`supersedes\`, \`caused_by\`, \`implements\`, \`part_of\`, \`relates_to\`
66
+
67
+ ### Session Handoff
68
+ Before ending a session, call \`save_session_summary\` with:
69
+ - summary, tasksCompleted, tasksInProgress, blockers, filesModified, decisionsMade, nextSteps
70
+
71
+ ### Maintenance
72
+ - \`prune_stale\` — remove unaccessed entities (dry run by default)
73
+ - \`list_recent\` — browse stored knowledge
74
+ - \`search_memory\` — find specific entities
75
+ `;
76
+ function question(rl, prompt, defaultVal) {
77
+ const suffix = defaultVal ? ` (${defaultVal})` : '';
78
+ return new Promise((resolve) => {
79
+ rl.question(`${prompt}${suffix}: `, (answer) => {
80
+ resolve(answer.trim() || defaultVal || '');
81
+ });
82
+ });
83
+ }
84
+ async function validateApiKey(apiUrl, apiKey, project) {
85
+ try {
86
+ const controller = new AbortController();
87
+ const timer = setTimeout(() => controller.abort(), 5000);
88
+ const response = await fetch(`${apiUrl}/projects/${project}/sessions/last`, {
89
+ headers: {
90
+ 'Content-Type': 'application/json',
91
+ 'x-api-key': apiKey,
92
+ },
93
+ signal: controller.signal,
94
+ });
95
+ clearTimeout(timer);
96
+ // Any non-401 response means the key is valid
97
+ return response.status !== 401;
98
+ }
99
+ catch {
100
+ return false;
101
+ }
102
+ }
103
+ function readJsonFile(filePath) {
104
+ try {
105
+ return JSON.parse(fs.readFileSync(filePath, 'utf-8'));
106
+ }
107
+ catch {
108
+ return null;
109
+ }
110
+ }
111
+ function writeJsonFile(filePath, data) {
112
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
113
+ fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + '\n');
114
+ }
115
+ async function main() {
116
+ console.log('\n🔧 Orchestrator Init — Set up persistent memory for Claude Code\n');
117
+ const rl = readline.createInterface({
118
+ input: process.stdin,
119
+ output: process.stdout,
120
+ });
121
+ try {
122
+ // 1. Collect configuration
123
+ const apiUrl = await question(rl, 'API URL', PRODUCTION_API_URL);
124
+ const apiKey = await question(rl, 'API Key (ftfo_...)');
125
+ const project = await question(rl, 'Project slug');
126
+ if (!apiKey || !project) {
127
+ console.error('\nAPI key and project slug are required.');
128
+ process.exit(1);
129
+ }
130
+ // 2. Validate API key
131
+ console.log('\nValidating API key...');
132
+ const valid = await validateApiKey(apiUrl, apiKey, project);
133
+ if (!valid) {
134
+ console.error('API key validation failed. Check your key and project slug.');
135
+ process.exit(1);
136
+ }
137
+ console.log('API key is valid.\n');
138
+ // 3. Write/merge .mcp.json
139
+ const mcpPath = path.join(process.cwd(), '.mcp.json');
140
+ const mcpConfig = readJsonFile(mcpPath) || {};
141
+ if (!mcpConfig.mcpServers)
142
+ mcpConfig.mcpServers = {};
143
+ // Resolve the path to this package's dist/index.js
144
+ const serverPath = path.resolve(__dirname, 'index.js');
145
+ mcpConfig.mcpServers['orchestrator'] = {
146
+ command: 'node',
147
+ args: [serverPath],
148
+ env: {
149
+ ORCHESTRATOR_API_URL: apiUrl,
150
+ ORCHESTRATOR_API_KEY: apiKey,
151
+ ORCHESTRATOR_PROJECT: project,
152
+ },
153
+ };
154
+ writeJsonFile(mcpPath, mcpConfig);
155
+ console.log(`Written: ${mcpPath}`);
156
+ // 4. Append orchestrator protocol to CLAUDE.md
157
+ const claudeMdPath = path.join(process.cwd(), 'CLAUDE.md');
158
+ let claudeMd = '';
159
+ try {
160
+ claudeMd = fs.readFileSync(claudeMdPath, 'utf-8');
161
+ }
162
+ catch {
163
+ // File doesn't exist yet
164
+ }
165
+ if (!claudeMd.includes('## Orchestrator Protocol')) {
166
+ const separator = claudeMd.length > 0 ? '\n\n' : '';
167
+ fs.writeFileSync(claudeMdPath, claudeMd + separator + ORCHESTRATOR_PROTOCOL);
168
+ console.log(`Updated: ${claudeMdPath}`);
169
+ }
170
+ else {
171
+ console.log(`Skipped: ${claudeMdPath} (orchestrator protocol already present)`);
172
+ }
173
+ // 5. Create .claude/settings.local.json with hooks
174
+ const settingsPath = path.join(process.cwd(), '.claude', 'settings.local.json');
175
+ const settings = readJsonFile(settingsPath) || {};
176
+ if (!settings.hooks)
177
+ settings.hooks = {};
178
+ const hookScriptPath = path.resolve(__dirname, 'hooks', 'session-start.js');
179
+ settings.hooks['SessionStart'] = [{
180
+ type: 'command',
181
+ command: `node ${hookScriptPath}`,
182
+ }];
183
+ settings.hooks['Stop'] = [{
184
+ type: 'prompt',
185
+ prompt: 'You MUST call save_session_summary before this session ends if ANY of these occurred:\n1. Files were created, modified, or deleted\n2. Bugs were debugged or fixed\n3. Architectural decisions were made\n4. New features were implemented\n5. Errors were investigated\n\nCall: save_session_summary({ summary: "...", tasksCompleted: [...], tasksInProgress: [...], filesModified: [...], decisionsMade: [...], nextSteps: [...] })\n\nSkip only if this was a purely read-only exploration with no actionable outcomes.',
186
+ }];
187
+ writeJsonFile(settingsPath, settings);
188
+ console.log(`Written: ${settingsPath}`);
189
+ // 6. Success message
190
+ console.log('\n✅ Orchestrator initialized successfully!\n');
191
+ console.log('Next steps:');
192
+ console.log(' 1. Start a new Claude Code session');
193
+ console.log(' 2. The orchestrator MCP server will auto-connect');
194
+ console.log(' 3. Last session context will be auto-injected via hook');
195
+ console.log(' 4. Use recall_context, search_memory, store_entity, etc.');
196
+ console.log('');
197
+ }
198
+ finally {
199
+ rl.close();
200
+ }
201
+ }
202
+ main().catch((err) => {
203
+ console.error('Init failed:', err.message);
204
+ process.exit(1);
205
+ });
206
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mDAAoC;AACpC,uCAAwB;AACxB,2CAA4B;AAE5B,MAAM,kBAAkB,GAAG,gDAAgD,CAAA;AAE3E,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC7B,CAAA;AAED,SAAS,QAAQ,CAAC,EAAsB,EAAE,MAAc,EAAE,UAAmB;IAC3E,MAAM,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,UAAU,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;IACnD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,EAAE,CA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C;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Notify connected clients that the tool list has changed.
3
+ * Call this when tools are dynamically added or removed (e.g., recipe-based tool aliases).
4
+ */
5
+ export declare function sendToolsChanged(): void;
6
+ export declare function startServer(): Promise<void>;
7
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAuFA;;;GAGG;AACH,wBAAgB,gBAAgB,SAE/B;AAGD,wBAAsB,WAAW,kBAIhC"}
package/dist/server.js ADDED
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sendToolsChanged = sendToolsChanged;
4
+ exports.startServer = startServer;
5
+ const node_crypto_1 = require("node:crypto");
6
+ const index_js_1 = require("@modelcontextprotocol/sdk/server/index.js");
7
+ const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
8
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
9
+ const config_1 = require("./config");
10
+ const client_1 = require("./client");
11
+ const tools_1 = require("./tools");
12
+ const config = (0, config_1.getConfig)();
13
+ const sessionId = (0, node_crypto_1.randomUUID)();
14
+ const client = new client_1.OrchestratorClient(config, sessionId);
15
+ const server = new index_js_1.Server({
16
+ name: 'orchestrator',
17
+ version: '0.1.0',
18
+ }, {
19
+ capabilities: {
20
+ tools: { listChanged: true },
21
+ },
22
+ });
23
+ // Default outputSchema for tools that return text content
24
+ const DEFAULT_OUTPUT_SCHEMA = {
25
+ type: 'object',
26
+ properties: {
27
+ type: { const: 'text' },
28
+ text: { type: 'string' },
29
+ },
30
+ };
31
+ // List available tools
32
+ server.setRequestHandler(types_js_1.ListToolsRequestSchema, async () => {
33
+ return {
34
+ tools: tools_1.tools.map((tool) => ({
35
+ name: tool.name,
36
+ description: tool.description,
37
+ inputSchema: tool.inputSchema,
38
+ outputSchema: tool.outputSchema || DEFAULT_OUTPUT_SCHEMA,
39
+ })),
40
+ };
41
+ });
42
+ // Handle tool calls
43
+ server.setRequestHandler(types_js_1.CallToolRequestSchema, async (request) => {
44
+ const { name, arguments: args } = request.params;
45
+ const tool = tools_1.tools.find((t) => t.name === name);
46
+ if (!tool) {
47
+ return {
48
+ content: [{ type: 'text', text: `Unknown tool: ${name}` }],
49
+ isError: true,
50
+ };
51
+ }
52
+ const startTime = Date.now();
53
+ let isError = false;
54
+ try {
55
+ const result = await tool.handler(client, args || {});
56
+ isError = result.isError || false;
57
+ return result;
58
+ }
59
+ catch (err) {
60
+ isError = true;
61
+ // Read tools soft fail, write tools hard fail
62
+ const isReadTool = ['recall_context', 'search_memory', 'list_recent', 'get_entity', 'get_last_session', 'check_error', 'get_recipe', 'list_recipes'].includes(name);
63
+ if (isReadTool) {
64
+ return {
65
+ content: [{ type: 'text', text: `Warning: ${name} failed: ${err.message}` }],
66
+ };
67
+ }
68
+ return {
69
+ content: [{ type: 'text', text: `Error in ${name}: ${err.message}` }],
70
+ isError: true,
71
+ };
72
+ }
73
+ finally {
74
+ // Fire-and-forget tool call event logging
75
+ const durationMs = Date.now() - startTime;
76
+ client.logToolCall(name, durationMs, isError).catch(() => { });
77
+ }
78
+ });
79
+ /**
80
+ * Notify connected clients that the tool list has changed.
81
+ * Call this when tools are dynamically added or removed (e.g., recipe-based tool aliases).
82
+ */
83
+ function sendToolsChanged() {
84
+ server.notification({ method: 'notifications/tools/list_changed' });
85
+ }
86
+ // Start the server
87
+ async function startServer() {
88
+ const transport = new stdio_js_1.StdioServerTransport();
89
+ await server.connect(transport);
90
+ console.error(`Orchestrator MCP server started for project: ${config.project}`);
91
+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AI,EAAE,YAAY,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;YACrE,OAAO,EAAE,IAAI;SACd,CAAA;IACH,CAAC;YAAS,CAAC;QACT,0CAA0C;QAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAA;QACzC,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IAC/D,CAAC;AACH,CAAC,CAAC,CAAA;AAEF;;;GAGG;AACH,SAAgB,gBAAgB;IAC9B,MAAM,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,kCAAkC,EAAE,CAAC,CAAA;AACrE,CAAC;AAED,mBAAmB;AACZ,KAAK,UAAU,WAAW;IAC/B,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAA;IAC5C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IAC/B,OAAO,CAAC,KAAK,CAAC,gDAAgD,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;AACjF,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { OrchestratorClient } from './client';
2
+ export interface ToolDefinition {
3
+ name: string;
4
+ description: string;
5
+ inputSchema: Record<string, any>;
6
+ outputSchema?: Record<string, any>;
7
+ handler: (client: OrchestratorClient, args: any) => Promise<{
8
+ content: Array<{
9
+ type: string;
10
+ text: string;
11
+ }>;
12
+ isError?: boolean;
13
+ }>;
14
+ }
15
+ export declare const tools: ToolDefinition[];
16
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAElD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAClC,OAAO,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAA;CACnI;AAkED,eAAO,MAAM,KAAK,EAAE,cAAc,EAotCjC,CAAA"}