From d3ad27e10a1e2b739c12c6e9d95201978765f015 Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Wed, 3 Dec 2025 21:03:48 +0700 Subject: [PATCH] feat: improve Agent Control MCP activity endpoint with count headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enhance the get_agent_activity tool to provide better context about the activity list: - Add activity count headers showing "X of Y activities" - Remove raw format option, always use curated format for consistency - Simplify implementation by removing unnecessary format branching - Respect limit parameter to show most recent N activities This makes it clearer to users when they're viewing a subset of activities versus the full list. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../server/src/server/agent/mcp-server.ts | 47 ++++++++----------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/packages/server/src/server/agent/mcp-server.ts b/packages/server/src/server/agent/mcp-server.ts index a6012fa57..61cd14b62 100644 --- a/packages/server/src/server/agent/mcp-server.ts +++ b/packages/server/src/server/agent/mcp-server.ts @@ -15,7 +15,6 @@ import type { import { AgentPermissionRequestPayloadSchema, AgentPermissionResponseSchema, - AgentTimelineItemPayloadSchema, AgentSnapshotPayloadSchema, serializeAgentSnapshot, } from "../messages.js"; @@ -642,57 +641,49 @@ export async function createAgentMcpServer( { title: "Get Agent Activity", description: - "Return recent agent timeline entries. Default response is a curated summary; raw timeline entries are available via format='raw'.", + "Return recent agent timeline entries as a curated summary.", inputSchema: { agentId: z.string(), - format: z.enum(["curated", "raw"]).optional().default("curated"), limit: z .number() .optional() - .describe("Optional limit for raw entries (most recent first)."), + .describe("Optional limit for number of activities to include (most recent first)."), }, outputSchema: { agentId: z.string(), - format: z.enum(["curated", "raw"]), updateCount: z.number(), currentModeId: z.string().nullable(), content: z.string(), - updates: z - .array(AgentTimelineItemPayloadSchema) - .nullable() - .describe("Timeline entries when format='raw'."), }, }, - async ({ agentId, format = "curated", limit }) => { + async ({ agentId, limit }) => { const timeline = agentManager.getTimeline(agentId); const snapshot = agentManager.getAgent(agentId); - if (format === "curated") { - return { - content: [], - structuredContent: ensureValidJson({ - agentId, - format: "curated" as const, - updateCount: timeline.length, - currentModeId: snapshot?.currentModeId ?? null, - content: curateAgentActivity(timeline), - updates: null, - }), - }; + const activitiesToCurate = limit + ? timeline.slice(-limit) + : timeline; + + const curatedContent = curateAgentActivity(activitiesToCurate); + const totalCount = timeline.length; + const shownCount = activitiesToCurate.length; + + let countHeader: string; + if (limit && shownCount < totalCount) { + countHeader = `Showing ${shownCount} of ${totalCount} ${totalCount === 1 ? 'activity' : 'activities'} (limited to ${limit})`; + } else { + countHeader = `Showing all ${totalCount} ${totalCount === 1 ? 'activity' : 'activities'}`; } - const entries = limit - ? timeline.slice(-limit).reverse() - : timeline; + const contentWithCount = `${countHeader}\n\n${curatedContent}`; + return { content: [], structuredContent: ensureValidJson({ agentId, - format: "raw" as const, updateCount: timeline.length, currentModeId: snapshot?.currentModeId ?? null, - content: "", - updates: entries, + content: contentWithCount, }), }; }