@moorchehai/mcp 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.
@@ -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
  };