get_service_usage
Check usage statistics for Sonnet 4.5, Gemini, or GPT-5 services to monitor API quotas and track request consumption against subscription limits.
Instructions
Get usage statistics for a specific service
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| service | Yes | Service to check usage for |
Implementation Reference
- src/index.ts:212-253 (handler)MCP tool handler for 'get_service_usage': validates service input, delegates to monitor.getServiceUsage, formats and returns markdown response with status, usage details, and alerts.private async handleGetServiceUsage(args: { service: string }) { const { service } = args; if (!['sonnet45', 'gemini', 'gpt5', 'total'].includes(service)) { throw new Error( 'Invalid service. Must be one of: sonnet45, gemini, gpt5, total' ); } const usage = this.monitor.getServiceUsage( service as 'sonnet45' | 'gemini' | 'gpt5' | 'total' ); const status = usage.isCritical ? '🔴 CRITICAL' : usage.isWarning ? '🟡 WARNING' : '🟢 OK'; const content = ` # ${service.toUpperCase()} Service Usage ## Status: ${status} - **Current**: ${usage.current} - **Maximum**: ${usage.max} - **Percentage**: ${usage.percentage.toFixed(1)}% - **Remaining**: ${usage.remaining} ${usage.isCritical ? '⚠️ This service is at or near its limit!' : ''} ${usage.isWarning ? '⚠️ This service is approaching its limit.' : ''} `.trim(); return { content: [ { type: 'text', text: content, }, ], }; }
- src/index.ts:48-62 (registration)Tool registration in ListTools response, defining name, description, and input schema with service enum.{ name: 'get_service_usage', description: 'Get usage statistics for a specific service', inputSchema: { type: 'object', properties: { service: { type: 'string', enum: ['sonnet45', 'gemini', 'gpt5', 'total'], description: 'Service to check usage for', }, }, required: ['service'], }, },
- src/cursorLimitsMonitor.ts:149-167 (helper)Core helper method implementing service usage computation: retrieves stats, current/max values, percentage, remaining requests, and warning/critical flags.public getServiceUsage( service: 'sonnet45' | 'gemini' | 'gpt5' | 'total' ): ServiceUsage { const stats = this.getUsageStats(); const current = this.getCurrentUsage(service); const max = this.getMaxUsage(service); const percentage = stats.usagePercentages[service]; const remaining = stats.remaining[service]; return { service, current, max, percentage, remaining, isWarning: percentage >= 0.8, isCritical: percentage >= 0.95, }; }
- src/types.ts:71-82 (schema)Type definitions for ServiceType enum and ServiceUsage interface used in getServiceUsage output.export type ServiceType = 'sonnet45' | 'gemini' | 'gpt5' | 'total'; export interface ServiceUsage { service: ServiceType; current: number; max: number; percentage: number; remaining: number; isWarning: boolean; isCritical: boolean; }