Skip to main content
Glama

list_models

Retrieve available AI models from the Grok API to select appropriate ones for text generation, vision tasks, or file processing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The list_models tool handler that retrieves and formats available language and image generation models from the XAI API. Creates a client, lists models with their creation dates, and returns them as a formatted string.
    @mcp.tool() async def list_models(): client = Client(api_key=XAI_API_KEY) models_info = [] models_info.append("## Language Models") for model in client.models.list_language_models(): models_info.append(f"- {model.name} ({model.created.ToDatetime().strftime('%d %B %Y')})") models_info.append("\n## Image Generation Models") for model in client.models.list_image_generation_models(): models_info.append(f"- {model.name} ({model.created.ToDatetime().strftime('%d %B %Y')})") client.close() return "\n".join(models_info)
  • src/server.py:17-17 (registration)
    The @mcp.tool() decorator registers the list_models function as an MCP tool, automatically exposing it to the MCP server.
    @mcp.tool()
  • XAI_API_KEY constant imported and used by list_models to authenticate with the XAI API when retrieving model information.
    XAI_API_KEY = os.getenv("XAI_API_KEY", "") if XAI_API_KEY: os.environ["XAI_API_KEY"] = XAI_API_KEY

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