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
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| filename | No |
Implementation Reference
- src/server.py:523-537 (handler)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"