Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Track MCP and A2A trigger executions like the others.

Type of Change

  • Other: Better tracking

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 20, 2026 0:24am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 20, 2026

Greptile Summary

This PR extends the execution tracking system to include MCP (Model Context Protocol) and A2A (Agent-to-Agent) trigger types, bringing them to parity with existing trigger types like manual, API, webhook, schedule, and chat.

Key Changes:

  • Added database columns total_mcp_executions and total_a2a_executions to the user_stats table
  • Extended the execution logger switch statement to increment counters for MCP and A2A triggers
  • Updated admin billing API types and response mapping to include the new execution counts
  • All changes follow the established pattern used by other trigger types

Implementation Quality:

  • Consistent with existing trigger tracking patterns
  • Proper database migration with defaults
  • Complete end-to-end implementation across schema, logger, and API layers

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The implementation is straightforward and follows the exact pattern established by existing trigger types (manual, api, webhook, schedule, chat). All changes are additive only, with proper database migration, consistent naming conventions, and complete coverage across all necessary layers (database schema, execution logger, and admin API). No breaking changes or edge cases identified.
  • No files require special attention

Important Files Changed

Filename Overview
packages/db/migrations/0146_cultured_ikaris.sql Adds total_mcp_executions and total_a2a_executions columns to user_stats table with default value of 0
packages/db/schema.ts Adds totalMcpExecutions and totalA2aExecutions fields to userStats schema matching the migration
apps/sim/lib/logs/execution/logger.ts Adds switch cases for mcp and a2a triggers to increment respective execution counters
apps/sim/app/api/v1/admin/types.ts Adds totalMcpExecutions and totalA2aExecutions fields to AdminUserBilling interface
apps/sim/app/api/v1/admin/users/[id]/billing/route.ts Maps totalMcpExecutions and totalA2aExecutions from stats to billing response with null coalescing

Sequence Diagram

sequenceDiagram
    participant Workflow
    participant ExecutionLogger
    participant Database
    participant AdminAPI
    
    Note over Workflow,Database: MCP/A2A Execution Flow
    
    Workflow->>ExecutionLogger: finalize(costSummary, trigger='mcp'|'a2a')
    ExecutionLogger->>ExecutionLogger: Check trigger type in switch
    
    alt trigger is 'mcp'
        ExecutionLogger->>Database: UPDATE user_stats SET total_mcp_executions = total_mcp_executions + 1
    else trigger is 'a2a'
        ExecutionLogger->>Database: UPDATE user_stats SET total_a2a_executions = total_a2a_executions + 1
    end
    
    ExecutionLogger->>Database: Update totalCost, totalTokensUsed, currentPeriodCost
    Database-->>ExecutionLogger: Stats updated
    
    Note over AdminAPI,Database: Admin Billing Query
    
    AdminAPI->>Database: SELECT * FROM user_stats WHERE userId = ?
    Database-->>AdminAPI: Return stats including totalMcpExecutions, totalA2aExecutions
    AdminAPI->>AdminAPI: Map to AdminUserBilling response
    AdminAPI-->>AdminAPI: Return billing data with MCP/A2A counts
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (2)

  1. apps/sim/app/api/v1/admin/types.ts, line 548-552 (link)

    logic: Missing totalMcpExecutions and totalA2aExecutions fields that were added to the user_stats table

  2. apps/sim/app/api/v1/admin/users/[id]/billing/route.ts, line 95-99 (link)

    logic: Missing mappings for totalMcpExecutions and totalA2aExecutions fields

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator Author

@greptile

@icecrasher321 icecrasher321 merged commit 9efd3d5 into staging Jan 20, 2026
11 checks passed
@icecrasher321 icecrasher321 deleted the improvement/exec-counters branch January 20, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants