Skip to main content
Glama
mvacaporale

Claude Usage MCP Server

by mvacaporale

check_claude_auth

Verify authentication status for Claude.ai sessions to monitor usage limits and track API consumption.

Instructions

Check if the current session is authenticated with Claude.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler logic for 'check_claude_auth' tool, which checks browser authentication status.
    elif name == "check_claude_auth":
        context = await get_browser_context()
        is_authenticated = await check_authenticated(context)
    
        return [TextContent(
            type="text",
            text=json.dumps({
                "authenticated": is_authenticated,
                "auth_state_exists": AUTH_STATE_PATH.exists()
            }, indent=2)
        )]
  • server.py:211-219 (registration)
    Registration of the 'check_claude_auth' tool within the list_tools function.
            name="check_claude_auth",
            description="Check if the current session is authenticated with Claude.",
            inputSchema={
                "type": "object",
                "properties": {},
                "required": []
            }
        )
    ]
  • Helper function used by 'check_claude_auth' to perform the actual authentication check using Playwright.
    async def check_authenticated(context: BrowserContext) -> bool:
        """Check if current session is authenticated."""
        page = await context.new_page()
        try:
            await page.goto(USAGE_URL, wait_until="domcontentloaded", timeout=60000)
            # Wait a bit for any redirects
            await page.wait_for_timeout(2000)
            # Check if we're on the usage page or redirected to login
            current_url = page.url
            return "settings/usage" in current_url and "login" not in current_url
        except Exception:
            return False
        finally:
            await page.close()

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/mvacaporale/claude-usage-mcp'

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