Skip to main content
Glama

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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)

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/merterbak/Grok-MCP'

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