get_stream_analytics
Retrieve stream analytics including viewer counts, engagement metrics, and performance data for monitoring streaming channel performance across platforms.
Instructions
Get analytics and statistics for streams including viewer counts, engagement metrics, and performance data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| streamId | No | Optional stream ID to get analytics for a specific stream. If not provided, returns analytics for the current user |
Implementation Reference
- src/restream-client.ts:156-164 (handler)The core implementation of the getStreamAnalytics tool. Fetches analytics data from the Restream API endpoint, either for a specific stream by ID or user-level analytics. Handles authentication and errors via the class methods.async getStreamAnalytics(streamId?: string): Promise<any> { try { const endpoint = streamId ? `/streams/${streamId}/analytics` : '/user/analytics'; const response = await this.axiosInstance.get(endpoint); return response.data; } catch (error) { throw this.handleError(error, 'Failed to fetch stream analytics'); } }
- src/index.ts:123-135 (registration)Registers the 'get_stream_analytics' tool in the MCP tools list, including its name, description, and input schema definition.{ name: 'get_stream_analytics', description: 'Get analytics and statistics for streams including viewer counts, engagement metrics, and performance data', inputSchema: { type: 'object', properties: { streamId: { type: 'string', description: 'Optional stream ID to get analytics for a specific stream. If not provided, returns analytics for the current user', }, }, }, },
- src/index.ts:274-286 (handler)The MCP server request handler for the 'get_stream_analytics' tool. Parses input arguments, calls the RestreamClient method, and formats the response as MCP content.case 'get_stream_analytics': { const analytics = await restreamClient.getStreamAnalytics( args && typeof args.streamId === 'string' ? args.streamId : undefined ); return { content: [ { type: 'text', text: JSON.stringify(analytics, null, 2), }, ], }; }