Skip to content

USER GUIDE: Claude Parser Tool

CLI Commands:

  1. Show Message History:
  2. Command: cg_basic log
  3. Description: Displays the message history from the current session.
  4. Example: cg_basic log --limit 10

  5. Show Specific Message Details:

  6. Command: cg_reflog show <uuid>
  7. Description: Shows details of a specific message using its UUID.
  8. Example: cg_reflog show abc123

  9. Show Operations History:

  10. Command: cg_reflog reflog
  11. Description: Displays all operations history across sessions.
  12. Example: cg_reflog reflog --limit 20

Calling SDK from Python Code:

  1. Analyzing Tool Usage:
  2. Function: analyze_tool_usage(session_data: Dict[str, Any]) -> Dict[str, Any]
  3. Description: Analyzes tool usage from session data.
  4. Example: analyze_tool_usage(session_data)

  5. Calculating Session Cost:

  6. Function: calculate_session_cost(...) -> Dict[str, float]
  7. Description: Calculates session cost based on token usage.
  8. Example: calculate_session_cost(input_tokens, output_tokens, cache_read_tokens, cache_creation_tokens, model)

  9. Calculating Context Window:

  10. Function: calculate_context_window(jsonl_path: Optional[str] = None) -> Dict[str, int]
  11. Description: Calculates context window usage with user/assistant separation.
  12. Example: calculate_context_window(jsonl_path)

Integrating with MCP Tools in Claude:

  • The tool provides functions to analyze tool usage, calculate session cost, and estimate token usage.
  • These functions can be integrated with other MCP tools in Claude for comprehensive analytics and billing.

Common Workflows and Use Cases:

  1. Analyzing Tool Usage:
  2. Use the analyze_tool_usage function to track tool usage patterns in sessions.
  3. Calculating Session Cost:
  4. Utilize the calculate_session_cost function to estimate the cost of a session based on token usage.
  5. Monitoring Context Window Usage:
  6. Use the calculate_context_window function to monitor and manage context window token usage.

By following the provided CLI commands and SDK functions, users can effectively analyze tool usage, calculate session costs, and integrate with other MCP tools in Claude for enhanced analytics and workflows.