@moorchehai/mcp 1.3.2 → 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 +16 -10
- package/package.json +1 -1
- package/src/server/index.js +247 -225
- package/src/server/tools/data-tools.js +356 -209
- package/src/server/tools/namespace-tools.js +129 -129
- package/src/server/tools/search-tools.js +13 -1
- package/src/server/utils/prompts.js +358 -358
- package/src/server/utils/resources.js +7 -18
|
@@ -1,130 +1,130 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { makeApiRequest, API_ENDPOINTS } from '../config/api.js';
|
|
3
|
-
|
|
4
|
-
// Namespace listing tool
|
|
5
|
-
export const listNamespacesTool = {
|
|
6
|
-
name: "list-namespaces",
|
|
7
|
-
description: "List all available namespaces in Moorcheh",
|
|
8
|
-
parameters: {},
|
|
9
|
-
handler: async () => {
|
|
10
|
-
try {
|
|
11
|
-
const data = await makeApiRequest('GET', API_ENDPOINTS.namespaces);
|
|
12
|
-
|
|
13
|
-
if (!data.namespaces || data.namespaces.length === 0) {
|
|
14
|
-
return {
|
|
15
|
-
content: [
|
|
16
|
-
{
|
|
17
|
-
type: "text",
|
|
18
|
-
text: "No namespaces found",
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const formattedNamespaces = data.namespaces.map((ns) =>
|
|
25
|
-
[
|
|
26
|
-
`Namespace: ${ns.namespace_name}`,
|
|
27
|
-
`Type: ${ns.type}`,
|
|
28
|
-
`Vector Dimension: ${ns.vector_dimension || 'N/A'}`,
|
|
29
|
-
`Created: ${ns.created_at || 'N/A'}`,
|
|
30
|
-
`Items: ${ns.item_count || 'N/A'}`,
|
|
31
|
-
"---",
|
|
32
|
-
].join("\n")
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const namespacesText = `Available namespaces:\n\n${formattedNamespaces.join("\n")}`;
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
content: [
|
|
39
|
-
{
|
|
40
|
-
type: "text",
|
|
41
|
-
text: namespacesText,
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
};
|
|
45
|
-
} catch (error) {
|
|
46
|
-
return {
|
|
47
|
-
content: [
|
|
48
|
-
{
|
|
49
|
-
type: "text",
|
|
50
|
-
text: `Error listing namespaces: ${error.message}`,
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// Create namespace tool
|
|
59
|
-
export const createNamespaceTool = {
|
|
60
|
-
name: "create-namespace",
|
|
61
|
-
description: "Create a new namespace for document storage in Moorcheh",
|
|
62
|
-
parameters: {
|
|
63
|
-
namespace_name: z.string().describe("Name of the namespace to create"),
|
|
64
|
-
type: z.string().optional().describe("Type of namespace (text, vector, etc.)"),
|
|
65
|
-
vector_dimension: z.number().optional().describe("Vector dimension for vector namespaces"),
|
|
66
|
-
},
|
|
67
|
-
handler: async ({ namespace_name, type = "text", vector_dimension }) => {
|
|
68
|
-
try {
|
|
69
|
-
const data = await makeApiRequest('POST', API_ENDPOINTS.namespaces, {
|
|
70
|
-
namespace_name,
|
|
71
|
-
type,
|
|
72
|
-
vector_dimension,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const resultText = `Successfully created namespace "${namespace_name}":\n${JSON.stringify(data, null, 2)}`;
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
content: [
|
|
79
|
-
{
|
|
80
|
-
type: "text",
|
|
81
|
-
text: resultText,
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
};
|
|
85
|
-
} catch (error) {
|
|
86
|
-
return {
|
|
87
|
-
content: [
|
|
88
|
-
{
|
|
89
|
-
type: "text",
|
|
90
|
-
text: `Error creating namespace: ${error.message}`,
|
|
91
|
-
},
|
|
92
|
-
],
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// Delete namespace tool
|
|
99
|
-
export const deleteNamespaceTool = {
|
|
100
|
-
name: "delete-namespace",
|
|
101
|
-
description: "Delete a namespace and all its contents from Moorcheh",
|
|
102
|
-
parameters: {
|
|
103
|
-
namespace_name: z.string().describe("Name of the namespace to delete"),
|
|
104
|
-
},
|
|
105
|
-
handler: async ({ namespace_name }) => {
|
|
106
|
-
try {
|
|
107
|
-
const data = await makeApiRequest('DELETE', `${API_ENDPOINTS.namespaces}/${namespace_name}`);
|
|
108
|
-
|
|
109
|
-
const resultText = `Successfully deleted namespace "${namespace_name}":\n${JSON.stringify(data, null, 2)}`;
|
|
110
|
-
|
|
111
|
-
return {
|
|
112
|
-
content: [
|
|
113
|
-
{
|
|
114
|
-
type: "text",
|
|
115
|
-
text: resultText,
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
};
|
|
119
|
-
} catch (error) {
|
|
120
|
-
return {
|
|
121
|
-
content: [
|
|
122
|
-
{
|
|
123
|
-
type: "text",
|
|
124
|
-
text: `Error deleting namespace: ${error.message}`,
|
|
125
|
-
},
|
|
126
|
-
],
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
},
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { makeApiRequest, API_ENDPOINTS } from '../config/api.js';
|
|
3
|
+
|
|
4
|
+
// Namespace listing tool
|
|
5
|
+
export const listNamespacesTool = {
|
|
6
|
+
name: "list-namespaces",
|
|
7
|
+
description: "List all available namespaces in Moorcheh",
|
|
8
|
+
parameters: {},
|
|
9
|
+
handler: async () => {
|
|
10
|
+
try {
|
|
11
|
+
const data = await makeApiRequest('GET', API_ENDPOINTS.namespaces);
|
|
12
|
+
|
|
13
|
+
if (!data.namespaces || data.namespaces.length === 0) {
|
|
14
|
+
return {
|
|
15
|
+
content: [
|
|
16
|
+
{
|
|
17
|
+
type: "text",
|
|
18
|
+
text: "No namespaces found",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const formattedNamespaces = data.namespaces.map((ns) =>
|
|
25
|
+
[
|
|
26
|
+
`Namespace: ${ns.namespace_name}`,
|
|
27
|
+
`Type: ${ns.type}`,
|
|
28
|
+
`Vector Dimension: ${ns.vector_dimension || 'N/A'}`,
|
|
29
|
+
`Created: ${ns.created_at || 'N/A'}`,
|
|
30
|
+
`Items: ${ns.item_count || 'N/A'}`,
|
|
31
|
+
"---",
|
|
32
|
+
].join("\n")
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const namespacesText = `Available namespaces:\n\n${formattedNamespaces.join("\n")}`;
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
content: [
|
|
39
|
+
{
|
|
40
|
+
type: "text",
|
|
41
|
+
text: namespacesText,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
} catch (error) {
|
|
46
|
+
return {
|
|
47
|
+
content: [
|
|
48
|
+
{
|
|
49
|
+
type: "text",
|
|
50
|
+
text: `Error listing namespaces: ${error.message}`,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Create namespace tool
|
|
59
|
+
export const createNamespaceTool = {
|
|
60
|
+
name: "create-namespace",
|
|
61
|
+
description: "Create a new namespace for document storage in Moorcheh",
|
|
62
|
+
parameters: {
|
|
63
|
+
namespace_name: z.string().describe("Name of the namespace to create"),
|
|
64
|
+
type: z.string().optional().describe("Type of namespace (text, vector, etc.)"),
|
|
65
|
+
vector_dimension: z.number().optional().describe("Vector dimension for vector namespaces"),
|
|
66
|
+
},
|
|
67
|
+
handler: async ({ namespace_name, type = "text", vector_dimension }) => {
|
|
68
|
+
try {
|
|
69
|
+
const data = await makeApiRequest('POST', API_ENDPOINTS.namespaces, {
|
|
70
|
+
namespace_name,
|
|
71
|
+
type,
|
|
72
|
+
vector_dimension,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const resultText = `Successfully created namespace "${namespace_name}":\n${JSON.stringify(data, null, 2)}`;
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
content: [
|
|
79
|
+
{
|
|
80
|
+
type: "text",
|
|
81
|
+
text: resultText,
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
} catch (error) {
|
|
86
|
+
return {
|
|
87
|
+
content: [
|
|
88
|
+
{
|
|
89
|
+
type: "text",
|
|
90
|
+
text: `Error creating namespace: ${error.message}`,
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// Delete namespace tool
|
|
99
|
+
export const deleteNamespaceTool = {
|
|
100
|
+
name: "delete-namespace",
|
|
101
|
+
description: "Delete a namespace and all its contents from Moorcheh",
|
|
102
|
+
parameters: {
|
|
103
|
+
namespace_name: z.string().describe("Name of the namespace to delete"),
|
|
104
|
+
},
|
|
105
|
+
handler: async ({ namespace_name }) => {
|
|
106
|
+
try {
|
|
107
|
+
const data = await makeApiRequest('DELETE', `${API_ENDPOINTS.namespaces}/${namespace_name}`);
|
|
108
|
+
|
|
109
|
+
const resultText = `Successfully deleted namespace "${namespace_name}":\n${JSON.stringify(data, null, 2)}`;
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
content: [
|
|
113
|
+
{
|
|
114
|
+
type: "text",
|
|
115
|
+
text: resultText,
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
} catch (error) {
|
|
120
|
+
return {
|
|
121
|
+
content: [
|
|
122
|
+
{
|
|
123
|
+
type: "text",
|
|
124
|
+
text: `Error deleting namespace: ${error.message}`,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
130
|
};
|
|
@@ -186,7 +186,19 @@ export const answerTool = {
|
|
|
186
186
|
type: z.enum(['text']).optional().describe("Search type for answer generation. Supported value is 'text'."),
|
|
187
187
|
threshold: z.number().min(0).max(1).optional().describe("Similarity threshold for results. A value between 0 and 1 that filters documents based on relevance before generating the answer. Higher values (0.7-0.9) ensure only highly relevant content is used, lower values (0.3-0.5) include more context. Required when kiosk_mode is true."),
|
|
188
188
|
kiosk_mode: z.boolean().optional().describe("Kiosk mode for restricted search. When true, search is restricted to specific namespaces with threshold filtering, providing more controlled and focused answers suitable for production environments."),
|
|
189
|
-
ai_model: z.string().optional().describe(
|
|
189
|
+
ai_model: z.string().optional().describe(
|
|
190
|
+
"AI model ID for answer generation (snake_case field sent to the API). Supported models: " +
|
|
191
|
+
"'anthropic.claude-sonnet-4-6' (Claude Sonnet 4.6), " +
|
|
192
|
+
"'anthropic.claude-opus-4-6-v1' (Claude Opus 4.6), " +
|
|
193
|
+
"'meta.llama4-maverick-17b-instruct-v1:0' (Llama 4 Maverick 17B), " +
|
|
194
|
+
"'amazon.nova-pro-v1:0' (Amazon Nova Pro), " +
|
|
195
|
+
"'deepseek.r1-v1:0' (DeepSeek R1), " +
|
|
196
|
+
"'deepseek.v3.2' (DeepSeek V3.2), " +
|
|
197
|
+
"'openai.gpt-oss-120b-1:0' (OpenAI GPT OSS 120B), " +
|
|
198
|
+
"'qwen.qwen3-32b-v1:0' (Qwen 3 32B), " +
|
|
199
|
+
"'qwen.qwen3-next-80b-a3b' (Qwen3 Next 80B A3B). " +
|
|
200
|
+
"If omitted, the Moorcheh API uses its default model for your account."
|
|
201
|
+
),
|
|
190
202
|
chat_history: z.array(z.object({
|
|
191
203
|
role: z.string().describe("Role of the message in the conversation. Use 'user' for user messages and 'assistant' for AI responses. This helps maintain conversation context and allows the AI to reference previous exchanges."),
|
|
192
204
|
content: z.string()
|