Read Advisor Log
read_advisor_logReview past Opus advisor consultations to understand previous advice and decision context for your project.
Instructions
Read the consultation log from prior Opus advisor calls for this project. Useful for reviewing past advice or getting context on decisions already made.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| last_n | No | Number of recent consultations to return. Omit for the full log. |
Implementation Reference
- src/index.ts:536-560 (handler)The tool handler for 'read_advisor_log' – reads the advisor log, optionally filters by last_n consultations, and returns the content.
}, async ({ last_n }) => { try { const log = await readAdvisorLog(); if (!log) { return { content: [ { type: "text" as const, text: "No advisor consultations yet." }, ], }; } if (last_n) { const recent = getRecentHistory(log, last_n, Infinity); return { content: [{ type: "text" as const, text: recent || "No consultations found." }], }; } return { content: [{ type: "text" as const, text: log }] }; } catch (err) { const message = err instanceof Error ? err.message : "Unknown error reading log"; return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } - src/index.ts:520-560 (registration)Registration of the 'read_advisor_log' tool with the MCP server, including title, description, inputSchema, annotations, and handler.
server.registerTool("read_advisor_log", { title: "Read Advisor Log", description: "Read the consultation log from prior Opus advisor calls for this project. " + "Useful for reviewing past advice or getting context on decisions already made.", inputSchema: { last_n: z .number() .optional() .describe( "Number of recent consultations to return. Omit for the full log.", ), }, annotations: { readOnlyHint: true, }, }, async ({ last_n }) => { try { const log = await readAdvisorLog(); if (!log) { return { content: [ { type: "text" as const, text: "No advisor consultations yet." }, ], }; } if (last_n) { const recent = getRecentHistory(log, last_n, Infinity); return { content: [{ type: "text" as const, text: recent || "No consultations found." }], }; } return { content: [{ type: "text" as const, text: log }] }; } catch (err) { const message = err instanceof Error ? err.message : "Unknown error reading log"; return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } - src/index.ts:525-532 (schema)Input schema for the tool: optional 'last_n' number limiting returned consultations.
inputSchema: { last_n: z .number() .optional() .describe( "Number of recent consultations to return. Omit for the full log.", ), }, - src/index.ts:57-63 (helper)Helper function readAdvisorLog() that reads the advisor log file from disk, returning empty string if not found.
async function readAdvisorLog(): Promise<string> { try { return await readFile(ADVISOR_LOG, "utf-8"); } catch { return ""; } } - src/index.ts:66-70 (helper)Helper function parseConsultations() used to split log into individual consultation entries.
function parseConsultations(log: string): string[] { const parts = log.split(/(?=\n## Consultation)/); // First part is the header, rest are consultations return parts.length > 1 ? parts.slice(1) : []; }