You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by po...@apache.org on 2026/05/31 12:59:41 UTC
(comdev) branch main updated: ponymail-mcp: add limit/offset pagination to search_list (#12)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/comdev.git
The following commit(s) were added to refs/heads/main by this push:
new 7592dd7 ponymail-mcp: add limit/offset pagination to search_list (#12)
7592dd7 is described below
commit 7592dd7705fa8288b21b8033f9728a7940e4f8f6
Author: André Ahlert <an...@aex.partners>
AuthorDate: Sun May 31 09:59:35 2026 -0300
ponymail-mcp: add limit/offset pagination to search_list (#12)
The search_list tool previously rendered the first 30 email summaries
unconditionally, then printed "... and N more emails" with no way to
reach those N entries without re-querying the backend (and getting the
same first 30 back). For LLM clients doing list-wide analysis, the
remainder was effectively invisible.
This change adds two optional parameters:
- limit (int, 1..200, default 30) — caps the rendered window
- offset (int, >= 0, default 0) — skips the first N entries
The backend call is unchanged; both parameters only affect which slice
of the already-fetched result set is formatted into the response. The
default behaviour (no params) is identical to before.
The trailing summary is upgraded from a static "... and N more" to an
explicit "Showing X-Y of Z" plus the exact next-page offset when more
results remain, so the caller can page deterministically.
Signed-off-by: André Ahlert <an...@aex.partners>
---
mcp/ponymail-mcp/index.js | 35 +++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/mcp/ponymail-mcp/index.js b/mcp/ponymail-mcp/index.js
index d3e66c6..4a75ab8 100644
--- a/mcp/ponymail-mcp/index.js
+++ b/mcp/ponymail-mcp/index.js
@@ -168,8 +168,23 @@ server.tool(
body: z.string().optional().describe("Filter by body text"),
quick: z.boolean().optional().describe("If true, return statistics only (faster)"),
emails_only: z.boolean().optional().describe("If true, return email summaries only (skip thread_struct, participants, word cloud)"),
+ limit: z
+ .number()
+ .int()
+ .min(1)
+ .max(200)
+ .optional()
+ .describe("Maximum email summaries to return in the rendered output (default 30, max 200). The backend always returns the full hit set; this only caps how many are formatted into the response."),
+ offset: z
+ .number()
+ .int()
+ .min(0)
+ .optional()
+ .describe("Number of email summaries to skip before rendering (default 0). Combine with `limit` to page through a large result set without re-querying the backend."),
},
- async ({ list, domain, query, timespan, from, subject, body, quick, emails_only }) => {
+ async ({ list, domain, query, timespan, from, subject, body, quick, emails_only, limit, offset }) => {
+ const pageLimit = limit ?? 30;
+ const pageOffset = offset ?? 0;
const restricted = restrictionFor(list, domain);
if (restricted) {
return {
@@ -246,14 +261,26 @@ server.tool(
const emails = Array.isArray(data.emails)
? data.emails
: Object.values(data.emails);
- for (const e of emails.slice(0, 30)) {
+ const total = emails.length;
+ const start = Math.min(pageOffset, total);
+ const end = Math.min(start + pageLimit, total);
+ const windowed = emails.slice(start, end);
+ for (const e of windowed) {
const date = e.date || new Date((e.epoch || 0) * 1000).toISOString().slice(0, 10);
lines.push(`- **${e.subject}**`);
lines.push(` From: ${e.from} | Date: ${date} | ID: ${e.id || e.mid}`);
}
lines.push("");
- if (emails.length > 30) {
- lines.push(`... and ${emails.length - 30} more emails`);
+ if (total === 0) {
+ // no-op; the empty "## Emails" header is enough signal
+ } else if (windowed.length === 0) {
+ lines.push(`Showing 0 of ${total} (offset ${pageOffset} is past the end).`);
+ } else {
+ lines.push(`Showing ${start + 1}-${end} of ${total}.`);
+ if (end < total) {
+ const nextOffset = end;
+ lines.push(`... ${total - end} more emails. Re-query with offset=${nextOffset} to continue.`);
+ }
}
}