Grok Management MCP

MCP server for the xAI Management API — API keys, ACLs, audit logs, and billing

दस्तावेज़

mcp-server-grok-management

MCP server for the xAI Management API (management-api.x.ai) — team API keys and billing, over stdio. Pure Rust binary.

Auth uses a management key (not an inference API key) from console.x.aiSettings → Management Keys.

For day-to-day spend questions, start with billing_overview.

Tools (23)

Billing (primary)

ToolAccessNotes
billing_overviewreadDashboard: period spend, headroom, limits, prepaid, PMs, contact
get_invoice_previewreadThis month’s postpaid spend + product breakdown
get_spending_limitsreadSoft/hard limits in USD
set_spending_limitwriteSoft limit in cents; confirm="YES-WRITE"
get_prepaid_balancereadCredit ledger
top_upwriteCharge default PM; confirm="TOP-UP"
list_payment_methodsreadCards / Stripe Link (add cards in console)
set_default_payment_methodwriteconfirm="YES-WRITE"
get_billing_inforeadName / email / address
set_billing_infowriteconfirm="YES-WRITE"
list_invoicesreadOptional year/month/since/invoice_ids filters
get_invoicereadOne invoice + line items
get_usagereadAnalytics (usd sum, group_by, timezone)

API keys

validate_key, list_api_keys, create_api_key, update_api_key, delete_api_key (DELETE), rotate_api_key (ROTATE), check_propagation, list_models, list_endpoints

Audit

list_audit_events

Safety gates

ToolRequired confirm
delete_api_key"DELETE"
rotate_api_key"ROTATE"
set_spending_limit"YES-WRITE"
set_billing_info"YES-WRITE"
set_default_payment_method"YES-WRITE"
top_up"TOP-UP" (charges card)

Money fields are USD cents (e.g. 10000 = $100.00).

Write billing tools need BillingWrite (or full access) on the management key. validate_key reports whether BillingWrite is listed on the key’s ACLs.

Configuration

~/.config/mcp-server-grok-management/config.toml (chmod 600):

management_key = "xai-..."   # console.x.ai → Settings → Management Keys
# team_id = "uuid"           # optional — auto from validate
# base_url = "https://management-api.x.ai"

Build

cargo build --release   # target/release/mcp-server-grok-management
cargo test
./tests/test-stdio.sh

Architecture

No god modules: api/ (HTTP by domain), format/ (pure text), params/ (schemas), tools/ (MCP handlers composed with router_keys + router_billing + router_audit). See CLAUDE.md.

MCP clients

Already wired for Grok (~/.grok/config.toml) and Claude Code (claude mcp add -s user …). Restart the client session if tools don’t appear.

Scope notes

  • Creating management keys themselves is console-only.
  • Adding payment methods is console-only; this server lists them and can set default.
  • Collections / Computer Use / Conversations / Files resources are not in the public Management REST surface (only appear as management-key ACL labels).

Docs