Skip to main content
Glama

Read Advisor Metadata

read_advisor_meta
Read-only

Read structured metadata—latency, token counts, effort levels—from past consultations to analyze cost and performance patterns.

Instructions

Read structured metadata (latency, token counts, effort levels) from all consultations. Useful for understanding cost and performance patterns.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
last_nNoNumber of recent entries to return. Omit for all.

Implementation Reference

  • src/index.ts:563-627 (registration)
    Registration of the 'read_advisor_meta' tool on the MCP server with title, description, input schema, and annotations.
    server.registerTool("read_advisor_meta", {
      title: "Read Advisor Metadata",
      description:
        "Read structured metadata (latency, token counts, effort levels) from all " +
        "consultations. Useful for understanding cost and performance patterns.",
      inputSchema: {
        last_n: z
          .number()
          .optional()
          .describe("Number of recent entries to return. Omit for all."),
      },
      annotations: {
        readOnlyHint: true,
      },
    }, async ({ last_n }) => {
      try {
        const raw = await readFile(ADVISOR_META, "utf-8").catch(() => "");
        if (!raw.trim()) {
          return {
            content: [{ type: "text" as const, text: "No metadata yet." }],
          };
        }
        const lines = raw.trim().split("\n");
        const selected = last_n ? lines.slice(-last_n) : lines;
    
        // Parse and format as a summary table
        const entries = selected.map((line) => {
          try { return JSON.parse(line); } catch { return null; }
        }).filter(Boolean);
    
        const totalLatency = entries.reduce(
          (sum: number, e: { latencyMs: number }) => sum + e.latencyMs, 0,
        );
        const totalAdviceTokens = entries.reduce(
          (sum: number, e: { adviceTokens: number }) => sum + e.adviceTokens, 0,
        );
    
        const summary = [
          `## Advisor Metadata (${entries.length} consultations)`,
          "",
          `| # | Timestamp | Effort | Latency | Q Tokens | Advice Tokens |`,
          `|---|-----------|--------|---------|----------|---------------|`,
          ...entries.map((e: {
            timestamp: string;
            effort: string;
            latencyMs: number;
            questionTokens: number;
            adviceTokens: number;
          }, i: number) =>
            `| ${i + 1} | ${e.timestamp.slice(0, 19)} | ${e.effort} | ${(e.latencyMs / 1000).toFixed(1)}s | ~${e.questionTokens} | ~${e.adviceTokens} |`,
          ),
          "",
          `**Totals**: ${(totalLatency / 1000).toFixed(1)}s latency, ~${totalAdviceTokens} advice tokens`,
        ].join("\n");
    
        return { content: [{ type: "text" as const, text: summary }] };
      } catch (err) {
        const message =
          err instanceof Error ? err.message : "Unknown error reading metadata";
        return {
          content: [{ type: "text" as const, text: `Error: ${message}` }],
          isError: true,
        };
      }
    });
  • Handler function that reads advisor-meta.jsonl, parses JSON lines, computes aggregate stats (latency, token counts), and returns a formatted markdown table.
    }, async ({ last_n }) => {
      try {
        const raw = await readFile(ADVISOR_META, "utf-8").catch(() => "");
        if (!raw.trim()) {
          return {
            content: [{ type: "text" as const, text: "No metadata yet." }],
          };
        }
        const lines = raw.trim().split("\n");
        const selected = last_n ? lines.slice(-last_n) : lines;
    
        // Parse and format as a summary table
        const entries = selected.map((line) => {
          try { return JSON.parse(line); } catch { return null; }
        }).filter(Boolean);
    
        const totalLatency = entries.reduce(
          (sum: number, e: { latencyMs: number }) => sum + e.latencyMs, 0,
        );
        const totalAdviceTokens = entries.reduce(
          (sum: number, e: { adviceTokens: number }) => sum + e.adviceTokens, 0,
        );
    
        const summary = [
          `## Advisor Metadata (${entries.length} consultations)`,
          "",
          `| # | Timestamp | Effort | Latency | Q Tokens | Advice Tokens |`,
          `|---|-----------|--------|---------|----------|---------------|`,
          ...entries.map((e: {
            timestamp: string;
            effort: string;
            latencyMs: number;
            questionTokens: number;
            adviceTokens: number;
          }, i: number) =>
            `| ${i + 1} | ${e.timestamp.slice(0, 19)} | ${e.effort} | ${(e.latencyMs / 1000).toFixed(1)}s | ~${e.questionTokens} | ~${e.adviceTokens} |`,
          ),
          "",
          `**Totals**: ${(totalLatency / 1000).toFixed(1)}s latency, ~${totalAdviceTokens} advice tokens`,
        ].join("\n");
    
        return { content: [{ type: "text" as const, text: summary }] };
      } catch (err) {
        const message =
          err instanceof Error ? err.message : "Unknown error reading metadata";
        return {
          content: [{ type: "text" as const, text: `Error: ${message}` }],
          isError: true,
        };
      }
    });
  • Input schema for the tool: optional 'last_n' number to limit the number of recent entries returned.
    inputSchema: {
      last_n: z
        .number()
        .optional()
        .describe("Number of recent entries to return. Omit for all."),
    },
  • Constant ADVISOR_META defining the file path to advisor-meta.jsonl where the tool reads metadata from.
    const ADVISOR_META = join(ADVISOR_DIR, "advisor-meta.jsonl");
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, so the safety profile is covered. The description adds value by specifying the fields read (latency, token counts, effort levels), but does not disclose additional behaviors like behavior on empty results or error handling. For a read-only tool, this is adequate but not comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise with only two sentences, front-loading the core action and then stating the use case. Every sentence is meaningful with no superfluous wording.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one optional parameter and no output schema, the description gives a high-level overview but omits details like return format, data structure, or scope limitations (e.g., 'all consultations' implies no filtering). While siblings provide context, the description alone is moderately complete but could be more thorough.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with a clear description of the sole parameter 'last_n'. The tool description does not add any extra meaning or context about the parameter beyond what the schema provides, so the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool reads structured metadata (latency, token counts, effort levels) from consultations, with a specific verb and resource. It distinguishes from siblings like 'read_advisor_log' and 'clear_advisor_log' by focusing on metadata vs logs, making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description mentions it is 'useful for understanding cost and performance patterns,' implying a use case, but fails to provide explicit when-to-use or when-not-to-use guidance. No alternatives are mentioned, leaving the agent to infer usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Divinci-AI/opus-advisor-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server