brief-mcp 1.3.0 → 1.5.0
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/dist/index.js +44 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -41,26 +41,29 @@ class SupabaseClient {
|
|
|
41
41
|
'Content-Type': 'application/json'
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
async search(question) {
|
|
45
|
-
const response = await axios.post(`${EDGE_FUNCTIONS_URL}/search-context`, { question, match_count: 5, match_threshold: 0.3 }, { headers: this.headers });
|
|
44
|
+
async search(question, orgRef) {
|
|
45
|
+
const response = await axios.post(`${EDGE_FUNCTIONS_URL}/search-context`, { question, match_count: 5, match_threshold: 0.3, org_ref: orgRef }, { headers: this.headers });
|
|
46
46
|
return response.data;
|
|
47
47
|
}
|
|
48
|
-
async ingestDocument(content, title,
|
|
49
|
-
// First get user's org_id from a simple call
|
|
48
|
+
async ingestDocument(content, title, orgRef) {
|
|
50
49
|
const response = await axios.post(`${EDGE_FUNCTIONS_URL}/ingest-context`, {
|
|
51
50
|
content,
|
|
52
51
|
title: title || 'Untitled',
|
|
53
|
-
|
|
52
|
+
org_ref: orgRef,
|
|
54
53
|
source_type: 'mcp'
|
|
55
54
|
}, { headers: this.headers });
|
|
56
55
|
return response.data;
|
|
57
56
|
}
|
|
58
|
-
async listDocuments(limit = 20) {
|
|
59
|
-
|
|
57
|
+
async listDocuments(limit = 20, orgRef) {
|
|
58
|
+
let url = `${EDGE_FUNCTIONS_URL}/list-documents?limit=${limit}`;
|
|
59
|
+
if (orgRef) {
|
|
60
|
+
url += `&org_ref=${encodeURIComponent(orgRef)}`;
|
|
61
|
+
}
|
|
62
|
+
const response = await axios.get(url, { headers: this.headers });
|
|
60
63
|
return response.data;
|
|
61
64
|
}
|
|
62
|
-
async deleteDocument(documentId) {
|
|
63
|
-
const response = await axios.post(`${EDGE_FUNCTIONS_URL}/delete-document`, { document_id: documentId }, { headers: this.headers });
|
|
65
|
+
async deleteDocument(documentId, orgRef) {
|
|
66
|
+
const response = await axios.post(`${EDGE_FUNCTIONS_URL}/delete-document`, { document_id: documentId, org_ref: orgRef }, { headers: this.headers });
|
|
64
67
|
return response.data;
|
|
65
68
|
}
|
|
66
69
|
async listOrganizations() {
|
|
@@ -87,13 +90,17 @@ async function startMCPServer() {
|
|
|
87
90
|
tools: [
|
|
88
91
|
{
|
|
89
92
|
name: 'search-context',
|
|
90
|
-
description: 'Search
|
|
93
|
+
description: 'Search a knowledge base and get AI-powered answers. IMPORTANT: Call list-organizations first to get org_ref values, then specify which organization to search. If no org_ref is provided, uses your default organization.',
|
|
91
94
|
inputSchema: {
|
|
92
95
|
type: 'object',
|
|
93
96
|
properties: {
|
|
94
97
|
question: {
|
|
95
98
|
type: 'string',
|
|
96
99
|
description: 'Your question or search query'
|
|
100
|
+
},
|
|
101
|
+
org_ref: {
|
|
102
|
+
type: 'string',
|
|
103
|
+
description: 'Organization slug or ref to search in (from list-organizations). Required to search a specific org.'
|
|
97
104
|
}
|
|
98
105
|
},
|
|
99
106
|
required: ['question']
|
|
@@ -101,7 +108,7 @@ async function startMCPServer() {
|
|
|
101
108
|
},
|
|
102
109
|
{
|
|
103
110
|
name: 'add-knowledge',
|
|
104
|
-
description: 'Add new content to
|
|
111
|
+
description: 'Add new content to a knowledge base. IMPORTANT: Call list-organizations first to get org_ref values if you want to add to a specific organization.',
|
|
105
112
|
inputSchema: {
|
|
106
113
|
type: 'object',
|
|
107
114
|
properties: {
|
|
@@ -112,6 +119,10 @@ async function startMCPServer() {
|
|
|
112
119
|
title: {
|
|
113
120
|
type: 'string',
|
|
114
121
|
description: 'Title for the document'
|
|
122
|
+
},
|
|
123
|
+
org_ref: {
|
|
124
|
+
type: 'string',
|
|
125
|
+
description: 'Organization slug or ref to add content to (from list-organizations)'
|
|
115
126
|
}
|
|
116
127
|
},
|
|
117
128
|
required: ['content']
|
|
@@ -119,26 +130,34 @@ async function startMCPServer() {
|
|
|
119
130
|
},
|
|
120
131
|
{
|
|
121
132
|
name: 'list-knowledge',
|
|
122
|
-
description: 'List documents in
|
|
133
|
+
description: 'List documents in a knowledge base. IMPORTANT: Call list-organizations first to get org_ref values, then specify which organization to list. If no org_ref is provided, uses your default organization.',
|
|
123
134
|
inputSchema: {
|
|
124
135
|
type: 'object',
|
|
125
136
|
properties: {
|
|
126
137
|
limit: {
|
|
127
138
|
type: 'number',
|
|
128
139
|
description: 'Maximum number of documents to return (default: 20)'
|
|
140
|
+
},
|
|
141
|
+
org_ref: {
|
|
142
|
+
type: 'string',
|
|
143
|
+
description: 'Organization slug or ref to list documents from (from list-organizations). Required to list a specific org.'
|
|
129
144
|
}
|
|
130
145
|
}
|
|
131
146
|
}
|
|
132
147
|
},
|
|
133
148
|
{
|
|
134
149
|
name: 'delete-knowledge',
|
|
135
|
-
description: 'Delete a document from
|
|
150
|
+
description: 'Delete a document from a knowledge base. IMPORTANT: Call list-organizations first to get org_ref, then specify which organization the document belongs to.',
|
|
136
151
|
inputSchema: {
|
|
137
152
|
type: 'object',
|
|
138
153
|
properties: {
|
|
139
154
|
id: {
|
|
140
155
|
type: 'string',
|
|
141
156
|
description: 'The document ID to delete'
|
|
157
|
+
},
|
|
158
|
+
org_ref: {
|
|
159
|
+
type: 'string',
|
|
160
|
+
description: 'Organization slug or ref where the document is (from list-organizations). Required for multi-org.'
|
|
142
161
|
}
|
|
143
162
|
},
|
|
144
163
|
required: ['id']
|
|
@@ -160,11 +179,11 @@ async function startMCPServer() {
|
|
|
160
179
|
try {
|
|
161
180
|
switch (name) {
|
|
162
181
|
case 'search-context': {
|
|
163
|
-
const { question } = toolArgs;
|
|
182
|
+
const { question, org_ref } = toolArgs;
|
|
164
183
|
if (!question || typeof question !== 'string') {
|
|
165
184
|
throw new Error('Question is required');
|
|
166
185
|
}
|
|
167
|
-
const result = await supabase.search(question);
|
|
186
|
+
const result = await supabase.search(question, org_ref);
|
|
168
187
|
let responseText = result.answer;
|
|
169
188
|
if (result.sources && result.sources.length > 0) {
|
|
170
189
|
responseText += '\n\n---\n**Sources:**';
|
|
@@ -178,30 +197,26 @@ async function startMCPServer() {
|
|
|
178
197
|
};
|
|
179
198
|
}
|
|
180
199
|
case 'add-knowledge': {
|
|
181
|
-
const { content, title } = toolArgs;
|
|
200
|
+
const { content, title, org_ref } = toolArgs;
|
|
182
201
|
if (!content || typeof content !== 'string') {
|
|
183
202
|
throw new Error('Content is required');
|
|
184
203
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const listResult = await supabase.listDocuments(1);
|
|
188
|
-
cachedOrgId = listResult.org_id;
|
|
189
|
-
}
|
|
190
|
-
const result = await supabase.ingestDocument(content, title, cachedOrgId);
|
|
204
|
+
const result = await supabase.ingestDocument(content, title, org_ref);
|
|
205
|
+
cachedOrgId = result.org_id; // Cache for future use
|
|
191
206
|
return {
|
|
192
207
|
content: [{
|
|
193
208
|
type: 'text',
|
|
194
|
-
text: `Document added!\nID: ${result.documentId}\nChunks created: ${result.chunks}`
|
|
209
|
+
text: `Document added!\nID: ${result.documentId}\nChunks created: ${result.chunks}${org_ref ? `\nOrganization: ${org_ref}` : ''}`
|
|
195
210
|
}]
|
|
196
211
|
};
|
|
197
212
|
}
|
|
198
213
|
case 'list-knowledge': {
|
|
199
|
-
const { limit } = toolArgs;
|
|
200
|
-
const result = await supabase.listDocuments(limit || 20);
|
|
214
|
+
const { limit, org_ref } = toolArgs;
|
|
215
|
+
const result = await supabase.listDocuments(limit || 20, org_ref);
|
|
201
216
|
cachedOrgId = result.org_id; // Cache for future add-knowledge calls
|
|
202
217
|
if (result.documents.length === 0) {
|
|
203
218
|
return {
|
|
204
|
-
content: [{ type: 'text', text:
|
|
219
|
+
content: [{ type: 'text', text: `No documents in knowledge base${org_ref ? ` (org: ${org_ref})` : ''}.` }]
|
|
205
220
|
};
|
|
206
221
|
}
|
|
207
222
|
let text = `**${result.documents.length} document(s):**\n\n`;
|
|
@@ -214,16 +229,16 @@ async function startMCPServer() {
|
|
|
214
229
|
};
|
|
215
230
|
}
|
|
216
231
|
case 'delete-knowledge': {
|
|
217
|
-
const { id } = toolArgs;
|
|
232
|
+
const { id, org_ref } = toolArgs;
|
|
218
233
|
if (!id) {
|
|
219
234
|
throw new Error('Document ID is required');
|
|
220
235
|
}
|
|
221
|
-
const result = await supabase.deleteDocument(id);
|
|
236
|
+
const result = await supabase.deleteDocument(id, org_ref);
|
|
222
237
|
return {
|
|
223
238
|
content: [{
|
|
224
239
|
type: 'text',
|
|
225
240
|
text: result.success
|
|
226
|
-
? `Document ${id} deleted.`
|
|
241
|
+
? `Document ${id} deleted${org_ref ? ` from ${org_ref}` : ''}.`
|
|
227
242
|
: `Failed to delete document ${id}.`
|
|
228
243
|
}]
|
|
229
244
|
};
|