list_models
Retrieve available AI models from the Grok MCP server to select appropriate capabilities for tasks like text generation, vision processing, and file support.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.py:88-110 (handler)The implementation of the `list_models` tool which queries the xAI API for both language and image generation models and formats the results for the MCP output.
@mcp.tool(annotations=READONLY) async def list_models(): client = Client(api_key=XAI_API_KEY) models_info = [] models_info.append("# Language Models\n") for m in client.models.list_language_models(): date = m.created.ToDatetime().strftime('%d %b %Y') inp = m.prompt_text_token_price / 10000 out = m.completion_text_token_price / 10000 models_info.append(f"**{m.name}** — {date}") models_info.append(f" Input: ${inp:g}/M · Output: ${out:g}/M\n") models_info.append("# Image Generation Models\n") for m in client.models.list_image_generation_models(): date = m.created.ToDatetime().strftime('%d %b %Y') price = m.image_price / 10000000000 models_info.append(f"**{m.name}** — {date}") models_info.append(f" ${price:g} per image\n") client.close() return "\n".join(models_info)