feat: Multi-account support — query multiple Clarity projects by domain name#23
Open
zenmediasocial wants to merge 1 commit into
Open
feat: Multi-account support — query multiple Clarity projects by domain name#23zenmediasocial wants to merge 1 commit into
zenmediasocial wants to merge 1 commit into
Conversation
- Add accounts.json config (~/.clarity-mcp/accounts.json) - Domain names as account identifiers (e.g., crowntrophy.com) - New 'account' param on analytics + recordings tools - New list-clarity-accounts tool for discovery - Default account support (auto-used when no account specified) - Single-account auto-select when only one configured - Backward compatible with --clarity_api_token single-token mode - Response tagging shows which account was queried
|
@zenmediasocial please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
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
Adds multi-account support so a single MCP server instance can query multiple Clarity projects, identified by domain name.
The Problem
The current server supports one API token at a time. Anyone managing multiple sites with Clarity (agencies, consultants, multi-property teams) has to either:
The Solution
A
~/.clarity-mcp/accounts.jsonconfig file that maps domain names to API tokens:{ "default": "mysite.com", "accounts": { "mysite.com": { "token": "token-1" }, "clientsite.com": { "token": "token-2" }, "blog.example.org": { "token": "token-3" } } }Domain names are natural identifiers — easy to remember, no ambiguity. Users just say "show me sessions for clientsite.com" and it works.
Changes
src/accounts.ts— config loading, token resolution, account listinglist-clarity-accountstool — lets the LLM discover available projectsaccountparameter added toquery-analytics-dashboardandlist-session-recordingstools_accountfield)CLARITY_API_TOKENfromutils.ts— token resolution moved to accounts moduleBackward Compatible
--clarity_api_tokenCLI arg orCLARITY_API_TOKENenv var still works (becomes a "default" account)accountparameterConfig File Locations (checked in order)
--accounts-file=/custom/path.json~/.clarity-mcp/accounts.json~/.config/clarity-mcp/accounts.jsonContext
I've been using Clarity since before public release and install it on every client site by default. Managing 15+ properties with per-project tokens was the friction that prompted this. The domain-keyed approach means zero mental overhead — you already know your sites by their domains.
Happy to iterate on the implementation if the team has preferences on config format or API conventions.