Skip to main content
Glama

upload_file

Upload files to the Grok MCP server for processing with AI capabilities including vision analysis, content generation, and agentic tool calling.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
filenameNo

Implementation Reference

  • The implementation of the 'upload_file' MCP tool, which uploads a file via the xAI client and returns the file ID, name, and size.
    @mcp.tool()
    async def upload_file(
        file_path: str,
        filename: Optional[str] = None
    ):
        client = Client(api_key=XAI_API_KEY)
        
        path = Path(file_path)
        if not path.exists():
            raise FileNotFoundError(f"File not found {file_path}")
        
        uploaded = client.files.upload(file_path)
        client.close()
        
        return f"**File uploaded successfully**\n- **File ID:** `{uploaded.id}`\n- **Filename:** {uploaded.filename}\n- **Size:** {uploaded.size} bytes"

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