read
Extracts file content from storage services like S3, Azure Blob Storage, and Google Cloud Storage using a specified URI, returning the content or error details.
Instructions
Read file content from OpenDAL service
Args:
uri: resource URI, e.g. mys3://path/to/file
Returns:
File content or error information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uri | Yes |
Implementation Reference
- src/mcp_server_opendal/server.py:113-131 (handler)The main handler function for the 'read' MCP tool. It parses the input URI, retrieves the appropriate OpenDAL resource, calls the opendal_resource template to read the file content and metadata, formats the response (text or base64-encoded binary), and handles errors.async def read(uri: str) -> Dict[str, Any]: """ Read file content from OpenDAL service Args: uri: resource URI, e.g. mys3://path/to/file Returns: File content or error information """ logger.debug(f"Reading file content: {uri}") try: resource, path = parse_uri(uri) # Directly call the resource function to get content return await opendal_resource(resource.scheme, path) except Exception as e: logger.error(f"Failed to read file content: {e!s}") return {"error": str(e)}