@rigstate/mcp 0.5.2 → 0.5.4
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/index.js +23 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/tools/query-brain.ts +27 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rigstate/mcp",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Rigstate MCP Server - Model Context Protocol for AI Editors",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@ai-sdk/google": "^3.0.13",
|
|
19
19
|
"@google/generative-ai": "^0.24.1",
|
|
20
20
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
21
|
+
"@openrouter/ai-sdk-provider": "^1.5.4",
|
|
21
22
|
"@rigstate/rules-engine": "0.1.0",
|
|
22
23
|
"@supabase/supabase-js": "^2.39.0",
|
|
23
24
|
"ai": "^6.0.5",
|
package/src/tools/query-brain.ts
CHANGED
|
@@ -34,23 +34,37 @@ architecture rules, decisions, and constraints.`,
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
//
|
|
37
|
+
// Generate embedding using the preferred provider (OpenRouter or Google)
|
|
38
38
|
async function generateQueryEmbedding(query: string): Promise<number[] | null> {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const openRouterKey = process.env.OPENROUTER_API_KEY;
|
|
40
|
+
const googleKey = process.env.GOOGLE_GENERATIVE_AI_API_KEY;
|
|
41
|
+
|
|
42
|
+
if (!openRouterKey && !googleKey) {
|
|
43
|
+
console.warn('Neither OPENROUTER_API_KEY nor GOOGLE_GENERATIVE_AI_API_KEY found, skipping vector search.');
|
|
42
44
|
return null;
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
try {
|
|
46
|
-
const { google } = await import('@ai-sdk/google');
|
|
47
48
|
const { embed } = await import('ai');
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
if (openRouterKey) {
|
|
51
|
+
const { createOpenRouter } = await import('@openrouter/ai-sdk-provider');
|
|
52
|
+
const openrouter = createOpenRouter({ apiKey: openRouterKey });
|
|
53
|
+
|
|
54
|
+
// Use Gemini embedding via OpenRouter to maintain 768 dimensions
|
|
55
|
+
const { embedding } = await embed({
|
|
56
|
+
model: openrouter.embedding('google/text-embedding-004'),
|
|
57
|
+
value: query.replace(/\n/g, ' '),
|
|
58
|
+
});
|
|
59
|
+
return embedding;
|
|
60
|
+
} else {
|
|
61
|
+
const { google } = await import('@ai-sdk/google');
|
|
62
|
+
const { embedding } = await embed({
|
|
63
|
+
model: google.embedding('text-embedding-004'),
|
|
64
|
+
value: query.replace(/\n/g, ' '),
|
|
65
|
+
});
|
|
66
|
+
return embedding;
|
|
67
|
+
}
|
|
54
68
|
} catch (error) {
|
|
55
69
|
console.error('Failed to generate embedding for search:', error);
|
|
56
70
|
return null;
|
|
@@ -84,8 +98,8 @@ export async function queryBrain(
|
|
|
84
98
|
let memories: MemoryRecord[] = [];
|
|
85
99
|
|
|
86
100
|
// Use the hybrid search RPC
|
|
87
|
-
console.
|
|
88
|
-
console.
|
|
101
|
+
console.error(`Searching brain for "${query}" (limit: ${limit}, threshold: ${threshold})`);
|
|
102
|
+
console.error(`Embedding present: ${!!embedding}`);
|
|
89
103
|
|
|
90
104
|
const { data: searchResults, error: searchError } = await supabase
|
|
91
105
|
.rpc('hybrid_search_memories', {
|
|
@@ -118,7 +132,7 @@ export async function queryBrain(
|
|
|
118
132
|
}));
|
|
119
133
|
}
|
|
120
134
|
} else if (searchResults) {
|
|
121
|
-
console.
|
|
135
|
+
console.error(`Found ${searchResults.length} results from RPC`);
|
|
122
136
|
memories = searchResults.map((m: any) => ({
|
|
123
137
|
id: m.id,
|
|
124
138
|
content: m.content,
|