list-files
Retrieve available files for OpenAI assistants to access and use in conversations or tasks.
Instructions
List files available for assistants
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list-files"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_server_openai/server.py:197-202 (handler)Handler logic for the 'list-files' tool, which delegates to LLMConnector.list_files() and formats the list of files as text content.
elif name == "list-files": response = await connector.list_files() files_str = "\\n".join([f"- ID: {f.id}, Name: {f.filename}, Size: {f.bytes} bytes" for f in response]) if not files_str: files_str = "No files found." return [types.TextContent(type="text", text=f"Available Files:\\n{files_str}")] - src/mcp_server_openai/llm.py:96-102 (helper)The core implementation of listing OpenAI assistant files using the OpenAI client API.
async def list_files(self): try: response = await self.client.files.list(purpose="assistants") return response.data except Exception as e: logger.error(f"Failed to list files: {str(e)}") raise - src/mcp_server_openai/server.py:112-116 (registration)Registration of the 'list-files' tool in the server's list_tools() method, including its schema with no required inputs.
types.Tool( name="list-files", description="List files available for assistants", inputSchema={"type": "object", "properties": {}} ),