uploadContentFileAboutOrganization
Upload organizational content files to the Content Server, specifying file content, name, and user roles for secure storage and management.
Instructions
Upload content file about the organization
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | The file content to upload | |
| fileName | Yes | The file name | |
| role | No | The roles of the user |
Implementation Reference
- rag_tools.py:51-64 (handler)The handler function implementing the tool logic. It receives file content, filename, and optional role, then calls RagService.upload_file to perform the upload and returns a success message.def upload_content_file_about_organization(self, file: str, file_name: str, role: str = "") -> list[str]: """ Upload content file about the organization. Args: file: The file content to upload file_name: The file name (required) role: The roles of the user Returns: Success message """ self.rag_service.upload_file(file, file_name, role, self.user_id_from_environment) return ["File uploaded successfully"]
- mcp_server.py:91-109 (schema)JSON input schema defining parameters: file (required string), fileName (required string), role (optional string).inputSchema={ "type": "object", "properties": { "file": { "type": "string", "description": "The file content to upload" }, "fileName": { "type": "string", "description": "The file name" }, "role": { "type": "string", "description": "The roles of the user" } }, "required": ["file", "fileName"], "additionalProperties": False }
- mcp_server.py:164-173 (registration)Tool dispatch logic in the MCP call_tool handler, validating arguments and invoking the RagTools handler.elif name == "uploadContentFileAboutOrganization": if "file" not in arguments or "fileName" not in arguments: raise ValueError("file and fileName parameters are required") result = rag_tools.upload_content_file_about_organization( arguments["file"], arguments["fileName"], arguments.get("role", "") ) logger.debug(f"Tool {name} executed successfully") return [types.TextContent(type="text", text=str(result))]
- rag_service.py:58-82 (helper)Supporting function that handles the actual file upload via HTTP POST to the content service, including temp file creation and cleanup.def upload_file(self, content: str, file_name: str, role: str, user_id: str = "invalid") -> None: """Upload content file about the organization""" url = f"{self.content_service_url}/contents/file" headers = {'userId': user_id} # Create temporary file temp_file = self._convert_string_to_file(content, file_name) try: with open(temp_file, 'rb') as f: files = {'file': (file_name, f, 'text/plain')} data = { 'role': role, 'userId': user_id } response = requests.post(url, files=files, data=data, headers=headers) response.raise_for_status() except requests.RequestException as e: print(f"Error uploading file: {e}") raise finally: # Clean up temporary file if temp_file.exists(): temp_file.unlink()