list-files
Retrieve available files for OpenAI assistants to access and use in conversations.
Instructions
List files available for assistants
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp_server_openai/server.py:112-116 (registration)Registration of the 'list-files' tool in the list_tools handler, including its input schema (empty object) and description.types.Tool( name="list-files", description="List files available for assistants", inputSchema={"type": "object", "properties": {}} ),
- src/mcp_server_openai/server.py:197-202 (handler)MCP tool handler for 'list-files': calls LLMConnector.list_files(), formats the list of files into a string, and returns as TextContent.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)Core implementation of file listing in LLMConnector: asynchronously lists OpenAI files with purpose='assistants' using the OpenAI client.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