Skip to content

Commit e0f0d8c

Browse files
committed
remove cap of 20 kowledge assets
1 parent 48f4130 commit e0f0d8c

3 files changed

Lines changed: 36 additions & 20 deletions

File tree

apps/agent/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ ragas-results.json
5454
logs
5555
storage
5656
docker-compose.knowledge-manager.yml
57+
DKG_Node_Publisher_Tests.xml

packages/plugin-dkg-publisher/src/mcp/tools.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ export function registerMcpTools(mcp: any, serviceContainer: ServiceContainer |
123123
"knowledge-asset-list-recent",
124124
{
125125
title: "List Recent Knowledge Assets",
126-
description: "Show, list, or display recent knowledge assets. Use when user asks 'show me recent assets', 'what was published', 'last X assets', etc. Can filter by status (published, failed, publishing, queued). Always returns up to 20 most recent assets (capped at 20).",
126+
description: "Show, list, or display recent knowledge assets. Use when user asks 'show me recent assets', 'what was published', 'last X assets', 'publishes 200-500', etc. Can filter by status (published, failed, publishing, queued). Supports pagination with offset for large queries.",
127127
inputSchema: {
128-
limit: z.number().min(1).max(20).default(5).optional().describe("Number of assets to return (1-20, default: 5)"),
128+
limit: z.number().min(1).default(20).optional().describe("Number of assets to return (default: 20)"),
129+
offset: z.number().min(0).default(0).optional().describe("Number of assets to skip (for pagination, default: 0)"),
129130
status: z.enum(["published", "failed", "publishing", "queued"]).optional().describe("Filter by status (optional)"),
130131
},
131132
},
@@ -135,26 +136,31 @@ export function registerMcpTools(mcp: any, serviceContainer: ServiceContainer |
135136
}
136137

137138
const assetService = serviceContainer.get<AssetService>("assetService");
139+
138140
const assetsList = await assetService.getRecentAssets(
139-
input.limit || 5,
141+
input.limit,
140142
input.status,
143+
input.offset,
141144
);
142145

143146
if (assetsList.length === 0) {
144147
const statusFilter = input.status ? ` with status '${input.status}'` : '';
148+
const rangeText = input.offset > 0 ? ` (range ${input.offset + 1}-${input.offset + input.limit})` : '';
145149
return {
146150
content: [
147151
{
148152
type: "text",
149-
text: `No assets found${statusFilter}.\n\nNo knowledge assets have been published yet.`,
153+
text: `No assets found${statusFilter}${rangeText}.\n\nNo knowledge assets in this range.`,
150154
},
151155
],
152156
};
153157
}
154158

155-
const requestedLimit = input.limit || 5;
156159
const statusFilter = input.status ? ` ${input.status}` : '';
157-
let resultText = `**Last ${assetsList.length}${statusFilter} Assets** (showing most recent, max ${requestedLimit})\n\n`;
160+
const rangeStart = input.offset + 1;
161+
const rangeEnd = input.offset + assetsList.length;
162+
const rangeText = input.offset > 0 ? ` (${rangeStart}-${rangeEnd})` : '';
163+
let resultText = `**${assetsList.length}${statusFilter} Assets${rangeText}**\n\n`;
158164

159165
const db = serviceContainer.get<Database>("db");
160166

@@ -210,10 +216,11 @@ export function registerMcpTools(mcp: any, serviceContainer: ServiceContainer |
210216
"knowledge-asset-query-by-status",
211217
{
212218
title: "Find Knowledge Assets by Status",
213-
description: "Find, show, list, or query knowledge assets by publishing status. Use when user asks 'show me all published', 'failed assets', 'what's publishing', etc. Supports statuses: published (successfully published), failed (publishing failed), publishing (currently being published), queued (waiting to publish). Always returns up to 20 most recent assets matching the status (capped at 20).",
219+
description: "Find, show, list, or query knowledge assets by publishing status. Use when user asks 'show me all published', 'failed assets', 'what's publishing', 'publishes 100-200', etc. Supports statuses: published (successfully published), failed (publishing failed), publishing (currently being published), queued (waiting to publish). Supports pagination with offset for large queries.",
214220
inputSchema: {
215221
status: z.enum(["published", "failed", "publishing", "queued"]).describe("The status to filter by"),
216-
limit: z.number().min(1).max(20).default(10).optional().describe("Maximum number of results (1-20, default: 10)"),
222+
limit: z.number().min(1).default(20).optional().describe("Maximum number of results (default: 20)"),
223+
offset: z.number().min(0).default(0).optional().describe("Number of assets to skip (for pagination, default: 0)"),
217224
},
218225
},
219226
async (input: any, req: any) => {
@@ -222,25 +229,30 @@ export function registerMcpTools(mcp: any, serviceContainer: ServiceContainer |
222229
}
223230

224231
const assetService = serviceContainer.get<AssetService>("assetService");
232+
225233
const assetsList = await assetService.getAssetsByStatusForDisplay(
226234
input.status,
227-
input.limit || 10,
235+
input.limit,
236+
input.offset,
228237
);
229238

230239
if (assetsList.length === 0) {
240+
const rangeText = input.offset > 0 ? ` (range ${input.offset + 1}-${input.offset + input.limit})` : '';
231241
return {
232242
content: [
233243
{
234244
type: "text",
235-
text: `No assets found with status: ${input.status}\n\n` +
236-
`No ${input.status} knowledge assets found.`,
245+
text: `No assets found with status: ${input.status}${rangeText}\n\n` +
246+
`No ${input.status} knowledge assets in this range.`,
237247
},
238248
],
239249
};
240250
}
241251

242-
const requestedLimit = input.limit || 10;
243-
let resultText = `**Last ${assetsList.length} ${input.status.toUpperCase()} Assets** (showing most recent, max ${requestedLimit})\n\n`;
252+
const rangeStart = input.offset + 1;
253+
const rangeEnd = input.offset + assetsList.length;
254+
const rangeText = input.offset > 0 ? ` (${rangeStart}-${rangeEnd})` : '';
255+
let resultText = `**${assetsList.length} ${input.status.toUpperCase()} Assets${rangeText}**\n\n`;
244256

245257
const db = serviceContainer.get<Database>("db");
246258

packages/plugin-dkg-publisher/src/services/AssetService.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -596,24 +596,25 @@ export class AssetService extends EventEmitter {
596596
* Get recent assets for display (all users, no filtering by userId)
597597
*/
598598
async getRecentAssets(
599-
limit: number = 5,
599+
limit: number = 20,
600600
statusFilter?: "published" | "failed" | "publishing" | "queued",
601+
offset: number = 0,
601602
): Promise<AssetStatus[]> {
602-
const cappedLimit = Math.min(limit, 20); // Cap at 20
603-
604603
let query = this.db
605604
.select()
606605
.from(assets)
607606
.orderBy(desc(assets.createdAt))
608-
.limit(cappedLimit);
607+
.limit(limit)
608+
.offset(offset);
609609

610610
if (statusFilter) {
611611
const results = await this.db
612612
.select()
613613
.from(assets)
614614
.where(eq(assets.status, statusFilter))
615615
.orderBy(desc(assets.createdAt))
616-
.limit(cappedLimit);
616+
.limit(limit)
617+
.offset(offset);
617618

618619
return results.map((asset) => ({
619620
id: asset.id,
@@ -646,14 +647,16 @@ export class AssetService extends EventEmitter {
646647
*/
647648
async getAssetsByStatusForDisplay(
648649
status: "published" | "failed" | "publishing" | "queued",
649-
limit: number = 10,
650+
limit: number = 20,
651+
offset: number = 0,
650652
): Promise<AssetStatus[]> {
651653
const results = await this.db
652654
.select()
653655
.from(assets)
654656
.where(eq(assets.status, status))
655657
.orderBy(desc(assets.createdAt))
656-
.limit(Math.min(limit, 20)); // Cap at 20
658+
.limit(limit)
659+
.offset(offset);
657660

658661
return results.map((asset) => ({
659662
id: asset.id,

0 commit comments

Comments
 (0)