Skip to content

Commit c02f022

Browse files
author
Lasim
committed
feat(backend): add MCP client activity metrics endpoint and service
1 parent 9b82d78 commit c02f022

File tree

8 files changed

+513
-12
lines changed

8 files changed

+513
-12
lines changed

services/backend/api-spec.json

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5174,6 +5174,292 @@
51745174
}
51755175
}
51765176
},
5177+
"/api/me/metrics/mcp/client-activity": {
5178+
"get": {
5179+
"summary": "Get user MCP client activity metrics",
5180+
"tags": [
5181+
"Users",
5182+
"Metrics",
5183+
"MCP"
5184+
],
5185+
"description": "Returns time-series metrics for the authenticated user's MCP client activity including request counts, tool calls, and active clients over time. Supports multiple time ranges and bucket intervals for detailed activity analysis.",
5186+
"parameters": [
5187+
{
5188+
"schema": {
5189+
"type": "string",
5190+
"minLength": 1
5191+
},
5192+
"in": "query",
5193+
"name": "team_id",
5194+
"required": true,
5195+
"description": "Team ID to filter metrics"
5196+
},
5197+
{
5198+
"schema": {
5199+
"type": "string",
5200+
"enum": [
5201+
"1h",
5202+
"3h",
5203+
"6h",
5204+
"12h",
5205+
"24h",
5206+
"7d",
5207+
"30d"
5208+
]
5209+
},
5210+
"in": "query",
5211+
"name": "time_range",
5212+
"required": false,
5213+
"description": "Time range for metrics (e.g., 3h, 24h, 7d)"
5214+
},
5215+
{
5216+
"schema": {
5217+
"type": "string",
5218+
"enum": [
5219+
"15m",
5220+
"1h"
5221+
]
5222+
},
5223+
"in": "query",
5224+
"name": "interval",
5225+
"required": false,
5226+
"description": "Bucket interval for aggregation"
5227+
},
5228+
{
5229+
"schema": {
5230+
"type": "string"
5231+
},
5232+
"in": "query",
5233+
"name": "satellite_id",
5234+
"required": false,
5235+
"description": "Optional satellite ID to filter metrics"
5236+
},
5237+
{
5238+
"schema": {
5239+
"type": "string"
5240+
},
5241+
"in": "query",
5242+
"name": "auth_identifier",
5243+
"required": false,
5244+
"description": "Optional auth identifier to filter metrics"
5245+
}
5246+
],
5247+
"security": [
5248+
{
5249+
"cookieAuth": []
5250+
}
5251+
],
5252+
"responses": {
5253+
"200": {
5254+
"description": "Successful operation - metrics returned",
5255+
"content": {
5256+
"application/json": {
5257+
"schema": {
5258+
"type": "object",
5259+
"properties": {
5260+
"success": {
5261+
"type": "boolean",
5262+
"description": "Indicates if the operation was successful"
5263+
},
5264+
"data": {
5265+
"type": "object",
5266+
"properties": {
5267+
"metric_type": {
5268+
"type": "string",
5269+
"description": "Type of metric returned"
5270+
},
5271+
"time_range": {
5272+
"type": "object",
5273+
"properties": {
5274+
"start": {
5275+
"type": "string",
5276+
"format": "date-time",
5277+
"description": "Start of time range (ISO 8601)"
5278+
},
5279+
"end": {
5280+
"type": "string",
5281+
"format": "date-time",
5282+
"description": "End of time range (ISO 8601)"
5283+
},
5284+
"interval": {
5285+
"type": "string",
5286+
"description": "Bucket interval used"
5287+
}
5288+
},
5289+
"required": [
5290+
"start",
5291+
"end",
5292+
"interval"
5293+
]
5294+
},
5295+
"filters": {
5296+
"type": "object",
5297+
"description": "Applied filters",
5298+
"additionalProperties": true
5299+
},
5300+
"buckets": {
5301+
"type": "array",
5302+
"items": {
5303+
"type": "object",
5304+
"properties": {
5305+
"timestamp": {
5306+
"type": "string",
5307+
"format": "date-time",
5308+
"description": "Bucket timestamp (ISO 8601)"
5309+
},
5310+
"request_count": {
5311+
"type": "number",
5312+
"description": "Number of requests in bucket"
5313+
},
5314+
"tool_call_count": {
5315+
"type": "number",
5316+
"description": "Number of tool calls in bucket"
5317+
},
5318+
"active_client_count": {
5319+
"type": "number",
5320+
"description": "Number of active clients in bucket"
5321+
}
5322+
},
5323+
"required": [
5324+
"timestamp",
5325+
"request_count",
5326+
"tool_call_count",
5327+
"active_client_count"
5328+
]
5329+
},
5330+
"description": "Time-series buckets with metrics"
5331+
},
5332+
"summary": {
5333+
"type": "object",
5334+
"description": "Summary statistics across all buckets",
5335+
"additionalProperties": true
5336+
}
5337+
},
5338+
"required": [
5339+
"metric_type",
5340+
"time_range",
5341+
"filters",
5342+
"buckets",
5343+
"summary"
5344+
]
5345+
}
5346+
},
5347+
"required": [
5348+
"success",
5349+
"data"
5350+
],
5351+
"description": "Successful operation - metrics returned"
5352+
}
5353+
}
5354+
}
5355+
},
5356+
"400": {
5357+
"description": "Bad Request - Invalid query parameters",
5358+
"content": {
5359+
"application/json": {
5360+
"schema": {
5361+
"type": "object",
5362+
"properties": {
5363+
"success": {
5364+
"type": "boolean",
5365+
"default": false,
5366+
"description": "Indicates failure"
5367+
},
5368+
"error": {
5369+
"type": "string",
5370+
"description": "Error message detailing what went wrong"
5371+
}
5372+
},
5373+
"required": [
5374+
"success",
5375+
"error"
5376+
],
5377+
"description": "Bad Request - Invalid query parameters"
5378+
}
5379+
}
5380+
}
5381+
},
5382+
"401": {
5383+
"description": "Unauthorized",
5384+
"content": {
5385+
"application/json": {
5386+
"schema": {
5387+
"type": "object",
5388+
"properties": {
5389+
"success": {
5390+
"type": "boolean",
5391+
"default": false,
5392+
"description": "Indicates failure"
5393+
},
5394+
"error": {
5395+
"type": "string",
5396+
"description": "Error message detailing what went wrong"
5397+
}
5398+
},
5399+
"required": [
5400+
"success",
5401+
"error"
5402+
],
5403+
"description": "Unauthorized"
5404+
}
5405+
}
5406+
}
5407+
},
5408+
"403": {
5409+
"description": "Forbidden - Insufficient permissions",
5410+
"content": {
5411+
"application/json": {
5412+
"schema": {
5413+
"type": "object",
5414+
"properties": {
5415+
"success": {
5416+
"type": "boolean",
5417+
"default": false,
5418+
"description": "Indicates failure"
5419+
},
5420+
"error": {
5421+
"type": "string",
5422+
"description": "Error message detailing what went wrong"
5423+
}
5424+
},
5425+
"required": [
5426+
"success",
5427+
"error"
5428+
],
5429+
"description": "Forbidden - Insufficient permissions"
5430+
}
5431+
}
5432+
}
5433+
},
5434+
"500": {
5435+
"description": "Internal Server Error",
5436+
"content": {
5437+
"application/json": {
5438+
"schema": {
5439+
"type": "object",
5440+
"properties": {
5441+
"success": {
5442+
"type": "boolean",
5443+
"default": false,
5444+
"description": "Indicates failure"
5445+
},
5446+
"error": {
5447+
"type": "string",
5448+
"description": "Error message detailing what went wrong"
5449+
}
5450+
},
5451+
"required": [
5452+
"success",
5453+
"error"
5454+
],
5455+
"description": "Internal Server Error"
5456+
}
5457+
}
5458+
}
5459+
}
5460+
}
5461+
}
5462+
},
51775463
"/api/settings": {
51785464
"get": {
51795465
"summary": "List all global settings",

0 commit comments

Comments
 (0)