get_recent_tool_calls
Retrieve recent tool call history to restore context, debug sequences, or onboard new chats with previous session data.
Instructions
Get recent tool call history with their arguments and outputs.
Returns chronological list of tool calls made during this session.
Useful for:
- Onboarding new chats about work already done
- Recovering context after chat history loss
- Debugging tool call sequences
Note: Does not track its own calls or other meta/query tools.
History kept in memory (last 1000 calls, lost on restart).
This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| maxResults | No | ||
| toolName | No | ||
| since | No |
Implementation Reference
- src/handlers/history-handlers.ts:8-40 (handler)Main handler function that executes the get_recent_tool_calls tool. Parses arguments using the schema, retrieves formatted recent calls and stats from toolHistory, and returns formatted JSON response.export async function handleGetRecentToolCalls(args: unknown): Promise<ServerResult> { try { const parsed = GetRecentToolCallsArgsSchema.parse(args); // Use formatted version with local timezone const calls = toolHistory.getRecentCallsFormatted({ maxResults: parsed.maxResults, toolName: parsed.toolName, since: parsed.since }); const stats = toolHistory.getStats(); // Format the response (excluding file path per user request) const summary = `Tool Call History (${calls.length} results, ${stats.totalEntries} total in memory)`; const historyJson = JSON.stringify(calls, null, 2); return { content: [{ type: "text", text: `${summary}\n\n${historyJson}` }] }; } catch (error) { return { content: [{ type: "text", text: `Error getting tool history: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } }
- src/tools/schemas.ts:203-207 (schema)Zod schema defining input parameters for get_recent_tool_calls: maxResults (1-1000, default 50), optional toolName filter, optional since datetime filter.export const GetRecentToolCallsArgsSchema = z.object({ maxResults: z.number().min(1).max(1000).optional().default(50), toolName: z.string().optional(), since: z.string().datetime().optional(), });
- src/server.ts:1217-1227 (registration)Registration in the main CallToolRequestSchema handler: dispatches calls to 'get_recent_tool_calls' to the handleGetRecentToolCalls function imported from handlers.case "get_recent_tool_calls": try { result = await handlers.handleGetRecentToolCalls(args); } catch (error) { capture('server_request_error', { message: `Error in get_recent_tool_calls handler: ${error}` }); result = { content: [{ type: "text", text: `Error: Failed to get tool call history` }], isError: true, }; } break;
- src/server.ts:989-1008 (registration)Tool registration in list_tools handler: defines the tool name, description, input schema, and annotations for the MCP protocol.name: "get_recent_tool_calls", description: ` Get recent tool call history with their arguments and outputs. Returns chronological list of tool calls made during this session. Useful for: - Onboarding new chats about work already done - Recovering context after chat history loss - Debugging tool call sequences Note: Does not track its own calls or other meta/query tools. History kept in memory (last 1000 calls, lost on restart). ${CMD_PREFIX_DESCRIPTION}`, inputSchema: zodToJsonSchema(GetRecentToolCallsArgsSchema), annotations: { title: "Get Recent Tool Calls", readOnlyHint: true, }, },
- src/utils/toolHistory.ts:202-214 (helper)Core helper method in ToolHistory class that retrieves and formats recent tool calls with local timezone timestamps, used directly by the handler.getRecentCallsFormatted(options: { maxResults?: number; toolName?: string; since?: string; }): FormattedToolCallRecord[] { const calls = this.getRecentCalls(options); // Format timestamps to local timezone return calls.map(call => ({ ...call, timestamp: formatLocalTimestamp(call.timestamp) })); }