@virsanghavi/axis-server 1.0.3 → 1.0.5
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/mcp-server.mjs +48 -24
- package/package.json +1 -1
package/dist/mcp-server.mjs
CHANGED
|
@@ -110,17 +110,18 @@ var ContextManager = class {
|
|
|
110
110
|
return `Updated ${filename}`;
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
|
-
async searchContext(query) {
|
|
113
|
+
async searchContext(query, projectName = "default") {
|
|
114
114
|
if (!this.apiUrl) {
|
|
115
115
|
throw new Error("SHARED_CONTEXT_API_URL not configured.");
|
|
116
116
|
}
|
|
117
|
-
const
|
|
117
|
+
const endpoint = this.apiUrl.endsWith("/v1") ? `${this.apiUrl}/search` : `${this.apiUrl}/v1/search`;
|
|
118
|
+
const response = await fetch(endpoint, {
|
|
118
119
|
method: "POST",
|
|
119
120
|
headers: {
|
|
120
121
|
"Content-Type": "application/json",
|
|
121
122
|
"Authorization": `Bearer ${this.apiSecret || ""}`
|
|
122
123
|
},
|
|
123
|
-
body: JSON.stringify({ query })
|
|
124
|
+
body: JSON.stringify({ query, projectName })
|
|
124
125
|
});
|
|
125
126
|
if (!response.ok) {
|
|
126
127
|
const text = await response.text();
|
|
@@ -134,18 +135,19 @@ var ContextManager = class {
|
|
|
134
135
|
}
|
|
135
136
|
throw new Error("No results format recognized.");
|
|
136
137
|
}
|
|
137
|
-
async embedContent(items) {
|
|
138
|
+
async embedContent(items, projectName = "default") {
|
|
138
139
|
if (!this.apiUrl) {
|
|
139
140
|
console.warn("Skipping RAG embedding: SHARED_CONTEXT_API_URL not configured.");
|
|
140
141
|
return;
|
|
141
142
|
}
|
|
142
|
-
const
|
|
143
|
+
const endpoint = this.apiUrl.endsWith("/v1") ? `${this.apiUrl}/embed` : `${this.apiUrl}/v1/embed`;
|
|
144
|
+
const response = await fetch(endpoint, {
|
|
143
145
|
method: "POST",
|
|
144
146
|
headers: {
|
|
145
147
|
"Content-Type": "application/json",
|
|
146
148
|
"Authorization": `Bearer ${this.apiSecret || ""}`
|
|
147
149
|
},
|
|
148
|
-
body: JSON.stringify({ items })
|
|
150
|
+
body: JSON.stringify({ items, projectName })
|
|
149
151
|
});
|
|
150
152
|
if (!response.ok) {
|
|
151
153
|
const text = await response.text();
|
|
@@ -222,10 +224,13 @@ var NerveCenter = class {
|
|
|
222
224
|
const supabaseUrl = options.supabaseUrl || process.env.NEXT_PUBLIC_SUPABASE_URL;
|
|
223
225
|
const supabaseKey = options.supabaseServiceRoleKey || process.env.SUPABASE_SERVICE_ROLE_KEY;
|
|
224
226
|
if (!supabaseUrl || !supabaseKey) {
|
|
225
|
-
|
|
227
|
+
logger.warn("Supabase credentials missing. Running in local-only mode (state will be ephemeral or file-based).");
|
|
228
|
+
this.supabase = void 0;
|
|
229
|
+
this.useSupabase = false;
|
|
230
|
+
} else {
|
|
231
|
+
this.supabase = createClient(supabaseUrl, supabaseKey);
|
|
232
|
+
this.useSupabase = true;
|
|
226
233
|
}
|
|
227
|
-
this.supabase = createClient(supabaseUrl, supabaseKey);
|
|
228
|
-
this.useSupabase = true;
|
|
229
234
|
this.state = {
|
|
230
235
|
locks: {},
|
|
231
236
|
jobs: {},
|
|
@@ -235,6 +240,9 @@ var NerveCenter = class {
|
|
|
235
240
|
get projectId() {
|
|
236
241
|
return this._projectId;
|
|
237
242
|
}
|
|
243
|
+
get currentProjectName() {
|
|
244
|
+
return this.projectName;
|
|
245
|
+
}
|
|
238
246
|
async init() {
|
|
239
247
|
await this.loadState();
|
|
240
248
|
await this.detectProjectName();
|
|
@@ -744,8 +752,7 @@ var RagEngine = class {
|
|
|
744
752
|
// ../../src/local/mcp-server.ts
|
|
745
753
|
dotenv2.config({ path: ".env.local" });
|
|
746
754
|
if (!process.env.NEXT_PUBLIC_SUPABASE_URL || !process.env.SUPABASE_SERVICE_ROLE_KEY) {
|
|
747
|
-
logger.
|
|
748
|
-
process.exit(1);
|
|
755
|
+
logger.warn("Supabase credentials missing. RAG & Persistence disabled. Running in local/ephemeral mode.");
|
|
749
756
|
}
|
|
750
757
|
var manager = new ContextManager(
|
|
751
758
|
process.env.SHARED_CONTEXT_API_URL || "https://aicontext.vercel.app/api/v1",
|
|
@@ -756,13 +763,14 @@ var nerveCenter = new NerveCenter(manager, {
|
|
|
756
763
|
supabaseServiceRoleKey: process.env.SUPABASE_SERVICE_ROLE_KEY,
|
|
757
764
|
projectName: process.env.PROJECT_NAME || "default"
|
|
758
765
|
});
|
|
759
|
-
var ragEngine
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
);
|
|
766
|
+
var ragEngine;
|
|
767
|
+
if (process.env.NEXT_PUBLIC_SUPABASE_URL && process.env.SUPABASE_SERVICE_ROLE_KEY) {
|
|
768
|
+
ragEngine = new RagEngine(
|
|
769
|
+
process.env.NEXT_PUBLIC_SUPABASE_URL,
|
|
770
|
+
process.env.SUPABASE_SERVICE_ROLE_KEY,
|
|
771
|
+
process.env.OPENAI_API_KEY || ""
|
|
772
|
+
);
|
|
773
|
+
}
|
|
766
774
|
async function ensureFileSystem() {
|
|
767
775
|
const fs3 = await import("fs/promises");
|
|
768
776
|
const path3 = await import("path");
|
|
@@ -1082,13 +1090,29 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1082
1090
|
if (name === "index_file") {
|
|
1083
1091
|
const filePath = String(args?.filePath);
|
|
1084
1092
|
const content = String(args?.content);
|
|
1085
|
-
|
|
1086
|
-
|
|
1093
|
+
try {
|
|
1094
|
+
await manager.embedContent([{ content, metadata: { filePath } }], nerveCenter.currentProjectName);
|
|
1095
|
+
return { content: [{ type: "text", text: "Indexed via Remote API." }] };
|
|
1096
|
+
} catch (e) {
|
|
1097
|
+
if (ragEngine) {
|
|
1098
|
+
const success = await ragEngine.indexContent(filePath, content);
|
|
1099
|
+
return { content: [{ type: "text", text: success ? "Indexed locally." : "Local index failed." }] };
|
|
1100
|
+
}
|
|
1101
|
+
return { content: [{ type: "text", text: `Indexing failed: ${e}` }], isError: true };
|
|
1102
|
+
}
|
|
1087
1103
|
}
|
|
1088
1104
|
if (name === SEARCH_CONTEXT_TOOL) {
|
|
1089
1105
|
const query = String(args?.query);
|
|
1090
|
-
|
|
1091
|
-
|
|
1106
|
+
try {
|
|
1107
|
+
const results = await manager.searchContext(query, nerveCenter.currentProjectName);
|
|
1108
|
+
return { content: [{ type: "text", text: results }] };
|
|
1109
|
+
} catch (e) {
|
|
1110
|
+
if (ragEngine) {
|
|
1111
|
+
const results = await ragEngine.search(query);
|
|
1112
|
+
return { content: [{ type: "text", text: results.join("\n---\n") }] };
|
|
1113
|
+
}
|
|
1114
|
+
return { content: [{ type: "text", text: `Search failed: ${e}` }], isError: true };
|
|
1115
|
+
}
|
|
1092
1116
|
}
|
|
1093
1117
|
if (name === "get_subscription_status") {
|
|
1094
1118
|
const email = String(args?.email);
|
|
@@ -1160,9 +1184,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1160
1184
|
async function main() {
|
|
1161
1185
|
await ensureFileSystem();
|
|
1162
1186
|
await nerveCenter.init();
|
|
1163
|
-
if (nerveCenter.projectId) {
|
|
1187
|
+
if (nerveCenter.projectId && ragEngine) {
|
|
1164
1188
|
ragEngine.setProjectId(nerveCenter.projectId);
|
|
1165
|
-
logger.info(`RAG Engine linked to Project ID: ${nerveCenter.projectId}`);
|
|
1189
|
+
logger.info(`Local RAG Engine linked to Project ID: ${nerveCenter.projectId}`);
|
|
1166
1190
|
}
|
|
1167
1191
|
const transport = new StdioServerTransport();
|
|
1168
1192
|
await server.connect(transport);
|