Skip to main content
Glama

check_context_budget

Monitor context window usage and remaining capacity to manage token limits effectively. Returns token metrics and status indicators for informed session management.

Instructions

Check current context window usage and remaining capacity. Returns tokens used, remaining, percentage, and status (sufficient/low/critical).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
context_limitNoMaximum context tokens. Default: 156000 (200K * 0.78)

Implementation Reference

  • The _check_context_budget function calculates the context usage using TranscriptParser and returns token statistics.
    async def _check_context_budget(arguments: dict[str, Any]) -> dict:
        """Check context window usage."""
        context_limit = arguments.get("context_limit", DEFAULT_CONTEXT_LIMIT)
    
        parser = TranscriptParser()
        budget = parser.get_context_budget(context_limit)
    
        return {
            "tokens_used": budget.tokens_used,
            "tokens_remaining": budget.tokens_remaining,
            "percentage_used": budget.percentage_used,
            "context_limit": budget.context_limit,
            "status": budget.status,
        }

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/TimEvans/ccsession'

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