Skip to main content
Glama
snilld-ai
by snilld-ai

upload-file

Upload files to OpenAI Assistants for processing and analysis, enabling document-based interactions through the MCP server.

Instructions

Upload a file for use by assistants

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesThe local path to the file to upload

Implementation Reference

  • Core handler implementation that opens the local file and uploads it to OpenAI using the AsyncOpenAI client with purpose='assistants'.
    async def upload_file(self, file_path: str): try: with open(file_path, "rb") as file: response = await self.client.files.create(file=file, purpose="assistants") return response except Exception as e: logger.error(f"Failed to upload file {file_path}: {str(e)}") raise
  • Registers the 'upload-file' tool in the MCP server's list_tools handler, including its schema for input validation.
    types.Tool( name="upload-file", description="Upload a file for use by assistants", inputSchema={ "type": "object", "properties": { "file_path": {"type": "string", "description": "The local path to the file to upload"} }, "required": ["file_path"] } ),
  • Dispatch logic in the server's call_tool handler that invokes the LLMConnector's upload_file method and formats the response.
    elif name == "upload-file": response = await connector.upload_file(arguments["file_path"]) return [types.TextContent(type="text", text=f"File uploaded: {response.filename}, ID: {response.id}")]

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/snilld-ai/openai-assistant-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server