@virsanghavi/axis-server 1.0.4 → 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 +41 -19
- 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();
|
|
@@ -238,6 +240,9 @@ var NerveCenter = class {
|
|
|
238
240
|
get projectId() {
|
|
239
241
|
return this._projectId;
|
|
240
242
|
}
|
|
243
|
+
get currentProjectName() {
|
|
244
|
+
return this.projectName;
|
|
245
|
+
}
|
|
241
246
|
async init() {
|
|
242
247
|
await this.loadState();
|
|
243
248
|
await this.detectProjectName();
|
|
@@ -758,13 +763,14 @@ var nerveCenter = new NerveCenter(manager, {
|
|
|
758
763
|
supabaseServiceRoleKey: process.env.SUPABASE_SERVICE_ROLE_KEY,
|
|
759
764
|
projectName: process.env.PROJECT_NAME || "default"
|
|
760
765
|
});
|
|
761
|
-
var ragEngine
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
);
|
|
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
|
+
}
|
|
768
774
|
async function ensureFileSystem() {
|
|
769
775
|
const fs3 = await import("fs/promises");
|
|
770
776
|
const path3 = await import("path");
|
|
@@ -1084,13 +1090,29 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1084
1090
|
if (name === "index_file") {
|
|
1085
1091
|
const filePath = String(args?.filePath);
|
|
1086
1092
|
const content = String(args?.content);
|
|
1087
|
-
|
|
1088
|
-
|
|
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
|
+
}
|
|
1089
1103
|
}
|
|
1090
1104
|
if (name === SEARCH_CONTEXT_TOOL) {
|
|
1091
1105
|
const query = String(args?.query);
|
|
1092
|
-
|
|
1093
|
-
|
|
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
|
+
}
|
|
1094
1116
|
}
|
|
1095
1117
|
if (name === "get_subscription_status") {
|
|
1096
1118
|
const email = String(args?.email);
|
|
@@ -1162,9 +1184,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
1162
1184
|
async function main() {
|
|
1163
1185
|
await ensureFileSystem();
|
|
1164
1186
|
await nerveCenter.init();
|
|
1165
|
-
if (nerveCenter.projectId) {
|
|
1187
|
+
if (nerveCenter.projectId && ragEngine) {
|
|
1166
1188
|
ragEngine.setProjectId(nerveCenter.projectId);
|
|
1167
|
-
logger.info(`RAG Engine linked to Project ID: ${nerveCenter.projectId}`);
|
|
1189
|
+
logger.info(`Local RAG Engine linked to Project ID: ${nerveCenter.projectId}`);
|
|
1168
1190
|
}
|
|
1169
1191
|
const transport = new StdioServerTransport();
|
|
1170
1192
|
await server.connect(transport);
|