@rigstate/mcp 0.5.2 → 0.5.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rigstate/mcp",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
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",
@@ -34,23 +34,37 @@ architecture rules, decisions, and constraints.`,
34
34
  }
35
35
  });
36
36
 
37
- // Simple embedding generation using Google Gemini
37
+ // Generate embedding using the preferred provider (OpenRouter or Google)
38
38
  async function generateQueryEmbedding(query: string): Promise<number[] | null> {
39
- const apiKey = process.env.GOOGLE_GENERATIVE_AI_API_KEY;
40
- if (!apiKey) {
41
- console.warn('GOOGLE_GENERATIVE_AI_API_KEY not found, skipping vector search.');
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
- const { embedding } = await embed({
50
- model: google.embedding('text-embedding-004'),
51
- value: query.replace(/\n/g, ' '),
52
- });
53
- return embedding;
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;