@moorchehai/mcp 1.2.1

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.
@@ -0,0 +1,157 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
3
+ "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
4
+ <svg version="1.0" xmlns="http://www.w3.org/2000/svg"
5
+ width="1500.000000pt" height="600.000000pt" viewBox="0 0 1500.000000 600.000000"
6
+ preserveAspectRatio="xMidYMid meet">
7
+
8
+ <g transform="translate(0.000000,600.000000) scale(0.100000,-0.100000)"
9
+ fill="#000000" stroke="none">
10
+ <path d="M2969 4960 c-86 -15 -165 -72 -203 -147 -21 -41 -21 -109 -1 -117 16
11
+ -6 25 8 45 71 15 49 71 110 120 131 75 32 255 11 399 -47 56 -22 66 -30 69
12
+ -53 4 -35 24 -50 63 -46 62 6 67 75 7 98 -18 6 -55 22 -83 35 -131 60 -312 93
13
+ -416 75z"/>
14
+ <path d="M2943 4755 c-55 -28 -95 -68 -121 -121 -27 -58 11 -90 45 -36 26 42
15
+ 75 92 108 110 46 24 153 19 255 -13 106 -34 156 -59 245 -124 62 -45 69 -54
16
+ 67 -80 -6 -57 64 -94 101 -53 49 54 -20 149 -72 100 -11 -11 -12 -9 -7 8 13
17
+ 44 -136 144 -297 201 -52 18 -100 26 -172 30 -93 4 -103 3 -152 -22z"/>
18
+ <path d="M2600 4658 c-51 -13 -110 -57 -144 -106 -24 -33 -31 -56 -34 -105 -5
19
+ -84 22 -149 92 -215 93 -88 212 -130 397 -139 168 -8 203 5 134 49 -19 13 -35
20
+ 26 -35 29 0 4 39 15 86 25 l86 18 -6 35 c-10 61 -74 178 -134 243 -54 58 -126
21
+ 118 -143 118 -4 0 -12 -13 -17 -29 -14 -41 -43 -54 -71 -34 -19 13 -22 23 -19
22
+ 61 3 45 2 47 -27 53 -44 10 -125 8 -165 -3z m81 -74 c12 -15 11 -18 -5 -28
23
+ -69 -41 -82 -55 -103 -106 -25 -63 -56 -79 -72 -37 -22 58 31 146 104 172 52
24
+ 18 60 18 76 -1z m101 -110 c78 -40 58 -164 -28 -180 -45 -8 -91 11 -109 47
25
+ -49 94 41 182 137 133z"/>
26
+ <path d="M2735 4469 c4 -5 4 -21 1 -34 -7 -29 -49 -43 -71 -25 -23 19 -28 6
27
+ -15 -34 27 -82 118 -88 155 -10 19 40 5 78 -36 100 -33 17 -42 18 -34 3z"/>
28
+ <path d="M1278 4384 c-40 -42 -74 -81 -76 -88 -1 -7 7 -21 18 -31 20 -18 21
29
+ -18 76 36 42 41 54 60 51 77 -9 48 22 18 68 -67 58 -106 135 -224 152 -229 6
30
+ -2 20 9 29 24 17 26 17 28 -9 78 -42 80 -155 258 -169 268 -37 23 -67 8 -140
31
+ -68z"/>
32
+ <path d="M526 4441 c-4 -5 -6 -206 -5 -446 l1 -437 35 68 c86 168 219 324 335
33
+ 392 121 72 300 109 406 84 23 -5 42 -8 42 -5 0 3 -28 36 -62 73 -35 36 -106
34
+ 114 -158 173 l-95 106 -247 1 c-138 0 -249 -4 -252 -9z"/>
35
+ <path d="M2144 4436 c-104 -33 -184 -129 -184 -220 0 -82 55 -150 136 -171 42
36
+ -10 56 -9 125 11 42 12 86 27 98 33 30 16 67 70 81 117 11 36 10 48 -9 98 -11
37
+ 31 -21 68 -21 81 0 54 -126 82 -226 51z m114 -58 c20 -20 14 -26 -45 -45 -41
38
+ -13 -74 -33 -114 -70 -31 -29 -59 -50 -63 -46 -14 14 -5 58 20 90 47 62 168
39
+ 105 202 71z"/>
40
+ <path d="M1765 4166 c-52 -24 -125 -95 -125 -121 0 -8 -15 -22 -32 -31 -43
41
+ -22 -67 -43 -84 -75 -11 -23 -10 -33 11 -85 13 -32 33 -67 45 -76 19 -15 24
42
+ -15 65 -1 36 12 51 12 79 3 43 -14 83 5 170 79 46 39 68 51 100 53 36 3 43 8
43
+ 63 43 13 22 23 43 23 46 0 3 -22 20 -48 37 -36 23 -57 48 -81 92 l-32 60 -52
44
+ 0 c-33 0 -70 -9 -102 -24z m100 -60 c0 -13 -18 -30 -50 -49 -27 -16 -61 -40
45
+ -76 -53 -14 -13 -28 -24 -31 -24 -15 0 -16 34 -2 64 30 63 159 113 159 62z
46
+ m-215 -186 c0 -20 -43 -45 -59 -36 -18 11 -13 44 11 68 20 20 22 20 35 3 7
47
+ -11 13 -26 13 -35z"/>
48
+ <path d="M3130 4163 c-39 -7 -46 -21 -17 -34 30 -14 82 0 82 22 0 15 -24 20
49
+ -65 12z"/>
50
+ <path d="M2468 4066 c-32 -36 -58 -68 -58 -71 0 -4 45 -4 99 0 55 4 128 4 163
51
+ 0 l63 -7 161 -161 c88 -89 172 -178 187 -197 l26 -35 1 215 0 215 -157 0
52
+ c-193 0 -241 12 -423 102 -3 2 -31 -26 -62 -61z"/>
53
+ <path d="M1123 4029 c-111 -19 -217 -81 -331 -197 -82 -82 -128 -149 -174
54
+ -250 -57 -127 -76 -194 -80 -281 l-3 -84 60 -17 c33 -9 81 -20 107 -24 47 -7
55
+ 47 -7 74 34 27 41 27 42 8 53 -31 18 -125 110 -139 137 -16 32 -29 120 -17
56
+ 120 4 0 19 -25 31 -55 25 -61 98 -148 143 -171 17 -9 31 -14 32 -12 31 51 68
57
+ 105 104 151 l44 58 -24 27 c-38 42 -85 114 -111 173 l-24 54 -7 -59 c-6 -47
58
+ -16 -70 -48 -113 -22 -29 -46 -53 -54 -53 -7 0 -16 15 -19 33 -9 44 22 111 79
59
+ 176 25 28 46 61 46 71 0 34 17 22 25 -17 12 -69 96 -201 161 -256 l30 -26 75
60
+ 25 c41 13 145 43 232 66 181 48 177 44 177 155 0 80 -21 130 -83 194 -49 51
61
+ -94 75 -168 89 -58 11 -73 11 -146 -1z m148 -69 c37 -20 13 -91 -26 -76 -25 9
62
+ -40 53 -25 71 15 18 24 19 51 5z m-133 -38 c4 -40 -9 -57 -61 -84 -22 -11 -63
63
+ -38 -90 -60 -45 -35 -52 -37 -65 -24 -9 8 -15 34 -16 60 -1 52 5 58 109 111
64
+ 87 45 119 44 123 -3z m-498 -557 c0 -23 -32 -60 -43 -48 -10 9 -9 38 3 68 9
65
+ 23 13 25 25 15 8 -7 15 -22 15 -35z"/>
66
+ <path d="M2213 4030 c-15 -6 -23 -18 -23 -32 0 -40 20 -97 44 -124 20 -24 32
67
+ -27 97 -31 41 -3 133 0 204 5 l130 10 34 -36 c19 -21 82 -86 140 -146 95 -98
68
+ 107 -108 129 -100 14 5 30 17 36 26 9 15 -12 41 -144 174 l-155 156 -190 -5
69
+ c-104 -3 -197 -8 -206 -12 -13 -5 -17 3 -22 46 -9 74 -25 89 -74 69z"/>
70
+ <path d="M14138 4015 c-26 -8 -56 -27 -67 -41 -51 -65 -51 -181 1 -240 36 -41
71
+ 79 -54 183 -54 145 0 205 51 205 176 0 70 -24 116 -78 147 -44 26 -179 33
72
+ -244 12z"/>
73
+ <path d="M8210 3235 l0 -775 184 0 185 0 3 338 c3 331 3 338 27 385 60 123
74
+ 233 144 296 37 19 -33 20 -54 23 -397 l3 -363 185 0 185 0 -3 423 -3 422 -28
75
+ 60 c-36 78 -95 137 -171 172 -55 25 -72 28 -166 28 -94 0 -111 -3 -165 -28
76
+ -69 -32 -115 -73 -156 -136 l-29 -45 0 327 0 327 -185 0 -185 0 0 -775z"/>
77
+ <path d="M10820 3235 l0 -775 184 0 185 0 3 338 c3 331 3 338 27 385 60 123
78
+ 233 144 296 37 19 -33 20 -54 23 -397 l3 -363 185 0 185 0 -3 423 -3 422 -28
79
+ 60 c-36 78 -95 137 -171 172 -55 25 -72 28 -166 28 -94 0 -111 -3 -165 -28
80
+ -69 -32 -115 -73 -156 -136 l-29 -45 0 327 0 327 -185 0 -185 0 0 -775z"/>
81
+ <path d="M1935 3864 c-33 -35 -30 -114 6 -206 14 -36 108 -98 198 -132 56 -22
82
+ 70 -32 76 -54 3 -14 34 -85 67 -157 33 -71 69 -153 79 -182 22 -58 39 -69 77
83
+ -50 51 24 54 18 -147 412 l-36 70 -120 61 -120 61 -3 84 c-2 59 -7 89 -19 101
84
+ -21 24 -30 23 -58 -8z"/>
85
+ <path d="M2505 3779 c-66 -5 -141 -7 -167 -4 -46 5 -46 5 -97 -52 l-51 -57 54
86
+ -28 55 -28 93 -185 c51 -102 95 -185 98 -184 3 0 30 29 60 65 30 35 58 64 63
87
+ 64 4 0 7 -94 7 -210 l0 -209 46 -78 c52 -89 93 -141 176 -230 68 -72 76 -108
88
+ 32 -142 -50 -39 -128 -16 -214 65 l-51 47 3 -129 3 -129 248 -3 247 -2 1 37
89
+ c0 21 0 243 0 493 l-1 455 -91 85 c-51 47 -158 149 -238 228 -81 78 -149 141
90
+ -151 141 -3 -1 -59 -6 -125 -10z"/>
91
+ <path d="M1652 3745 c-33 -24 -55 -73 -48 -107 4 -18 1 -30 -7 -32 -6 -2 -86
92
+ -26 -177 -54 -91 -28 -217 -65 -280 -82 -63 -18 -123 -40 -133 -49 -22 -21
93
+ -196 -274 -268 -389 -49 -80 -51 -84 -34 -103 10 -10 31 -19 46 -19 26 0 38
94
+ 17 160 223 72 122 133 224 135 225 1 2 77 24 167 48 168 45 306 93 395 138 44
95
+ 22 55 34 82 90 36 72 38 119 5 124 -11 1 -30 -5 -43 -13z"/>
96
+ <path d="M3006 3574 c-14 -37 -3 -56 82 -129 99 -87 203 -153 255 -162 29 -4
97
+ 36 -2 42 16 9 29 2 36 -60 65 -73 33 -126 71 -219 155 -43 39 -82 71 -86 71
98
+ -4 0 -11 -7 -14 -16z"/>
99
+ <path d="M3795 3553 c-108 -23 -191 -67 -266 -142 -106 -107 -152 -228 -152
100
+ -406 0 -173 42 -290 145 -400 102 -109 246 -165 428 -165 182 0 326 56 428
101
+ 164 103 111 143 222 143 401 0 184 -42 297 -150 406 -44 43 -88 76 -131 97
102
+ -125 59 -298 77 -445 45z m209 -254 c53 -13 92 -49 119 -108 29 -64 36 -254
103
+ 13 -335 -32 -108 -118 -168 -218 -152 -62 10 -105 43 -136 106 -25 52 -27 63
104
+ -27 195 0 133 1 143 28 197 29 59 53 81 108 96 46 14 63 14 113 1z"/>
105
+ <path d="M5100 3554 c-261 -56 -420 -263 -420 -549 0 -359 239 -579 610 -562
106
+ 337 15 540 227 540 562 0 345 -228 567 -580 564 -47 0 -114 -7 -150 -15z m253
107
+ -272 c38 -21 73 -70 87 -121 31 -109 20 -289 -23 -366 -42 -74 -129 -109 -215
108
+ -86 -57 16 -95 51 -123 113 -20 47 -23 68 -23 183 0 114 3 136 23 182 27 61
109
+ 55 90 108 109 47 18 124 11 166 -14z"/>
110
+ <path d="M6602 3555 c-86 -26 -144 -81 -195 -180 l-25 -50 -6 55 c-3 30 -7 80
111
+ -9 110 l-2 55 -162 3 -163 2 0 -545 0 -545 185 0 185 0 0 301 c0 328 3 354 53
112
+ 415 59 71 190 105 294 75 37 -11 34 -20 53 149 6 52 13 107 16 122 5 24 1 28
113
+ -33 37 -51 15 -138 13 -191 -4z"/>
114
+ <path d="M7345 3556 c-275 -64 -425 -258 -425 -551 0 -349 223 -565 585 -565
115
+ 181 0 332 56 423 155 50 54 102 161 85 175 -11 9 -297 100 -315 100 -8 0 -19
116
+ -18 -25 -42 -23 -86 -102 -136 -196 -125 -72 9 -119 44 -154 114 -26 54 -28
117
+ 66 -28 178 1 173 30 250 110 290 56 27 144 27 182 -1 40 -30 72 -81 80 -126 3
118
+ -23 10 -37 17 -35 6 2 82 28 169 56 179 60 177 57 131 150 -50 100 -157 182
119
+ -285 217 -78 21 -280 27 -354 10z"/>
120
+ <path d="M9943 3559 c-208 -35 -375 -192 -423 -399 -17 -71 -17 -239 -1 -310
121
+ 48 -205 200 -350 413 -394 217 -45 448 8 570 130 42 42 97 129 87 138 -2 2
122
+ -69 25 -149 51 -114 38 -145 45 -149 34 -9 -29 -78 -87 -116 -98 -152 -42
123
+ -276 27 -309 172 l-6 27 375 0 375 0 0 118 c0 187 -42 304 -145 401 -123 116
124
+ -316 164 -522 130z m234 -275 c34 -25 69 -86 78 -136 l7 -38 -196 0 c-190 0
125
+ -196 1 -196 20 0 30 27 91 53 119 57 62 192 81 254 35z"/>
126
+ <path d="M13126 3560 c-128 -23 -216 -69 -290 -152 -40 -43 -86 -136 -86 -171
127
+ 0 -7 60 -26 155 -48 l155 -36 11 36 c7 20 19 46 27 59 40 61 182 88 238 46 45
128
+ -33 67 -70 72 -122 5 -59 31 -48 -231 -102 -217 -45 -264 -60 -329 -106 -129
129
+ -91 -145 -311 -30 -425 139 -138 464 -130 604 14 32 33 41 38 49 26 5 -8 9
130
+ -17 9 -20 0 -19 81 -81 125 -96 60 -21 203 -24 256 -5 l37 13 6 87 c4 48 10
131
+ 95 12 104 5 16 0 17 -40 12 -39 -6 -48 -3 -70 19 l-26 26 0 234 c0 128 -5 260
132
+ -11 292 -12 68 -46 140 -89 188 -34 40 -131 93 -204 114 -62 17 -282 25 -350
133
+ 13z m284 -693 c0 -112 -75 -187 -186 -187 -42 0 -59 5 -83 26 -26 22 -31 33
134
+ -31 70 0 73 30 92 200 128 104 22 100 24 100 -37z"/>
135
+ <path d="M14060 3005 l0 -545 185 0 185 0 0 545 0 545 -185 0 -185 0 0 -545z"/>
136
+ <path d="M1966 3432 c-34 -37 -85 -91 -112 -120 l-49 -53 -60 58 c-34 32 -80
137
+ 80 -104 106 l-43 49 -66 -35 c-37 -19 -96 -47 -131 -61 -48 -19 -83 -44 -137
138
+ -96 -39 -39 -77 -70 -83 -70 -30 0 -1 -41 111 -158 248 -257 503 -512 513
139
+ -512 6 0 124 119 263 264 l252 265 -34 78 c-81 187 -128 289 -139 300 -7 6
140
+ -36 21 -65 32 l-53 20 -63 -67z"/>
141
+ <path d="M1183 3337 c-99 -20 -102 -21 -122 -58 -12 -20 -21 -39 -21 -43 0
142
+ -26 146 27 218 78 28 21 52 40 52 42 0 6 -15 4 -127 -19z"/>
143
+ <path d="M524 3128 c3 -13 6 -81 6 -153 l1 -130 29 35 c42 49 132 208 125 220
144
+ -3 5 -14 10 -24 10 -10 0 -44 9 -76 20 -72 25 -69 25 -61 -2z"/>
145
+ <path d="M988 3137 c-7 -8 -44 -69 -82 -136 -45 -78 -79 -128 -97 -138 -16
146
+ -10 -60 -65 -99 -125 -38 -59 -97 -136 -130 -171 l-60 -65 7 -76 6 -76 256 2
147
+ 256 3 0 397 0 398 -22 0 c-12 0 -28 -6 -35 -13z"/>
148
+ <path d="M2456 3058 c-14 -20 -12 -29 46 -137 115 -219 218 -350 286 -368 50
149
+ -12 58 50 10 75 -66 34 -115 100 -199 263 -101 198 -112 211 -143 167z"/>
150
+ <path d="M648 2873 c-14 -16 -63 -80 -110 -143 -121 -162 -181 -222 -267 -262
151
+ -63 -29 -71 -36 -69 -58 2 -20 9 -26 33 -28 83 -8 298 196 444 421 36 55 41
152
+ 70 31 82 -18 22 -33 19 -62 -12z"/>
153
+ <path d="M12245 2811 c-76 -35 -105 -85 -105 -179 0 -75 30 -128 90 -162 63
154
+ -35 186 -36 245 -2 56 32 87 82 93 147 8 93 -29 163 -102 196 -55 25 -167 25
155
+ -221 0z"/>
156
+ </g>
157
+ </svg>
package/bin/cli.js ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { spawn } from 'child_process';
4
+ import { fileURLToPath } from 'url';
5
+ import { dirname, join } from 'path';
6
+
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+
10
+ // Path to the main server script
11
+ const serverPath = join(__dirname, '..', 'src', 'server', 'index.js');
12
+
13
+ // Get command line arguments (skip node and script name)
14
+ const args = process.argv.slice(2);
15
+
16
+ // Check if user needs help
17
+ if (args.includes('--help') || args.includes('-h')) {
18
+ console.log(`
19
+ Moorcheh MCP Server
20
+ ===================
21
+
22
+ Usage: npx @moorcheh/mcp [options]
23
+
24
+ Options:
25
+ --help, -h Show this help message
26
+ --version, -v Show version information
27
+
28
+ Environment Variables:
29
+ MOORCHEH_API_KEY Your Moorcheh API key (required)
30
+
31
+ Examples:
32
+ npx @moorcheh/mcp # Start the MCP server
33
+ MOORCHEH_API_KEY=xxx npx @moorcheh/mcp # Start with API key
34
+
35
+ For more information, visit: https://github.com/moorcheh-ai/moorcheh-mcp
36
+ `);
37
+ process.exit(0);
38
+ }
39
+
40
+ // Check if user wants version
41
+ if (args.includes('--version') || args.includes('-v')) {
42
+ const packageJson = await import('../package.json', { with: { type: 'json' } });
43
+ console.log(packageJson.default.version);
44
+ process.exit(0);
45
+ }
46
+
47
+ // Check for API key
48
+ if (!process.env.MOORCHEH_API_KEY) {
49
+ console.error(`
50
+ ❌ Error: Missing MOORCHEH_API_KEY environment variable
51
+
52
+ Please set your Moorcheh API key:
53
+ MOORCHEH_API_KEY=your_api_key_here npx @moorcheh/mcp
54
+
55
+ Get your API key at: https://app.moorcheh.ai
56
+ `);
57
+ process.exit(1);
58
+ }
59
+
60
+ console.error('🚀 Starting Moorcheh MCP Server...');
61
+ console.error('📝 API Key configured ✓');
62
+
63
+ // Start the main server
64
+ const child = spawn('node', [serverPath, ...args], {
65
+ stdio: 'inherit',
66
+ env: process.env
67
+ });
68
+
69
+ child.on('error', (error) => {
70
+ console.error('Failed to start server:', error);
71
+ process.exit(1);
72
+ });
73
+
74
+ child.on('close', (code) => {
75
+ process.exit(code);
76
+ });
package/env.example ADDED
@@ -0,0 +1,2 @@
1
+ # Required: Your Moorcheh API key
2
+ MOORCHEH_API_KEY=your_moorcheh_api_key_here
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@moorchehai/mcp",
3
+ "version": "1.2.1",
4
+ "description": "Moorcheh MCP Server with completable functionality for AI-powered search and answer operations",
5
+ "main": "src/server/index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "moorcheh-mcp": "bin/cli.js",
9
+ "mcp": "bin/cli.js"
10
+ },
11
+ "preferGlobal": true,
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "scripts": {
16
+ "start": "node src/server/index.js",
17
+ "dev": "node --watch src/server/index.js",
18
+ "test": "node src/test/test-mcp.js",
19
+ "build": "echo 'No build step required'",
20
+ "lint": "echo \"No linting configured\"",
21
+ "format": "echo \"No formatting configured\""
22
+ },
23
+ "keywords": [
24
+ "mcp",
25
+ "moorcheh",
26
+ "ai",
27
+ "search",
28
+ "bedrock",
29
+ "vector",
30
+ "semantic",
31
+ "completable",
32
+ "model-context-protocol",
33
+ "knowledge-base",
34
+ "document-search"
35
+ ],
36
+ "author": "Moorcheh Team",
37
+ "license": "Apache-2.0",
38
+ "dependencies": {
39
+ "@modelcontextprotocol/sdk": "^1.17.0",
40
+ "zod": "^3.22.4",
41
+ "axios": "^1.11.0"
42
+ },
43
+ "devDependencies": {
44
+ "node": ">=18.0.0"
45
+ },
46
+ "engines": {
47
+ "node": ">=18.0.0"
48
+ },
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/moorcheh-ai/moorcheh-mcp.git"
52
+ },
53
+ "bugs": {
54
+ "url": "https://github.com/moorcheh-ai/moorcheh-mcp/issues"
55
+ },
56
+ "homepage": "https://github.com/moorcheh-ai/moorcheh-mcp#readme",
57
+ "files": [
58
+ "src/",
59
+ "bin/",
60
+ "assets/",
61
+ "env.example",
62
+ "README.md",
63
+ "LICENSE"
64
+ ],
65
+ "directories": {
66
+ "lib": "src/server"
67
+ }
68
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "mcpServers": {
3
+ "moorcheh": {
4
+ "command": "npx",
5
+ "args": ["-y", "@moorcheh/mcp"],
6
+ "env": {
7
+ "MOORCHEH_API_KEY": "your_actual_api_key_here"
8
+ }
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,90 @@
1
+ import axios from 'axios';
2
+ import { readFileSync } from 'fs';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname, join } from 'path';
5
+
6
+ const __filename = fileURLToPath(import.meta.url);
7
+ const __dirname = dirname(__filename);
8
+
9
+ // Load environment variables from .env file silently without dotenv
10
+ try {
11
+ const envPath = join(__dirname, '../../../.env');
12
+ const envContent = readFileSync(envPath, 'utf8');
13
+ const envLines = envContent.split('\n');
14
+
15
+ for (const line of envLines) {
16
+ const trimmedLine = line.trim();
17
+ if (trimmedLine && !trimmedLine.startsWith('#')) {
18
+ const [key, ...valueParts] = trimmedLine.split('=');
19
+ if (key && valueParts.length > 0) {
20
+ const value = valueParts.join('=').replace(/^["']|["']$/g, '');
21
+ process.env[key] = value;
22
+ }
23
+ }
24
+ }
25
+ } catch (error) {
26
+ // Silently ignore if .env file doesn't exist
27
+ }
28
+
29
+ // Configure API endpoints
30
+ const MOORCHEH_API_KEY = process.env.MOORCHEH_API_KEY;
31
+
32
+ if (!MOORCHEH_API_KEY) {
33
+ console.error('Missing required API_KEY environment variable');
34
+ console.error('Please create a .env file in this directory with: MOORCHEH_API_KEY=your_actual_api_key');
35
+ process.exit(1);
36
+ }
37
+
38
+ // Debug: Check if API key looks valid (don't log the full key for security)
39
+ if (MOORCHEH_API_KEY === 'your_api_key_here' || MOORCHEH_API_KEY.length < 10) {
40
+ console.error('Warning: API_KEY appears to be invalid or placeholder');
41
+ console.error('Please check your .env file and ensure you have a valid Moorcheh API key');
42
+ }
43
+
44
+ // Construct API URLs using the simplified format
45
+ const constructApiUrl = (endpoint) => {
46
+ return `https://api.moorcheh.ai/v1${endpoint}`;
47
+ };
48
+
49
+ const API_ENDPOINTS = {
50
+ namespaces: constructApiUrl('/namespaces'),
51
+ search: constructApiUrl('/search'),
52
+ answer: constructApiUrl('/answer'),
53
+ };
54
+
55
+ // Helper function to make API requests
56
+ async function makeApiRequest(method, url, data = null) {
57
+ try {
58
+ const config = {
59
+ method,
60
+ url,
61
+ headers: {
62
+ 'x-api-key': MOORCHEH_API_KEY,
63
+ 'Content-Type': 'application/json',
64
+ },
65
+ };
66
+
67
+ if (data) {
68
+ config.data = data;
69
+ }
70
+
71
+ const response = await axios(config);
72
+ return response.data;
73
+ } catch (error) {
74
+ if (error.response) {
75
+ const status = error.response.status;
76
+ const data = error.response.data;
77
+
78
+ if (status === 403) {
79
+ throw new Error(`Forbidden: Check your API key. Status: ${status}, Response: ${JSON.stringify(data)}`);
80
+ } else if (status === 401) {
81
+ throw new Error(`Unauthorized: Invalid API key. Status: ${status}, Response: ${JSON.stringify(data)}`);
82
+ } else {
83
+ throw new Error(`API Error (${status}): ${JSON.stringify(data)}`);
84
+ }
85
+ }
86
+ throw new Error(`Network Error: ${error.message}`);
87
+ }
88
+ }
89
+
90
+ export { API_ENDPOINTS, makeApiRequest, MOORCHEH_API_KEY };
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
+
6
+ // Import tools
7
+ import { listNamespacesTool, createNamespaceTool, deleteNamespaceTool } from './tools/namespace-tools.js';
8
+ import { uploadTextTool, uploadVectorsTool, deleteDataTool, getDataTool } from './tools/data-tools.js';
9
+ import { searchTool, answerTool } from './tools/search-tools.js';
10
+
11
+ // Import resources
12
+ import {
13
+ namespacesResource,
14
+ namespaceDetailsResource,
15
+ apiDocsResource,
16
+ configHelpResource,
17
+ namespaceCreationGuideResource,
18
+ searchOptimizationGuideResource,
19
+ dataOrganizationGuideResource,
20
+ aiAnswerSetupGuideResource
21
+ } from './utils/resources.js';
22
+
23
+ // Import prompts
24
+ import {
25
+ searchOptimizationPrompt,
26
+ dataOrganizationPrompt,
27
+ aiAnswerSetupPrompt
28
+ } from './utils/prompts.js';
29
+
30
+ // Suppress stdout to prevent any non-MCP output
31
+ const originalStdoutWrite = process.stdout.write;
32
+ process.stdout.write = (chunk, encoding, callback) => {
33
+ // Only allow JSON-RPC messages to stdout
34
+ if (typeof chunk === 'string' && (chunk.trim().startsWith('{') || chunk.trim().startsWith('['))) {
35
+ return originalStdoutWrite.call(process.stdout, chunk, encoding, callback);
36
+ }
37
+ // Redirect everything else to stderr
38
+ process.stderr.write(chunk, encoding, callback);
39
+ };
40
+
41
+ // Create server instance
42
+ const server = new McpServer({
43
+ name: "Moorcheh",
44
+ version: "1.0.0",
45
+ });
46
+
47
+ // ========== REGISTER RESOURCES ==========
48
+
49
+ // Register all resources
50
+ server.resource(
51
+ namespacesResource.uri,
52
+ namespacesResource.description,
53
+ namespacesResource.mimeType,
54
+ namespacesResource.handler
55
+ );
56
+
57
+ server.resource(
58
+ namespaceDetailsResource.uri,
59
+ namespaceDetailsResource.description,
60
+ namespaceDetailsResource.mimeType,
61
+ namespaceDetailsResource.handler
62
+ );
63
+
64
+ server.resource(
65
+ apiDocsResource.uri,
66
+ apiDocsResource.description,
67
+ apiDocsResource.mimeType,
68
+ apiDocsResource.handler
69
+ );
70
+
71
+ server.resource(
72
+ configHelpResource.uri,
73
+ configHelpResource.description,
74
+ configHelpResource.mimeType,
75
+ configHelpResource.handler
76
+ );
77
+
78
+ server.resource(
79
+ namespaceCreationGuideResource.uri,
80
+ namespaceCreationGuideResource.description,
81
+ namespaceCreationGuideResource.mimeType,
82
+ namespaceCreationGuideResource.handler
83
+ );
84
+
85
+ server.resource(
86
+ searchOptimizationGuideResource.uri,
87
+ searchOptimizationGuideResource.description,
88
+ searchOptimizationGuideResource.mimeType,
89
+ searchOptimizationGuideResource.handler
90
+ );
91
+
92
+ server.resource(
93
+ dataOrganizationGuideResource.uri,
94
+ dataOrganizationGuideResource.description,
95
+ dataOrganizationGuideResource.mimeType,
96
+ dataOrganizationGuideResource.handler
97
+ );
98
+
99
+ server.resource(
100
+ aiAnswerSetupGuideResource.uri,
101
+ aiAnswerSetupGuideResource.description,
102
+ aiAnswerSetupGuideResource.mimeType,
103
+ aiAnswerSetupGuideResource.handler
104
+ );
105
+
106
+ // ========== REGISTER TOOLS ==========
107
+
108
+ // Register namespace tools
109
+ server.tool(
110
+ listNamespacesTool.name,
111
+ listNamespacesTool.description,
112
+ listNamespacesTool.parameters,
113
+ listNamespacesTool.handler,
114
+ );
115
+
116
+ server.tool(
117
+ createNamespaceTool.name,
118
+ createNamespaceTool.description,
119
+ createNamespaceTool.parameters,
120
+ createNamespaceTool.handler,
121
+ );
122
+
123
+ server.tool(
124
+ deleteNamespaceTool.name,
125
+ deleteNamespaceTool.description,
126
+ deleteNamespaceTool.parameters,
127
+ deleteNamespaceTool.handler,
128
+ );
129
+
130
+ // Register data tools
131
+ server.tool(
132
+ uploadTextTool.name,
133
+ uploadTextTool.description,
134
+ uploadTextTool.parameters,
135
+ uploadTextTool.handler,
136
+ );
137
+
138
+ server.tool(
139
+ uploadVectorsTool.name,
140
+ uploadVectorsTool.description,
141
+ uploadVectorsTool.parameters,
142
+ uploadVectorsTool.handler,
143
+ );
144
+
145
+ server.tool(
146
+ deleteDataTool.name,
147
+ deleteDataTool.description,
148
+ deleteDataTool.parameters,
149
+ deleteDataTool.handler,
150
+ );
151
+
152
+ server.tool(
153
+ getDataTool.name,
154
+ getDataTool.description,
155
+ getDataTool.parameters,
156
+ getDataTool.handler,
157
+ );
158
+
159
+ // Register search tools
160
+ server.tool(
161
+ searchTool.name,
162
+ searchTool.description,
163
+ searchTool.parameters,
164
+ searchTool.handler,
165
+ );
166
+
167
+ server.tool(
168
+ answerTool.name,
169
+ answerTool.description,
170
+ answerTool.parameters,
171
+ answerTool.handler,
172
+ );
173
+
174
+ // ========== REGISTER PROMPTS ==========
175
+
176
+ // Register search optimization prompt (new SDK signature)
177
+ server.registerPrompt(
178
+ searchOptimizationPrompt.name,
179
+ {
180
+ title: 'Search Optimization',
181
+ description: searchOptimizationPrompt.description,
182
+ argsSchema: searchOptimizationPrompt.argsSchema,
183
+ },
184
+ async (args) => searchOptimizationPrompt.handler(args)
185
+ );
186
+
187
+ // Register data organization prompt
188
+ server.registerPrompt(
189
+ dataOrganizationPrompt.name,
190
+ {
191
+ title: 'Data Organization',
192
+ description: dataOrganizationPrompt.description,
193
+ argsSchema: dataOrganizationPrompt.argsSchema,
194
+ },
195
+ async (args) => dataOrganizationPrompt.handler(args)
196
+ );
197
+
198
+ // Register AI answer setup prompt
199
+ server.registerPrompt(
200
+ aiAnswerSetupPrompt.name,
201
+ {
202
+ title: 'AI Answer Setup',
203
+ description: aiAnswerSetupPrompt.description,
204
+ argsSchema: aiAnswerSetupPrompt.argsSchema,
205
+ },
206
+ async (args) => aiAnswerSetupPrompt.handler(args)
207
+ );
208
+
209
+ // Start the server
210
+ async function main() {
211
+ const transport = new StdioServerTransport();
212
+ await server.connect(transport);
213
+ console.error("Server started");
214
+ }
215
+
216
+ main().catch((error) => {
217
+ console.error("Fatal error in main():", error);
218
+ process.exit(1);
219
+ });