get_info
Retrieve file metadata from Apache OpenDAL-backed storage services by specifying a resource URI.
Instructions
Get metadata of file in OpenDAL service
Args:
uri: resource URI, e.g. mys3://path/to/file
Returns:
File metadata informationInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uri | Yes |
Implementation Reference
- src/mcp_server_opendal/server.py:133-157 (handler)The 'get_info' tool handler function. It parses a URI using parse_uri(), calls resource.stat(path) to get file metadata, and returns formatted file information (name, size, type). Registered with @mcp.tool() decorator.
# Get file metadata @mcp.tool() async def get_info(uri: str) -> str: """ Get metadata of file in OpenDAL service Args: uri: resource URI, e.g. mys3://path/to/file Returns: File metadata information """ logger.debug(f"Getting file info: {uri}") try: resource, path = parse_uri(uri) metadata = await resource.stat(path) result = f"File: {path}\n" result += f"Size: {metadata.content_length} bytes\n" result += f"Type: {metadata.content_type}\n" return result except Exception as e: logger.error(f"Failed to get file info: {e!s}") return f"Error: {e!s}" - src/mcp_server_opendal/server.py:133-134 (registration)The @mcp.tool() decorator on line 134 registers 'get_info' as an MCP tool.
# Get file metadata @mcp.tool() - The stat() helper method on OpendalResource class, called by get_info to fetch file metadata via self.op.stat(path).
async def stat(self, path: Union[str, os.PathLike]) -> Metadata: """Get metadata for a specific path""" logger.debug(f"Statting path: {path}") return await self.op.stat(path) - The parse_uri() helper function, called by get_info to parse a URI into an OpendalResource instance and path string.
def parse_uri(uri: str) -> Tuple[OpendalResource, str]: """Parse a URI into a resource and path""" from urllib.parse import unquote, urlparse logger.debug(f"Parsing URI: {uri}") parsed = urlparse(uri) scheme = parsed.scheme path = parsed.netloc + parsed.path path = unquote(path) # Decode URL-encoded characters return (OpendalResource(scheme), path)