Skip to main content
Glama

list_files

Retrieve and organize files from the Grok MCP server by applying filters, sorting options, and pagination controls.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNo
orderNodesc
sort_byNocreated_at

Implementation Reference

  • The list_files tool handler implementation. This async function lists uploaded files from the XAI API with configurable limit (default 100), order (default 'desc'), and sort_by (default 'created_at') parameters. It returns a formatted string showing file ID, filename, and size for each file.
    @mcp.tool() async def list_files( limit: int = 100, order: str = "desc", sort_by: str = "created_at" ): client = Client(api_key=XAI_API_KEY) response = client.files.list(limit=limit, order=order, sort_by=sort_by) client.close() if not response.data: return "No files found." result = ["**Files:**\n"] for f in response.data: result.append(f"- `{f.id}` — {f.filename} ({f.size} bytes)") return "\n".join(result)
  • src/server.py:456-456 (registration)
    The @mcp.tool() decorator on line 456 registers the list_files function as an MCP tool, making it available to clients through the FastMCP server.
    @mcp.tool()

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