@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.
- package/LICENSE +201 -0
- package/README.md +315 -0
- package/assets/moorcheh-logo-dark.svg +157 -0
- package/assets/moorcheh-logo-light.svg +157 -0
- package/bin/cli.js +76 -0
- package/env.example +2 -0
- package/package.json +68 -0
- package/src/client/mcp.json +11 -0
- package/src/server/config/api.js +90 -0
- package/src/server/index.js +219 -0
- package/src/server/tools/data-tools.js +158 -0
- package/src/server/tools/namespace-tools.js +130 -0
- package/src/server/tools/search-tools.js +230 -0
- package/src/server/utils/completable.js +77 -0
- package/src/server/utils/prompts.js +359 -0
- package/src/server/utils/resources.js +360 -0
- package/src/test/test-mcp.js +154 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// Search optimization prompt
|
|
4
|
+
export const searchOptimizationPrompt = {
|
|
5
|
+
name: 'search-optimization',
|
|
6
|
+
description: 'Tips for optimizing search queries in Moorcheh',
|
|
7
|
+
argsSchema: {
|
|
8
|
+
search_type: z.enum(['text','vector']).optional().describe('Type of search (text or vector)'),
|
|
9
|
+
domain: z.string().optional().describe('Domain or topic area of your content')
|
|
10
|
+
},
|
|
11
|
+
handler: async (args) => {
|
|
12
|
+
const searchType = args?.search_type || 'text';
|
|
13
|
+
const domain = args?.domain || 'general';
|
|
14
|
+
|
|
15
|
+
const text = `# Moorcheh Search Optimization Guide
|
|
16
|
+
|
|
17
|
+
## Optimizing ${searchType} search for ${domain} content
|
|
18
|
+
|
|
19
|
+
### Request Format Examples:
|
|
20
|
+
|
|
21
|
+
**Text Search Request:**
|
|
22
|
+
\`\`\`json
|
|
23
|
+
{
|
|
24
|
+
"query": "your search text here",
|
|
25
|
+
"namespaces": ["your-namespace"],
|
|
26
|
+
"top_k": 10,
|
|
27
|
+
"kiosk_mode": false
|
|
28
|
+
}
|
|
29
|
+
\`\`\`
|
|
30
|
+
|
|
31
|
+
**Vector Search Request:**
|
|
32
|
+
\`\`\`json
|
|
33
|
+
{
|
|
34
|
+
"query": [0.1, 0.2, 0.3, ..., 0.768],
|
|
35
|
+
"namespaces": ["vector-embeddings"],
|
|
36
|
+
"top_k": 5,
|
|
37
|
+
"kiosk_mode": true,
|
|
38
|
+
"threshold": 0.1
|
|
39
|
+
}
|
|
40
|
+
\`\`\`
|
|
41
|
+
|
|
42
|
+
**cURL Example for Vector Search:**
|
|
43
|
+
\`\`\`bash
|
|
44
|
+
curl -X POST "https://api.moorcheh.ai/v1/search" \\
|
|
45
|
+
-H "Content-Type: application/json" \\
|
|
46
|
+
-H "x-api-Key: your-api-key-here" \\
|
|
47
|
+
-d '{
|
|
48
|
+
"query": [0.1, 0.2, 0.3, ..., 0.768],
|
|
49
|
+
"namespaces": ["vector-embeddings"],
|
|
50
|
+
"top_k": 5,
|
|
51
|
+
"kiosk_mode": true,
|
|
52
|
+
"threshold": 0.1
|
|
53
|
+
}'
|
|
54
|
+
\`\`\`
|
|
55
|
+
|
|
56
|
+
### Search Strategy:
|
|
57
|
+
|
|
58
|
+
${searchType === 'text' ? `
|
|
59
|
+
**Text Search Best Practices:**
|
|
60
|
+
- Use specific, descriptive terms rather than generic ones
|
|
61
|
+
- Include key domain terminology from your ${domain} field
|
|
62
|
+
- Try both short keywords and longer phrases
|
|
63
|
+
- Use synonyms if initial searches don't return good results
|
|
64
|
+
- Natural language queries work well for semantic search
|
|
65
|
+
|
|
66
|
+
**Query Examples:**
|
|
67
|
+
- Instead of: "help"
|
|
68
|
+
- Try: "troubleshooting guide", "how to resolve", "step by step"
|
|
69
|
+
- Use complete sentences: "How do I configure authentication?"
|
|
70
|
+
- Include context: "Python authentication setup for web applications"
|
|
71
|
+
` : `
|
|
72
|
+
**Vector Search Best Practices:**
|
|
73
|
+
- Ensure your query embeddings use the same model as your stored vectors
|
|
74
|
+
- Vector search works well with semantic similarity
|
|
75
|
+
- Natural language queries often work better than keywords
|
|
76
|
+
- Consider the context and intent behind your search
|
|
77
|
+
- Match vector dimensions with your namespace configuration
|
|
78
|
+
|
|
79
|
+
**Query Optimization:**
|
|
80
|
+
- Use complete sentences or questions for better semantic matching
|
|
81
|
+
- Include relevant context in your query
|
|
82
|
+
- Test with variations of the same concept
|
|
83
|
+
- Ensure vector dimensions match your namespace (e.g., 768 for many models)
|
|
84
|
+
`}
|
|
85
|
+
|
|
86
|
+
### Parameter Tuning:
|
|
87
|
+
|
|
88
|
+
1. **top_k**: Number of results to return (default: 10)
|
|
89
|
+
- Start with 5-10 for most use cases
|
|
90
|
+
- Increase for broader exploration
|
|
91
|
+
- Decrease for highly targeted results
|
|
92
|
+
|
|
93
|
+
2. **threshold**: Similarity threshold (0-1, optional)
|
|
94
|
+
- 0.7-0.8: High similarity, fewer but more relevant results
|
|
95
|
+
- 0.5-0.7: Moderate similarity, balanced results
|
|
96
|
+
- 0.3-0.5: Lower similarity, more comprehensive results
|
|
97
|
+
- **Important**: When kiosk_mode is true, threshold becomes mandatory
|
|
98
|
+
|
|
99
|
+
3. **kiosk_mode**: Boolean (default: false)
|
|
100
|
+
- true: Restrict search to specific namespace(s) with threshold filtering
|
|
101
|
+
- false: Search across all specified namespaces
|
|
102
|
+
- **Note**: When kiosk_mode is enabled, threshold parameter is required
|
|
103
|
+
|
|
104
|
+
### Kiosk Mode Requirements:
|
|
105
|
+
|
|
106
|
+
When using kiosk_mode=true:
|
|
107
|
+
- **threshold parameter is mandatory**
|
|
108
|
+
- Results are filtered by the specified threshold
|
|
109
|
+
- Useful for production environments with strict relevance requirements
|
|
110
|
+
- Example: kiosk_mode=true with threshold=0.7 ensures only high-confidence results
|
|
111
|
+
|
|
112
|
+
### Domain-Specific Tips for ${domain}:
|
|
113
|
+
- Use terminology specific to ${domain}
|
|
114
|
+
- Consider the typical language patterns in your content
|
|
115
|
+
- Test with actual user queries from your ${domain} context
|
|
116
|
+
- Monitor search performance and adjust parameters accordingly
|
|
117
|
+
- For technical content, include specific technology names and versions
|
|
118
|
+
|
|
119
|
+
### Troubleshooting:
|
|
120
|
+
- If no results: Lower threshold, check spelling, try synonyms
|
|
121
|
+
- If too many irrelevant results: Raise threshold, use more specific terms
|
|
122
|
+
- If results seem random: Check your embeddings model compatibility
|
|
123
|
+
- For vector search: Verify vector dimensions match namespace configuration
|
|
124
|
+
- For kiosk mode: Ensure threshold is provided when kiosk_mode=true
|
|
125
|
+
|
|
126
|
+
### Response Format:
|
|
127
|
+
The search returns results with:
|
|
128
|
+
- **id**: Document identifier
|
|
129
|
+
- **score**: Similarity score (0-1, higher is better)
|
|
130
|
+
- **label**: Relevance label (Close Match, Very High Relevance, etc.)
|
|
131
|
+
- **text**: Original text content (for text namespaces)
|
|
132
|
+
- **metadata**: Associated metadata
|
|
133
|
+
`;
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
messages: [
|
|
137
|
+
{
|
|
138
|
+
role: 'assistant',
|
|
139
|
+
content: { type: 'text', text }
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Data organization prompt
|
|
147
|
+
export const dataOrganizationPrompt = {
|
|
148
|
+
name: 'data-organization',
|
|
149
|
+
description: 'Best practices for organizing data in Moorcheh namespaces',
|
|
150
|
+
argsSchema: {
|
|
151
|
+
content_type: z.string().optional().describe("Type of content you're organizing"),
|
|
152
|
+
team_size: z.enum(['small','large']).optional().describe('Size of your team using this data')
|
|
153
|
+
},
|
|
154
|
+
handler: async (args) => {
|
|
155
|
+
const contentType = args?.content_type || 'documents';
|
|
156
|
+
const teamSize = args?.team_size || 'small';
|
|
157
|
+
|
|
158
|
+
const text = `# Moorcheh Data Organization Guide
|
|
159
|
+
|
|
160
|
+
## Organizing ${contentType} for a ${teamSize} team
|
|
161
|
+
|
|
162
|
+
### Namespace Strategy:
|
|
163
|
+
|
|
164
|
+
${teamSize === 'large' ? `
|
|
165
|
+
**Large Team Considerations:**
|
|
166
|
+
- Create separate namespaces by department or project
|
|
167
|
+
- Use consistent naming conventions across teams
|
|
168
|
+
- Implement clear metadata standards
|
|
169
|
+
- Consider access control and permissions
|
|
170
|
+
` : `
|
|
171
|
+
**Small Team Approach:**
|
|
172
|
+
- Fewer namespaces with more content per namespace
|
|
173
|
+
- Flexible organization that can evolve
|
|
174
|
+
- Focus on clear naming and good metadata
|
|
175
|
+
- Regular cleanup and maintenance
|
|
176
|
+
`}
|
|
177
|
+
|
|
178
|
+
### Content Organization for ${contentType}:
|
|
179
|
+
|
|
180
|
+
1. **Metadata Schema:**
|
|
181
|
+
\`\`\`json
|
|
182
|
+
{
|
|
183
|
+
"category": "primary classification",
|
|
184
|
+
"tags": ["tag1", "tag2", "tag3"],
|
|
185
|
+
"author": "content creator",
|
|
186
|
+
"created_date": "2024-01-01",
|
|
187
|
+
"department": "relevant team",
|
|
188
|
+
"priority": "high/medium/low",
|
|
189
|
+
"status": "draft/review/published"
|
|
190
|
+
}
|
|
191
|
+
\`\`\`
|
|
192
|
+
|
|
193
|
+
2. **Document ID Conventions:**
|
|
194
|
+
- Use descriptive, hierarchical IDs
|
|
195
|
+
- Include date/version when relevant
|
|
196
|
+
- Examples: "support-faq-login-2024", "product-spec-v2-auth"
|
|
197
|
+
|
|
198
|
+
3. **Content Chunking:**
|
|
199
|
+
- Break large documents into logical sections
|
|
200
|
+
- Each chunk should be self-contained
|
|
201
|
+
- Include context in metadata
|
|
202
|
+
|
|
203
|
+
### Maintenance Workflow:
|
|
204
|
+
|
|
205
|
+
1. **Regular Reviews:**
|
|
206
|
+
- Monthly metadata cleanup
|
|
207
|
+
- Remove outdated content
|
|
208
|
+
- Update tags and categories
|
|
209
|
+
|
|
210
|
+
2. **Quality Control:**
|
|
211
|
+
- Standardize formatting before upload
|
|
212
|
+
- Validate metadata completeness
|
|
213
|
+
- Test search functionality after major updates
|
|
214
|
+
|
|
215
|
+
3. **Growth Planning:**
|
|
216
|
+
- Monitor namespace size and performance
|
|
217
|
+
- Plan for content archival strategy
|
|
218
|
+
- Consider splitting namespaces as they grow
|
|
219
|
+
|
|
220
|
+
### Search-Friendly Organization:
|
|
221
|
+
- Use consistent terminology in your ${contentType}
|
|
222
|
+
- Include alternative phrasings in metadata
|
|
223
|
+
- Create logical content hierarchies
|
|
224
|
+
- Tag content with multiple relevant categories
|
|
225
|
+
|
|
226
|
+
This organization will help your ${teamSize} team efficiently manage and search through your ${contentType}.
|
|
227
|
+
`;
|
|
228
|
+
|
|
229
|
+
return {
|
|
230
|
+
messages: [
|
|
231
|
+
{
|
|
232
|
+
role: 'assistant',
|
|
233
|
+
content: { type: 'text', text }
|
|
234
|
+
}
|
|
235
|
+
]
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// AI answer setup prompt
|
|
241
|
+
export const aiAnswerSetupPrompt = {
|
|
242
|
+
name: 'ai-answer-setup',
|
|
243
|
+
description: 'Guide for configuring AI-powered answers in Moorcheh',
|
|
244
|
+
argsSchema: {
|
|
245
|
+
answer_style: z.enum(['concise','detailed','technical','friendly','balanced']).optional().describe('Desired style for AI answers'),
|
|
246
|
+
context_type: z.string().optional().describe('Type of context/domain for answers')
|
|
247
|
+
},
|
|
248
|
+
handler: async (args) => {
|
|
249
|
+
const answerStyle = args?.answer_style || 'balanced';
|
|
250
|
+
const contextType = args?.context_type || 'general';
|
|
251
|
+
|
|
252
|
+
const text = `# Moorcheh AI Answer Configuration Guide
|
|
253
|
+
|
|
254
|
+
## Setting up ${answerStyle} AI answers for ${contextType} content
|
|
255
|
+
|
|
256
|
+
### Header Prompt Configuration:
|
|
257
|
+
|
|
258
|
+
\`\`\`
|
|
259
|
+
You are an AI assistant specialized in ${contextType}.
|
|
260
|
+
Your role is to provide ${answerStyle} answers based on the provided context.
|
|
261
|
+
|
|
262
|
+
Style Guidelines:
|
|
263
|
+
${answerStyle === 'concise' ? `
|
|
264
|
+
- Keep answers brief and to the point
|
|
265
|
+
- Use bullet points for multiple items
|
|
266
|
+
- Avoid unnecessary explanations
|
|
267
|
+
- Focus on actionable information
|
|
268
|
+
` : answerStyle === 'detailed' ? `
|
|
269
|
+
- Provide comprehensive explanations
|
|
270
|
+
- Include relevant background information
|
|
271
|
+
- Use examples where helpful
|
|
272
|
+
- Structure answers with clear sections
|
|
273
|
+
` : answerStyle === 'technical' ? `
|
|
274
|
+
- Use precise technical terminology
|
|
275
|
+
- Include code examples when relevant
|
|
276
|
+
- Explain complex concepts step-by-step
|
|
277
|
+
- Reference specific technical details
|
|
278
|
+
` : answerStyle === 'friendly' ? `
|
|
279
|
+
- Use conversational, approachable language
|
|
280
|
+
- Include encouraging phrases
|
|
281
|
+
- Explain concepts in simple terms
|
|
282
|
+
- Ask clarifying questions when needed
|
|
283
|
+
` : `
|
|
284
|
+
- Balance brevity with completeness
|
|
285
|
+
- Use clear, professional language
|
|
286
|
+
- Structure information logically
|
|
287
|
+
- Include key details without overwhelming
|
|
288
|
+
`}
|
|
289
|
+
|
|
290
|
+
Context: You have access to ${contextType} documentation and resources.
|
|
291
|
+
\`\`\`
|
|
292
|
+
|
|
293
|
+
### Footer Prompt Configuration:
|
|
294
|
+
|
|
295
|
+
\`\`\`
|
|
296
|
+
Additional Guidelines:
|
|
297
|
+
- Always cite specific sources when possible
|
|
298
|
+
- If information is incomplete, acknowledge limitations
|
|
299
|
+
- Suggest follow-up questions for complex topics
|
|
300
|
+
- ${contextType === 'technical' ? 'Include relevant code snippets or examples' : 'Provide practical next steps'}
|
|
301
|
+
|
|
302
|
+
Response Format:
|
|
303
|
+
- Start with a direct answer to the question
|
|
304
|
+
- Support with relevant context from the knowledge base
|
|
305
|
+
- End with helpful next steps or related information
|
|
306
|
+
\`\`\`
|
|
307
|
+
|
|
308
|
+
### Parameter Recommendations:
|
|
309
|
+
|
|
310
|
+
1. **Temperature**:
|
|
311
|
+
${answerStyle === 'technical' ? '0.3-0.5 (more precise, less creative)' : answerStyle === 'friendly' ? '0.7-0.9 (more conversational)' : '0.5-0.7 (balanced)'}
|
|
312
|
+
|
|
313
|
+
2. **top_k**:
|
|
314
|
+
- 3-5 for focused answers
|
|
315
|
+
- 5-8 for comprehensive responses
|
|
316
|
+
- 8-10 for exploratory questions
|
|
317
|
+
|
|
318
|
+
3. **threshold**:
|
|
319
|
+
- 0.7+ for high confidence answers
|
|
320
|
+
- 0.5-0.7 for broader context inclusion
|
|
321
|
+
|
|
322
|
+
### Chat History Usage:
|
|
323
|
+
|
|
324
|
+
Include previous conversation context to:
|
|
325
|
+
- Maintain conversation flow
|
|
326
|
+
- Reference previous questions
|
|
327
|
+
- Build on established context
|
|
328
|
+
- Avoid repeating information
|
|
329
|
+
|
|
330
|
+
### Example Usage:
|
|
331
|
+
|
|
332
|
+
\`\`\`javascript
|
|
333
|
+
{
|
|
334
|
+
"namespace": "your-namespace",
|
|
335
|
+
"query": "How do I configure authentication?",
|
|
336
|
+
"headerPrompt": "You are a technical assistant...",
|
|
337
|
+
"footerPrompt": "Always include code examples...",
|
|
338
|
+
"temperature": 0.5,
|
|
339
|
+
"top_k": 5,
|
|
340
|
+
"chatHistory": [
|
|
341
|
+
{"role": "user", "content": "Previous question..."},
|
|
342
|
+
{"role": "assistant", "content": "Previous answer..."}
|
|
343
|
+
]
|
|
344
|
+
}
|
|
345
|
+
\`\`\`
|
|
346
|
+
|
|
347
|
+
This configuration will provide ${answerStyle} answers tailored to your ${contextType} use case.
|
|
348
|
+
`;
|
|
349
|
+
|
|
350
|
+
return {
|
|
351
|
+
messages: [
|
|
352
|
+
{
|
|
353
|
+
role: 'assistant',
|
|
354
|
+
content: { type: 'text', text }
|
|
355
|
+
}
|
|
356
|
+
]
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
};
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { makeApiRequest, API_ENDPOINTS } from '../config/api.js';
|
|
2
|
+
|
|
3
|
+
// Resource for namespace listing
|
|
4
|
+
export const namespacesResource = {
|
|
5
|
+
uri: "moorcheh://docs/namespaces",
|
|
6
|
+
description: "List of all Moorcheh namespaces",
|
|
7
|
+
mimeType: "application/json",
|
|
8
|
+
handler: async () => {
|
|
9
|
+
try {
|
|
10
|
+
const data = await makeApiRequest('GET', API_ENDPOINTS.namespaces);
|
|
11
|
+
return JSON.stringify(data, null, 2);
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return JSON.stringify({ error: error.message }, null, 2);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Resource for namespace details
|
|
19
|
+
export const namespaceDetailsResource = {
|
|
20
|
+
uri: "moorcheh://namespace/{namespace_name}",
|
|
21
|
+
description: "Details of a specific Moorcheh namespace",
|
|
22
|
+
mimeType: "application/json",
|
|
23
|
+
handler: async (uri) => {
|
|
24
|
+
try {
|
|
25
|
+
const namespaceName = uri.split('/').pop();
|
|
26
|
+
const data = await makeApiRequest('GET', `${API_ENDPOINTS.namespaces}/${namespaceName}`);
|
|
27
|
+
return JSON.stringify(data, null, 2);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
return JSON.stringify({ error: error.message }, null, 2);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Resource for API documentation
|
|
35
|
+
export const apiDocsResource = {
|
|
36
|
+
uri: "moorcheh://docs/api",
|
|
37
|
+
description: "Moorcheh API documentation and endpoints",
|
|
38
|
+
mimeType: "text/markdown",
|
|
39
|
+
handler: async () => {
|
|
40
|
+
return `# Moorcheh API Documentation
|
|
41
|
+
|
|
42
|
+
## Base URL
|
|
43
|
+
\`https://api.moorcheh.ai/v1\`
|
|
44
|
+
|
|
45
|
+
## Authentication
|
|
46
|
+
All requests require an API key in the \`x-api-key\` header.
|
|
47
|
+
|
|
48
|
+
## Endpoints
|
|
49
|
+
|
|
50
|
+
### Namespaces
|
|
51
|
+
- **GET** \`/namespaces\` - List all namespaces
|
|
52
|
+
- **POST** \`/namespaces\` - Create new namespace
|
|
53
|
+
- **DELETE** \`/namespaces/{name}\` - Delete namespace
|
|
54
|
+
- **GET** \`/namespaces/{name}\` - Get namespace details
|
|
55
|
+
|
|
56
|
+
### Documents
|
|
57
|
+
- **POST** \`/namespaces/{name}/documents\` - Upload text documents
|
|
58
|
+
- **POST** \`/namespaces/{name}/vectors\` - Upload vector data
|
|
59
|
+
- **POST** \`/namespaces/{name}/documents/delete\` - Delete specific documents
|
|
60
|
+
|
|
61
|
+
### Search & AI
|
|
62
|
+
- **POST** \`/search\` - Search across namespaces
|
|
63
|
+
- **POST** \`/answer\` - Get AI-generated answers
|
|
64
|
+
|
|
65
|
+
## Rate Limits
|
|
66
|
+
API requests are subject to rate limiting based on your subscription tier.
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// Resource for configuration help
|
|
72
|
+
export const configHelpResource = {
|
|
73
|
+
uri: "moorcheh://config/help",
|
|
74
|
+
description: "Configuration help and troubleshooting guide",
|
|
75
|
+
mimeType: "text/markdown",
|
|
76
|
+
handler: async () => {
|
|
77
|
+
return `# Moorcheh Configuration Help
|
|
78
|
+
|
|
79
|
+
## Environment Variables Required
|
|
80
|
+
|
|
81
|
+
Create a \`.env\` file in the same directory as this script with:
|
|
82
|
+
|
|
83
|
+
\`\`\`
|
|
84
|
+
MOORCHEH_API_KEY=your_moorcheh_api_key
|
|
85
|
+
\`\`\`
|
|
86
|
+
|
|
87
|
+
## Troubleshooting
|
|
88
|
+
|
|
89
|
+
### Common Issues
|
|
90
|
+
|
|
91
|
+
1. **403 Forbidden Error**
|
|
92
|
+
- Check your API key is correct
|
|
93
|
+
- Ensure your API key has proper permissions
|
|
94
|
+
|
|
95
|
+
2. **401 Unauthorized Error**
|
|
96
|
+
- Your API key may be invalid or expired
|
|
97
|
+
- Contact support to regenerate your key
|
|
98
|
+
|
|
99
|
+
3. **Network Errors**
|
|
100
|
+
- Check your internet connection
|
|
101
|
+
- Verify the API endpoint is correct
|
|
102
|
+
|
|
103
|
+
### Getting Help
|
|
104
|
+
|
|
105
|
+
For additional support, check:
|
|
106
|
+
- Moorcheh documentation
|
|
107
|
+
- API status page
|
|
108
|
+
- Contact support with your error details
|
|
109
|
+
`;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// Resource for namespace creation guidance
|
|
114
|
+
export const namespaceCreationGuideResource = {
|
|
115
|
+
uri: "moorcheh://guides/namespace-creation",
|
|
116
|
+
description: "Step-by-step guide for creating a new Moorcheh namespace, with best practices",
|
|
117
|
+
mimeType: "text/markdown",
|
|
118
|
+
handler: async () => {
|
|
119
|
+
return `# Moorcheh Namespace Creation Guide
|
|
120
|
+
|
|
121
|
+
## Step-by-step process:
|
|
122
|
+
|
|
123
|
+
1. **Choose a descriptive name** for your namespace
|
|
124
|
+
- Use lowercase letters, numbers, and hyphens
|
|
125
|
+
- Make it descriptive of your content
|
|
126
|
+
- Example: "customer-docs", "product-vectors", "help-articles"
|
|
127
|
+
|
|
128
|
+
2. **Determine the namespace type:**
|
|
129
|
+
- **Text namespace** for storing and searching text documents
|
|
130
|
+
- Ideal for documentation, articles, customer support content
|
|
131
|
+
- Full-text search capabilities included
|
|
132
|
+
- **Vector namespace** for semantic search and AI applications
|
|
133
|
+
- You'll need to specify vector dimensions (commonly 384, 768, or 1536)
|
|
134
|
+
- Compatible with embeddings from OpenAI, Sentence Transformers, etc.
|
|
135
|
+
|
|
136
|
+
3. **Use the create-namespace tool:**
|
|
137
|
+
\`\`\`
|
|
138
|
+
namespace_name: your-chosen-name
|
|
139
|
+
type: text # or vector
|
|
140
|
+
vector_dimension: 384 # only for vector namespaces
|
|
141
|
+
\`\`\`
|
|
142
|
+
|
|
143
|
+
## Best Practices:
|
|
144
|
+
- Start with a small test namespace to familiarize yourself
|
|
145
|
+
- Plan your document structure and metadata beforehand
|
|
146
|
+
- Consider how you'll organize and tag your content
|
|
147
|
+
- Test search functionality with sample data
|
|
148
|
+
|
|
149
|
+
## Next Steps:
|
|
150
|
+
After creating your namespace, you can:
|
|
151
|
+
- Upload documents using the upload-text tool
|
|
152
|
+
- Upload vector embeddings using upload-vectors tool (for vector namespaces)
|
|
153
|
+
- Search your content using the search tool
|
|
154
|
+
- Get AI-powered answers using the answer tool
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
// Resource for search optimization guidance
|
|
160
|
+
export const searchOptimizationGuideResource = {
|
|
161
|
+
uri: "moorcheh://guides/search-optimization",
|
|
162
|
+
description: "Tips for optimizing search queries in Moorcheh",
|
|
163
|
+
mimeType: "text/markdown",
|
|
164
|
+
handler: async () => {
|
|
165
|
+
return `# Moorcheh Search Optimization Guide
|
|
166
|
+
|
|
167
|
+
## General Search Strategy
|
|
168
|
+
|
|
169
|
+
### Text Search Best Practices:
|
|
170
|
+
- Use specific, descriptive terms rather than generic ones
|
|
171
|
+
- Include key domain terminology from your content field
|
|
172
|
+
- Try both short keywords and longer phrases
|
|
173
|
+
- Use synonyms if initial searches don't return good results
|
|
174
|
+
|
|
175
|
+
### Query Examples:
|
|
176
|
+
- Instead of: "help"
|
|
177
|
+
- Try: "troubleshooting guide", "how to resolve", "step by step"
|
|
178
|
+
|
|
179
|
+
### Vector Search Best Practices:
|
|
180
|
+
- Ensure your query embeddings use the same model as your stored vectors
|
|
181
|
+
- Vector search works well with semantic similarity
|
|
182
|
+
- Natural language queries often work better than keywords
|
|
183
|
+
- Consider the context and intent behind your search
|
|
184
|
+
|
|
185
|
+
### Query Optimization:
|
|
186
|
+
- Use complete sentences or questions for better semantic matching
|
|
187
|
+
- Include relevant context in your query
|
|
188
|
+
- Test with variations of the same concept
|
|
189
|
+
|
|
190
|
+
## Parameter Tuning:
|
|
191
|
+
|
|
192
|
+
1. **top_k**: Number of results to return
|
|
193
|
+
- Start with 5-10 for most use cases
|
|
194
|
+
- Increase for broader exploration
|
|
195
|
+
- Decrease for highly targeted results
|
|
196
|
+
|
|
197
|
+
2. **threshold**: Similarity threshold (0-1)
|
|
198
|
+
- 0.7-0.8: High similarity, fewer but more relevant results
|
|
199
|
+
- 0.5-0.7: Moderate similarity, balanced results
|
|
200
|
+
- 0.3-0.5: Lower similarity, more comprehensive results
|
|
201
|
+
|
|
202
|
+
## Troubleshooting:
|
|
203
|
+
- If no results: Lower threshold, check spelling, try synonyms
|
|
204
|
+
- If too many irrelevant results: Raise threshold, use more specific terms
|
|
205
|
+
- If results seem random: Check your embeddings model compatibility
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// Resource for data organization guidance
|
|
211
|
+
export const dataOrganizationGuideResource = {
|
|
212
|
+
uri: "moorcheh://guides/data-organization",
|
|
213
|
+
description: "Best practices for organizing data in Moorcheh namespaces",
|
|
214
|
+
mimeType: "text/markdown",
|
|
215
|
+
handler: async () => {
|
|
216
|
+
return `# Moorcheh Data Organization Guide
|
|
217
|
+
|
|
218
|
+
## Namespace Strategy
|
|
219
|
+
|
|
220
|
+
### Large Team Considerations:
|
|
221
|
+
- Create separate namespaces by department or project
|
|
222
|
+
- Use consistent naming conventions across teams
|
|
223
|
+
- Implement clear metadata standards
|
|
224
|
+
- Consider access control and permissions
|
|
225
|
+
|
|
226
|
+
### Small Team Approach:
|
|
227
|
+
- Fewer namespaces with more content per namespace
|
|
228
|
+
- Flexible organization that can evolve
|
|
229
|
+
- Focus on clear naming and good metadata
|
|
230
|
+
- Regular cleanup and maintenance
|
|
231
|
+
|
|
232
|
+
## Content Organization
|
|
233
|
+
|
|
234
|
+
1. **Metadata Schema:**
|
|
235
|
+
\`\`\`json
|
|
236
|
+
{
|
|
237
|
+
"category": "primary classification",
|
|
238
|
+
"tags": ["tag1", "tag2", "tag3"],
|
|
239
|
+
"author": "content creator",
|
|
240
|
+
"created_date": "2024-01-01",
|
|
241
|
+
"department": "relevant team",
|
|
242
|
+
"priority": "high/medium/low",
|
|
243
|
+
"status": "draft/review/published"
|
|
244
|
+
}
|
|
245
|
+
\`\`\`
|
|
246
|
+
|
|
247
|
+
2. **Document ID Conventions:**
|
|
248
|
+
- Use descriptive, hierarchical IDs
|
|
249
|
+
- Include date/version when relevant
|
|
250
|
+
- Examples: "support-faq-login-2024", "product-spec-v2-auth"
|
|
251
|
+
|
|
252
|
+
3. **Content Chunking:**
|
|
253
|
+
- Break large documents into logical sections
|
|
254
|
+
- Each chunk should be self-contained
|
|
255
|
+
- Include context in metadata
|
|
256
|
+
|
|
257
|
+
## Maintenance Workflow
|
|
258
|
+
|
|
259
|
+
1. **Regular Reviews:**
|
|
260
|
+
- Monthly metadata cleanup
|
|
261
|
+
- Remove outdated content
|
|
262
|
+
- Update tags and categories
|
|
263
|
+
|
|
264
|
+
2. **Quality Control:**
|
|
265
|
+
- Standardize formatting before upload
|
|
266
|
+
- Validate metadata completeness
|
|
267
|
+
- Test search functionality after major updates
|
|
268
|
+
|
|
269
|
+
3. **Growth Planning:**
|
|
270
|
+
- Monitor namespace size and performance
|
|
271
|
+
- Plan for content archival strategy
|
|
272
|
+
- Consider splitting namespaces as they grow
|
|
273
|
+
|
|
274
|
+
## Search-Friendly Organization
|
|
275
|
+
- Use consistent terminology in your content
|
|
276
|
+
- Include alternative phrasings in metadata
|
|
277
|
+
- Create logical content hierarchies
|
|
278
|
+
- Tag content with multiple relevant categories
|
|
279
|
+
`;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// Resource for AI answer configuration guidance
|
|
284
|
+
export const aiAnswerSetupGuideResource = {
|
|
285
|
+
uri: "moorcheh://guides/ai-answer-setup",
|
|
286
|
+
description: "Guide for configuring AI-powered answers in Moorcheh",
|
|
287
|
+
mimeType: "text/markdown",
|
|
288
|
+
handler: async () => {
|
|
289
|
+
return `# Moorcheh AI Answer Configuration Guide
|
|
290
|
+
|
|
291
|
+
## Header Prompt Configuration
|
|
292
|
+
|
|
293
|
+
\`\`\`
|
|
294
|
+
You are an AI assistant specialized in your domain.
|
|
295
|
+
Your role is to provide balanced answers based on the provided context.
|
|
296
|
+
|
|
297
|
+
Style Guidelines:
|
|
298
|
+
- Balance brevity with completeness
|
|
299
|
+
- Use clear, professional language
|
|
300
|
+
- Structure information logically
|
|
301
|
+
- Include key details without overwhelming
|
|
302
|
+
|
|
303
|
+
Context: You have access to documentation and resources.
|
|
304
|
+
\`\`\`
|
|
305
|
+
|
|
306
|
+
## Footer Prompt Configuration
|
|
307
|
+
|
|
308
|
+
\`\`\`
|
|
309
|
+
Additional Guidelines:
|
|
310
|
+
- Always cite specific sources when possible
|
|
311
|
+
- If information is incomplete, acknowledge limitations
|
|
312
|
+
- Suggest follow-up questions for complex topics
|
|
313
|
+
- Provide practical next steps
|
|
314
|
+
|
|
315
|
+
Response Format:
|
|
316
|
+
- Start with a direct answer to the question
|
|
317
|
+
- Support with relevant context from the knowledge base
|
|
318
|
+
- End with helpful next steps or related information
|
|
319
|
+
\`\`\`
|
|
320
|
+
|
|
321
|
+
## Parameter Recommendations
|
|
322
|
+
|
|
323
|
+
1. **Temperature**: 0.5-0.7 (balanced)
|
|
324
|
+
|
|
325
|
+
2. **top_k**:
|
|
326
|
+
- 3-5 for focused answers
|
|
327
|
+
- 5-8 for comprehensive responses
|
|
328
|
+
- 8-10 for exploratory questions
|
|
329
|
+
|
|
330
|
+
3. **threshold**:
|
|
331
|
+
- 0.7+ for high confidence answers
|
|
332
|
+
- 0.5-0.7 for broader context inclusion
|
|
333
|
+
|
|
334
|
+
## Chat History Usage
|
|
335
|
+
|
|
336
|
+
Include previous conversation context to:
|
|
337
|
+
- Maintain conversation flow
|
|
338
|
+
- Reference previous questions
|
|
339
|
+
- Build on established context
|
|
340
|
+
- Avoid repeating information
|
|
341
|
+
|
|
342
|
+
## Example Usage
|
|
343
|
+
|
|
344
|
+
\`\`\`javascript
|
|
345
|
+
{
|
|
346
|
+
"namespace": "your-namespace",
|
|
347
|
+
"query": "How do I configure authentication?",
|
|
348
|
+
"headerPrompt": "You are a technical assistant...",
|
|
349
|
+
"footerPrompt": "Always include code examples...",
|
|
350
|
+
"temperature": 0.5,
|
|
351
|
+
"top_k": 5,
|
|
352
|
+
"chatHistory": [
|
|
353
|
+
{"role": "user", "content": "Previous question..."},
|
|
354
|
+
{"role": "assistant", "content": "Previous answer..."}
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
\`\`\`
|
|
358
|
+
`;
|
|
359
|
+
}
|
|
360
|
+
};
|