get_stream_analytics
Retrieve stream analytics including viewer counts, engagement metrics, and performance data to monitor streaming effectiveness 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)Core implementation of the get_stream_analytics tool. Fetches analytics data from the Restream API endpoint, either for a specific stream or user-level analytics.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 with the MCP server, providing name, description, and input schema.{ 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:126-134 (schema)Defines the input schema for the get_stream_analytics tool, accepting an optional streamId parameter.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)MCP server request handler for the tool call. Extracts arguments, invokes the RestreamClient method, and returns formatted JSON response.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), }, ], }; }