Skip to main content
Glama
Xuanwo

MCP Server for Apache OpenDAL™

by Xuanwo

read

Read file content from any storage service supported by Apache OpenDAL by providing a resource URI.

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
NameRequiredDescriptionDefault
uriYes

Implementation Reference

  • The 'read' tool handler function registered via @mcp.tool(). Accepts a URI (e.g., mys3://path/to/file), parses it, and delegates to opendal_resource() which reads file content via OpenDAL.
    @mcp.tool()
    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)}
  • The read_path method on OpendalResource that actually calls await self.op.read(path) to read raw bytes from storage.
    async def read_path(self, path: Union[str, os.PathLike]) -> bytes:
        """Read content from a specific path"""
        logger.debug(f"Reading path: {path}")
        return await self.op.read(path)
  • The parse_uri helper that parses a URI string into an (OpendalResource, path) tuple used by the read tool.
    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)
  • The opendal_resource template resource handler (@mcp.resource) that the read tool delegates to. Reads file bytes via resource.read_path(), returns decoded text or base64-encoded binary content.
    @mcp.resource("{scheme}://{path}")
    async def opendal_resource(scheme: str, path: str) -> Dict[str, Any]:
        """
        Access files in OpenDAL service
    
        Args:
            scheme: storage service scheme
            path: file path
    
        Returns:
            Dictionary containing file content and metadata
        """
        logger.debug(f"Reading template resource content: {scheme}://{path}")
        try:
            resource = OpendalResource(scheme)
            data = await resource.read_path(path)
            metadata = await resource.stat(path)
    
            if resource.is_text_file(path):
                return {
                    "content": data.decode("utf-8"),
                    "mime_type": metadata.content_type or "text/plain",
                    "size": metadata.content_length,
                    "is_binary": False,
                }
            else:
                return {
                    "content": base64.b64encode(data).decode("ascii"),
                    "mime_type": metadata.content_type or "application/octet-stream",
                    "size": metadata.content_length,
                    "is_binary": True,
                }
        except Exception as e:
            logger.error(f"Failed to read resource: {e!s}")
            return {"error": str(e)}
  • The @mcp.tool() decorator registration for the 'read' tool on line 112.
    @mcp.tool()
    async def read(uri: str) -> Dict[str, Any]:
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description must fully convey behavior. It only states 'Read file content' and mentions 'Returns: File content or error information', but does not disclose read-only semantics, potential side effects, or limitations (e.g., file size, permissions).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise, using only three lines to convey purpose, argument, and return value. Every sentence is necessary and front-loaded with the primary function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity of the tool (single parameter, no output schema), the description covers the core functionality and return type. Minor gaps exist (e.g., no size limits or error details), but it is largely complete for a basic read operation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must clarify parameters. It provides an example URI ('mys3://path/to/file') and labels the parameter as 'resource URI', adding some meaning beyond the raw schema. However, it does not explain the format or constraints fully.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action 'Read file content' and the resource 'from OpenDAL service', using a specific verb and object. It distinguishes from sibling tools 'get_info' and 'list' which imply different operations.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives. There is no mention of context, prerequisites, or when not to use it, leaving the agent to infer.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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