Skip to content

Commit 9b82d78

Browse files
author
Lasim
committed
feat(metrics): add MCP client activity metrics endpoint and service
- Implemented a new Fastify route for retrieving MCP client activity metrics, including request counts, tool calls, and active clients over specified time ranges and intervals. - Created McpClientActivityMetricsService to handle the logic for querying and aggregating metrics data from the database. - Introduced TimeSeriesMetricsService as a base class for shared time-series metric functionalities, including time range parsing, bucket generation, and summary calculations. - Defined schemas for request query parameters and response formats to ensure proper validation and documentation. - Enhanced error handling and logging for better traceability of issues during metric retrieval.
1 parent 722811a commit 9b82d78

File tree

10 files changed

+5134
-16
lines changed

10 files changed

+5134
-16
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
CREATE TABLE `mcpClientActivityMetrics` (
2+
`id` text PRIMARY KEY NOT NULL,
3+
`user_id` text NOT NULL,
4+
`team_id` text NOT NULL,
5+
`satellite_id` text NOT NULL,
6+
`auth_identifier` text NOT NULL,
7+
`bucket_timestamp` integer NOT NULL,
8+
`bucket_interval` text CHECK(`bucket_interval` IN ('15m', '1h')) NOT NULL,
9+
`request_count` integer DEFAULT 0 NOT NULL,
10+
`tool_call_count` integer DEFAULT 0 NOT NULL,
11+
`active_client_count` integer DEFAULT 0 NOT NULL,
12+
`created_at` integer NOT NULL,
13+
FOREIGN KEY (`user_id`) REFERENCES `authUser`(`id`) ON UPDATE no action ON DELETE cascade,
14+
FOREIGN KEY (`team_id`) REFERENCES `teams`(`id`) ON UPDATE no action ON DELETE cascade,
15+
FOREIGN KEY (`satellite_id`) REFERENCES `satellites`(`id`) ON UPDATE no action ON DELETE cascade
16+
);
17+
--> statement-breakpoint
18+
CREATE INDEX `mcp_activity_metrics_lookup_idx` ON `mcpClientActivityMetrics` (`user_id`,`team_id`,`bucket_timestamp`,`bucket_interval`);--> statement-breakpoint
19+
CREATE INDEX `mcp_activity_metrics_time_idx` ON `mcpClientActivityMetrics` (`bucket_timestamp`);--> statement-breakpoint
20+
CREATE INDEX `mcp_activity_metrics_satellite_idx` ON `mcpClientActivityMetrics` (`satellite_id`,`bucket_timestamp`);--> statement-breakpoint
21+
CREATE INDEX `mcp_activity_metrics_unique_bucket` ON `mcpClientActivityMetrics` (`user_id`,`team_id`,`satellite_id`,`auth_identifier`,`bucket_timestamp`,`bucket_interval`);

0 commit comments

Comments
 (0)