list_models
Retrieve all available models for use with the Grok API to facilitate seamless integration and selection for AI tasks.
Instructions
List all models available for use with the Grok API
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/operations/models.ts:24-29 (handler)The core handler function for listing models. It makes a request to the 'models' endpoint via grokRequest and parses the response using ListModelsResponseSchema.export async function listModels(): Promise< z.infer<typeof ListModelsResponseSchema> > { const response = await grokRequest("models"); return ListModelsResponseSchema.parse(response); }
- src/operations/models.ts:12-15 (schema)Zod schema for validating the list models API response, containing an array of ModelSchema objects.export const ListModelsResponseSchema = z.object({ object: z.string(), data: z.array(ModelSchema), });
- src/operations/models.ts:5-10 (schema)Zod schema defining the structure of a single model object, used within ListModelsResponseSchema.export const ModelSchema = z.object({ id: z.string(), created: z.number().optional(), object: z.string(), owned_by: z.string().optional(), });
- src/operations/models.ts:17-18 (schema)Empty Zod schema for list models input options (no parameters required).export const ListModelsOptionsSchema = z.object({});
- index.ts:69-81 (registration)Tool registration in the FastMCP server. Specifies the tool name, description, input schema, and an execute handler that calls the core listModels function and stringifies the result.server.addTool({ name: "list_models", description: "List all models available for use with the Grok API", parameters: models.ListModelsOptionsSchema, execute: async () => { try { const result = await models.listModels(); return JSON.stringify(result, null, 2); } catch (err) { handleError(err); } }, });