Class: Mathpix::MCP::Tools::GetAccountInfoTool

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/mathpix/mcp/tools/get_account_info_tool.rb

Overview

Get Account Info Tool

Retrieves account information and plan details Thin delegate to Mathpix::Client (account endpoint)

Class Method Summary collapse

Class Method Details

.call(server_context:) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/mathpix/mcp/tools/get_account_info_tool.rb', line 20

def self.call(server_context:)
  safe_execute do
    client = mathpix_client(server_context)

    # Mathpix's v3 API has no account/plan endpoint for app tokens
    # (/v3/account returns 404). Derive the identifiers it does expose
    # from /v3/ocr-usage and tell the caller where to find plan/limits.
    rows = client.get('/ocr-usage', params: {})['ocr_usage'] || []
    first = rows.first || {}

    response_data = {
      success: true,
      account: {
        app_id: first['app_id'] || client.config.app_id,
        group_id: first['group_id']
      },
      note: 'Mathpix exposes no account/plan endpoint via the API; app_id/group_id are ' \
            'derived from /v3/ocr-usage. View plan, limits, and billing in the Mathpix ' \
            'console at https://console.mathpix.com.'
    }

    json_response(response_data)
  end
end