@topgunbuild/mcp-server 0.11.0 → 2.0.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 -97
- package/README.md +1 -1
- package/dist/cli.js +39 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +33 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -4
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,8 @@ var QueryArgsSchema = z.object({
|
|
|
17
17
|
order: z.enum(["asc", "desc"]).describe("Sort order: ascending or descending")
|
|
18
18
|
}).optional().describe("Sort configuration"),
|
|
19
19
|
limit: z.number().optional().default(10).describe("Maximum number of results to return"),
|
|
20
|
-
cursor: z.string().optional().describe("Opaque cursor for pagination (from previous response nextCursor)")
|
|
20
|
+
cursor: z.string().optional().describe("Opaque cursor for pagination (from previous response nextCursor)"),
|
|
21
|
+
fields: z.array(z.string()).optional().describe("Field names to return (projection). If omitted, all fields are returned.")
|
|
21
22
|
});
|
|
22
23
|
var MutateArgsSchema = z.object({
|
|
23
24
|
map: z.string().describe("Name of the map to modify (e.g., 'tasks', 'users')"),
|
|
@@ -28,7 +29,6 @@ var MutateArgsSchema = z.object({
|
|
|
28
29
|
var SearchArgsSchema = z.object({
|
|
29
30
|
map: z.string().describe("Name of the map to search (e.g., 'articles', 'documents', 'tasks')"),
|
|
30
31
|
query: z.string().describe("Search query (keywords or phrases to find)"),
|
|
31
|
-
methods: z.array(z.enum(["exact", "fulltext", "range"])).optional().default(["exact", "fulltext"]).describe('Search methods to use. Default: ["exact", "fulltext"]'),
|
|
32
32
|
limit: z.number().optional().default(10).describe("Maximum number of results to return"),
|
|
33
33
|
minScore: z.number().optional().default(0).describe("Minimum relevance score (0-1) for results")
|
|
34
34
|
});
|
|
@@ -71,7 +71,12 @@ var toolSchemas = {
|
|
|
71
71
|
description: "Sort configuration"
|
|
72
72
|
},
|
|
73
73
|
limit: { type: "number", description: "Maximum number of results to return", default: 10 },
|
|
74
|
-
cursor: { type: "string", description: "Opaque cursor for pagination (from previous response nextCursor)" }
|
|
74
|
+
cursor: { type: "string", description: "Opaque cursor for pagination (from previous response nextCursor)" },
|
|
75
|
+
fields: {
|
|
76
|
+
type: "array",
|
|
77
|
+
items: { type: "string" },
|
|
78
|
+
description: "Field names to return (projection). If omitted, all fields are returned."
|
|
79
|
+
}
|
|
75
80
|
},
|
|
76
81
|
required: ["map"]
|
|
77
82
|
},
|
|
@@ -98,12 +103,6 @@ var toolSchemas = {
|
|
|
98
103
|
properties: {
|
|
99
104
|
map: { type: "string", description: "Name of the map to search (e.g., 'articles', 'documents', 'tasks')" },
|
|
100
105
|
query: { type: "string", description: "Search query (keywords or phrases to find)" },
|
|
101
|
-
methods: {
|
|
102
|
-
type: "array",
|
|
103
|
-
items: { type: "string", enum: ["exact", "fulltext", "range"] },
|
|
104
|
-
description: 'Search methods to use. Default: ["exact", "fulltext"]',
|
|
105
|
-
default: ["exact", "fulltext"]
|
|
106
|
-
},
|
|
107
106
|
limit: { type: "number", description: "Maximum number of results to return", default: 10 },
|
|
108
107
|
minScore: { type: "number", description: "Minimum relevance score (0-1) for results", default: 0 }
|
|
109
108
|
},
|
|
@@ -173,7 +172,7 @@ async function handleQuery(rawArgs, ctx) {
|
|
|
173
172
|
isError: true
|
|
174
173
|
};
|
|
175
174
|
}
|
|
176
|
-
const { map, filter, sort, limit, cursor } = parseResult.data;
|
|
175
|
+
const { map, filter, sort, limit, cursor, fields } = parseResult.data;
|
|
177
176
|
if (ctx.config.allowedMaps && !ctx.config.allowedMaps.includes(map)) {
|
|
178
177
|
return {
|
|
179
178
|
content: [
|
|
@@ -197,14 +196,34 @@ async function handleQuery(rawArgs, ctx) {
|
|
|
197
196
|
if (cursor) {
|
|
198
197
|
queryFilter.cursor = cursor;
|
|
199
198
|
}
|
|
199
|
+
if (fields && fields.length > 0) {
|
|
200
|
+
queryFilter.fields = fields;
|
|
201
|
+
}
|
|
200
202
|
const handle = ctx.client.query(map, queryFilter);
|
|
203
|
+
let unsubscribe;
|
|
201
204
|
const results = await new Promise((resolve) => {
|
|
202
|
-
|
|
203
|
-
unsubscribe();
|
|
205
|
+
unsubscribe = handle.subscribe((data) => {
|
|
204
206
|
resolve(data);
|
|
205
207
|
});
|
|
206
208
|
});
|
|
207
|
-
|
|
209
|
+
let unsubPagination;
|
|
210
|
+
const paginationInfo = await Promise.race([
|
|
211
|
+
new Promise((resolve) => {
|
|
212
|
+
unsubPagination = handle.onPaginationChange((info) => {
|
|
213
|
+
if (info.cursorStatus !== "none" || info.hasMore) {
|
|
214
|
+
Promise.resolve().then(() => unsubPagination?.());
|
|
215
|
+
resolve(info);
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}),
|
|
219
|
+
new Promise(
|
|
220
|
+
(resolve) => setTimeout(() => {
|
|
221
|
+
unsubPagination?.();
|
|
222
|
+
resolve(handle.getPaginationInfo());
|
|
223
|
+
}, 500)
|
|
224
|
+
)
|
|
225
|
+
]);
|
|
226
|
+
unsubscribe?.();
|
|
208
227
|
if (results.length === 0) {
|
|
209
228
|
return {
|
|
210
229
|
content: [
|
|
@@ -1190,7 +1209,7 @@ var TopGunMCPServer = class {
|
|
|
1190
1209
|
if (!this.isStarted) return;
|
|
1191
1210
|
await this.server.close();
|
|
1192
1211
|
if (!this.externalClient) {
|
|
1193
|
-
this.client.close();
|
|
1212
|
+
await this.client.close();
|
|
1194
1213
|
}
|
|
1195
1214
|
this.isStarted = false;
|
|
1196
1215
|
this.logger.info("TopGun MCP Server stopped");
|