Skip to main content
Glama
Xuanwo

MCP Server for Apache OpenDAL™

by Xuanwo

get_info

Retrieve file metadata from storage services (e.g., S3, Azure Blob) via OpenDAL. Input the resource URI to access detailed file information instantly.

Instructions

Get metadata of file in OpenDAL service Args: uri: resource URI, e.g. mys3://path/to/file Returns: File metadata information

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
uriYes

Implementation Reference

  • The main handler function for the 'get_info' tool. It parses the URI, retrieves metadata using OpendalResource.stat, formats the file path, size, and content type into a string response, and handles errors.
    @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}"
  • Helper function parse_uri used in get_info to parse the input URI into an OpendalResource instance and the file path.
    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)
  • OpendalResource.stat method invoked by get_info to retrieve the file metadata (content_length, content_type).
    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)

Other Tools

Related Tools

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/Xuanwo/mcp-server-opendal'

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