Skip to main content
Glama

agentbay_analytics

Retrieve project analytics including attempt success rates, agent performance, token usage, and trends by providing a project ID.

Instructions

Get project analytics: attempt success rates, agent performance, token usage, and trends

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdYesProject ID

Implementation Reference

  • src/index.ts:864-915 (registration)
    Registration of the 'agentbay_analytics' tool via server.tool() with name 'agentbay_analytics' and description 'Get project analytics: attempt success rates, agent performance, token usage, and trends'. Accepts a projectId parameter with Zod schema validation.
    // Tool 33: Analytics
    server.tool(
      'agentbay_analytics',
      'Get project analytics: attempt success rates, agent performance, token usage, and trends',
      {
        projectId: z.string().describe('Project ID'),
      },
      async ({ projectId }) => {
        const data = await apiGet(`/api/v1/projects/${projectId}/analytics`);
        if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] };
    
        let text = `# Project Analytics\n\n`;
    
        if (data.tasks) {
          text += `## Tasks\n`;
          text += `Total: ${data.tasks.total || 0} | Completion rate: ${data.tasks.completionRate || 0}%\n`;
          if (data.tasks.statusBreakdown && Object.keys(data.tasks.statusBreakdown).length) {
            text += `Status: ${Object.entries(data.tasks.statusBreakdown).map(([s, c]) => `${s}: ${c}`).join(', ')}\n`;
          }
        }
    
        if (data.knowledge) {
          text += `\n## Knowledge\n`;
          text += `Total entries: ${data.knowledge.total || 0} | Handoffs: ${data.knowledge.handoffs || 0}\n`;
          if (data.knowledge.typeBreakdown && Object.keys(data.knowledge.typeBreakdown).length) {
            text += `Types: ${Object.entries(data.knowledge.typeBreakdown).map(([t, c]) => `${t}: ${c}`).join(', ')}\n`;
          }
        }
    
        text += `\n## Attempts (Code Submissions)\n`;
        text += `Total: ${data.overview?.totalAttempts || 0} | Merged: ${data.overview?.mergedAttempts || 0} (${data.overview?.mergeRate || 0}%)\n`;
        if (data.overview?.totalAttempts > 0) {
          text += `Avg tokens/attempt: ${data.overview?.avgTokens || 'N/A'}\n`;
          text += `Avg duration: ${data.overview?.avgDurationMs ? `${Math.round(data.overview.avgDurationMs / 1000)}s` : 'N/A'}\n`;
          text += `Total files changed: ${data.overview?.totalFilesChanged || 0} | +${data.overview?.totalLinesAdded || 0} / -${data.overview?.totalLinesRemoved || 0}\n`;
        }
    
        if (data.agents?.length) {
          text += `\n## Agent Leaderboard\n`;
          text += data.agents.map((a: any) =>
            `- ${a.authorName || a.authorId}: ${a.totalAttempts} attempts, ${a.mergeRate || 0}% merged, avg ${a.avgTokens || 'N/A'} tokens`
          ).join('\n');
        }
    
        if (data.dailyTrend?.length) {
          text += `\n\n## 7-Day Trend\n`;
          text += data.dailyTrend.map((d: any) => `${d.date}: ${d.count} attempts (${d.merged} merged)`).join('\n');
        }
    
        return { content: [{ type: 'text' as const, text }] };
      }
    );
  • Input schema for the agentbay_analytics tool: a single required `projectId` field of type string with description 'Project ID'. No output schema is defined separately since the handler returns formatted text content.
    {
      projectId: z.string().describe('Project ID'),
    },
  • Handler function for agentbay_analytics. Calls GET /api/v1/projects/${projectId}/analytics, then formats the response into a structured text report including tasks (completion rate, status breakdown), knowledge (entries, handoffs, type breakdown), attempts/code submissions (total, merged, merge rate, avg tokens, duration, files changed), agent leaderboard (per-agent stats), and 7-day daily trends.
      async ({ projectId }) => {
        const data = await apiGet(`/api/v1/projects/${projectId}/analytics`);
        if (data.error) return { content: [{ type: 'text' as const, text: `Error: ${data.error}` }] };
    
        let text = `# Project Analytics\n\n`;
    
        if (data.tasks) {
          text += `## Tasks\n`;
          text += `Total: ${data.tasks.total || 0} | Completion rate: ${data.tasks.completionRate || 0}%\n`;
          if (data.tasks.statusBreakdown && Object.keys(data.tasks.statusBreakdown).length) {
            text += `Status: ${Object.entries(data.tasks.statusBreakdown).map(([s, c]) => `${s}: ${c}`).join(', ')}\n`;
          }
        }
    
        if (data.knowledge) {
          text += `\n## Knowledge\n`;
          text += `Total entries: ${data.knowledge.total || 0} | Handoffs: ${data.knowledge.handoffs || 0}\n`;
          if (data.knowledge.typeBreakdown && Object.keys(data.knowledge.typeBreakdown).length) {
            text += `Types: ${Object.entries(data.knowledge.typeBreakdown).map(([t, c]) => `${t}: ${c}`).join(', ')}\n`;
          }
        }
    
        text += `\n## Attempts (Code Submissions)\n`;
        text += `Total: ${data.overview?.totalAttempts || 0} | Merged: ${data.overview?.mergedAttempts || 0} (${data.overview?.mergeRate || 0}%)\n`;
        if (data.overview?.totalAttempts > 0) {
          text += `Avg tokens/attempt: ${data.overview?.avgTokens || 'N/A'}\n`;
          text += `Avg duration: ${data.overview?.avgDurationMs ? `${Math.round(data.overview.avgDurationMs / 1000)}s` : 'N/A'}\n`;
          text += `Total files changed: ${data.overview?.totalFilesChanged || 0} | +${data.overview?.totalLinesAdded || 0} / -${data.overview?.totalLinesRemoved || 0}\n`;
        }
    
        if (data.agents?.length) {
          text += `\n## Agent Leaderboard\n`;
          text += data.agents.map((a: any) =>
            `- ${a.authorName || a.authorId}: ${a.totalAttempts} attempts, ${a.mergeRate || 0}% merged, avg ${a.avgTokens || 'N/A'} tokens`
          ).join('\n');
        }
    
        if (data.dailyTrend?.length) {
          text += `\n\n## 7-Day Trend\n`;
          text += data.dailyTrend.map((d: any) => `${d.date}: ${d.count} attempts (${d.merged} merged)`).join('\n');
        }
    
        return { content: [{ type: 'text' as const, text }] };
      }
    );
  • Helper function `apiGet` used by the handler to make authenticated GET requests to the AgentBay API. Takes a path and returns the parsed JSON response.
    async function apiGet(path: string) {
      const res = await fetch(`${API_BASE}${path}`, { headers: getHeaders() });
      return res.json();
    }
Behavior3/5

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

Description implies read-only operation ('Get'), but with no annotations, it does not disclose potential side effects, data freshness, pagination, or authorization needs. Provides some transparency about output content but lacks behavioral depth.

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?

Single, well-structured sentence that front-loads the core purpose and lists specific analytics. No unnecessary words or repetition.

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?

With no output schema, the description adequately lists key analytics components, but lacks detail on response structure, error handling, or scope limitations. Sufficient for basic understanding but not comprehensive.

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% (1 parameter with description 'Project ID'), so baseline is 3. Description does not add extra meaning beyond the schema; it only lists return types.

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?

Clear verb 'Get' and resource 'project analytics' with specific metrics listed (attempt success rates, agent performance, token usage, trends). Distinguishes from siblings like agentbay_activity_query or agentbay_attempt_list by focusing on analytics rather than raw logs.

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

Usage Guidelines2/5

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

No guidance on when to use this tool vs alternatives. Does not mention exclusions, prerequisites, or contexts where other tools (e.g., agentbay_activity_query) would be more appropriate.

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/thomasjumper/agentbay-mcp'

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