mcp-meilisearch 1.3.3 → 1.3.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/README.md
CHANGED
|
@@ -59,10 +59,28 @@ pnpm add mcp-meilisearch
|
|
|
59
59
|
|
|
60
60
|
#### AI Inference Options
|
|
61
61
|
|
|
62
|
-
- `aiProviderName`: Name of the AI provider ("openai" | "huggingface") (Default: "openai")
|
|
62
|
+
- `aiProviderName`: Name of the AI provider ("openai" | "huggingface" | "openrouter") (Default: "openai")
|
|
63
63
|
- `aiProviderApiKey`: AI provider API key for AI inference
|
|
64
64
|
- `llmModel`: AI model to use (Default: "gpt-3.5-turbo")
|
|
65
65
|
|
|
66
|
+
##### Using OpenRouter as AI Provider
|
|
67
|
+
|
|
68
|
+
When setting `aiProviderName` to "openrouter", please be aware that not all models support function calling, which is required for proper AI inference in this package. Make sure to select a model that supports the tools parameter.
|
|
69
|
+
|
|
70
|
+
You can find a list of OpenRouter models that support function calling at:
|
|
71
|
+
https://openrouter.ai/models?fmt=cards&supported_parameters=tools
|
|
72
|
+
|
|
73
|
+
Example configuration with OpenRouter:
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
await mcpMeilisearchServer({
|
|
77
|
+
meilisearchHost: "http://localhost:7700",
|
|
78
|
+
aiProviderName: "openrouter",
|
|
79
|
+
aiProviderApiKey: "your_openrouter_api_key",
|
|
80
|
+
llmModel: "anthropic/claude-3-opus", // Make sure to use a model that supports function calling
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
66
84
|
### Using the MCPClient
|
|
67
85
|
|
|
68
86
|
The package exports the MCPClient class for client-side integration:
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/types/options.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/types/options.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,GAAG,QAAQ,GAAG,aAAa,GAAG,YAAY,CAAC;AAE5E,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAE7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;OAGG;IACH,cAAc,CAAC,EAAE,qBAAqB,CAAC;IAEvC;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-handler.d.ts","sourceRoot":"","sources":["../../src/utils/ai-handler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAG5D,UAAU,MAAM;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAiBD,UAAU,cAAc;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACjC;AAED;;;;;GAKG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAA2B;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MG;IACH,UAAU,CACR,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,qBAAgC,EAC1C,KAAK,CAAC,EAAE,MAAM,GACb,IAAI;IA4BP;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAIxC,iBAAiB,IAAI,OAAO;IAI5B;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;;;;OAKG;IACG,YAAY,CAChB,KAAK,EAAE,MAAM,EACb,aAAa,CAAC,EAAE,MAAM,EAAE,GACvB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;YA+BnB,kBAAkB;YAiClB,uBAAuB;CAiCtC"}
|
package/dist/utils/ai-handler.js
CHANGED
|
@@ -48,6 +48,9 @@ export class AIService {
|
|
|
48
48
|
this.model = model;
|
|
49
49
|
switch (this.provider) {
|
|
50
50
|
case "openai":
|
|
51
|
+
this.client = new OpenAI({ apiKey });
|
|
52
|
+
break;
|
|
53
|
+
case "openrouter":
|
|
51
54
|
this.client = new OpenAI({
|
|
52
55
|
apiKey,
|
|
53
56
|
baseURL: "https://openrouter.ai/api/v1",
|
|
@@ -123,13 +126,10 @@ export class AIService {
|
|
|
123
126
|
{ role: "system", content: systemPrompt },
|
|
124
127
|
{ role: "user", content: query },
|
|
125
128
|
];
|
|
126
|
-
if (this.provider === "openai") {
|
|
127
|
-
return this.processOpenAIQuery(tools, messages);
|
|
128
|
-
}
|
|
129
129
|
if (this.provider === "huggingface") {
|
|
130
130
|
return this.processHuggingFaceQuery(tools, messages);
|
|
131
131
|
}
|
|
132
|
-
return
|
|
132
|
+
return this.processOpenAIQuery(tools, messages);
|
|
133
133
|
}
|
|
134
134
|
catch (error) {
|
|
135
135
|
if (error instanceof Error) {
|