Skip to main content
Glama

get_analytics_data

Retrieve visitor statistics and popularity trends for biological ontologies with optional date and ontology filtering.

Instructions

Get visitor statistics and popularity trends with optional date filtering

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
monthNoMonth (1-12) for specific data
yearNoYear for specific data (2013+)
ontologyNoSpecific ontology acronym (optional)

Implementation Reference

  • The core handler function that validates input, constructs API parameters and endpoint (/analytics or /ontologies/{ontology}/analytics), fetches data from BioOntology API, and returns formatted JSON response or error.
    private async handleGetAnalyticsData(args: any) { if (!isValidGetAnalyticsArgs(args)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid analytics data arguments'); } try { const params: any = { apikey: this.apiKey, }; if (args.month !== undefined) params.month = args.month; if (args.year !== undefined) params.year = args.year; let endpoint = '/analytics'; if (args.ontology) { endpoint = `/ontologies/${args.ontology}/analytics`; } const response = await this.apiClient.get(endpoint, { params }); return { content: [ { type: 'text', text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error fetching analytics data: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], isError: true, }; } }
  • Input schema defining optional parameters: month (1-12), year (>=2013), ontology (string). Used for MCP tool specification and validation.
    inputSchema: { type: 'object', properties: { month: { type: 'number', description: 'Month (1-12) for specific data', minimum: 1, maximum: 12 }, year: { type: 'number', description: 'Year for specific data (2013+)', minimum: 2013 }, ontology: { type: 'string', description: 'Specific ontology acronym (optional)' }, }, required: [], },
  • src/index.ts:680-692 (registration)
    Tool registration in the MCP server's tools list, including name, description, and input schema.
    { name: 'get_analytics_data', description: 'Get visitor statistics and popularity trends with optional date filtering', inputSchema: { type: 'object', properties: { month: { type: 'number', description: 'Month (1-12) for specific data', minimum: 1, maximum: 12 }, year: { type: 'number', description: 'Year for specific data (2013+)', minimum: 2013 }, ontology: { type: 'string', description: 'Specific ontology acronym (optional)' }, }, required: [], }, },
  • Type guard function for validating input arguments against the expected schema before executing the handler.
    const isValidGetAnalyticsArgs = ( args: any ): args is { month?: number; year?: number; ontology?: string } => { return ( typeof args === 'object' && args !== null && (args.month === undefined || (typeof args.month === 'number' && args.month >= 1 && args.month <= 12)) && (args.year === undefined || (typeof args.year === 'number' && args.year >= 2013)) && (args.ontology === undefined || typeof args.ontology === 'string') ); };
  • src/index.ts:722-723 (registration)
    Switch case in the main CallToolRequestHandler that routes calls to the specific handler method.
    case 'get_analytics_data': return this.handleGetAnalyticsData(args);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Augmented-Nature/BioOntology-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server