chore(analytics): implement simple get user count#41
Merged
Conversation
dhowden
approved these changes
Nov 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements the getUsersCount operation from the Algolia Analytics API, adding the ability to retrieve the number of unique users within a specified time range, including a daily breakdown.
Changes
New file: get_users_count.go
Implements the analytics_get_users_count MCP tool
Calls the Analytics API endpoint GET /2/users/count
Supports optional date range filtering and tag segmentation
Updated: analytics.go
Registered the new RegisterGetUsersCount function in the RegisterTools method
API Details
Endpoint: https://analytics.algolia.com/2/users/count
Parameters:
index (required): Index name to analyze
startDate (optional): Start date in YYYY-MM-DD format
endDate (optional): End date in YYYY-MM-DD format
tags (optional): Tags for analytics segmentation
Response: Returns the total count of unique users and a daily breakdown showing user counts per day.
Implementation Notes
Follows the established pattern used by other analytics tools (e.g., get_searches_count.go)
Uses the same authentication mechanism (environment variables ALGOLIA_APP_ID and ALGOLIA_API_KEY)
Includes proper error handling for API failures and invalid parameters
Returns results in the standard MCP tool result format
Testing
✅ Project builds successfully
✅ Tool is tested using the MCP inspector