Skip to main content
Glama
KonMam

s3-mcp

by KonMam

head_object

Retrieve metadata from S3 objects without downloading content. Check object existence, size, type, and version details using conditional headers.

Instructions

Retrieves metadata from an object without returning the object itself.

Args: bucket (str): The name of the bucket. key (str): The key (name) of the object. if_match (Optional[str]): Return object only if its ETag is the same. if_none_match (Optional[str]): Return object only if its ETag is different. version_id (Optional[str]): Version of the object.

Returns: str: JSON formatted S3 response.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bucketYes
keyYes
if_matchNo
if_none_matchNo
version_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The primary handler for the 'head_object' MCP tool, registered via @mcp.tool() decorator. It invokes the helper function and formats the boto3 response as JSON.
    @mcp.tool()
    def head_object(
        bucket: str,
        key: str,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        version_id: Optional[str] = None,
    ) -> str:
        """Retrieves metadata from an object without returning the object itself.
    
        Args:
            bucket (str): The name of the bucket.
            key (str): The key (name) of the object.
            if_match (Optional[str]): Return object only if its ETag is the same.
            if_none_match (Optional[str]): Return object only if its ETag is different.
            version_id (Optional[str]): Version of the object.
    
        Returns:
            str: JSON formatted S3 response.
        """
        result = _head_object_logic(
            bucket=bucket,
            key=key,
            if_match=if_match,
            if_none_match=if_none_match,
            version_id=version_id,
        )
        return format_response(result)
  • Helper function containing the core implementation logic for the head_object tool, constructing parameters and calling boto3's head_object method.
    def _head_object_logic(
        bucket: str,
        key: str,
        if_match: Optional[str] = None,
        if_none_match: Optional[str] = None,
        version_id: Optional[str] = None,
    ) -> Dict[str, Any]:
        """Core logic to retrieve metadata from an object.
    
        Args:
            bucket (str): The S3 bucket name.
            key (str): The S3 object key.
            if_match (Optional[str]): Return object only if its ETag is the same.
            if_none_match (Optional[str]): Return object only if its ETag is different.
            version_id (Optional[str]): Version of the object.
    
        Returns:
            Dict[str, Any]: Raw boto3 response from head_object.
        """
        client = get_s3_client()
        params: Dict[str, Any] = {"Bucket": bucket, "Key": key}
        if if_match:
            params["IfMatch"] = if_match
        if if_none_match:
            params["IfNoneMatch"] = if_none_match
        if version_id:
            params["VersionId"] = version_id
        return client.head_object(**params)
Behavior3/5

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

With no annotations provided, the description carries the full burden. It clearly states this is a read operation ('Retrieves'), which is helpful. However, it doesn't mention authentication requirements, rate limits, error conditions, or what specific metadata is returned. The description adds basic behavioral context but lacks important operational details.

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

Conciseness4/5

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

The description is well-structured with clear sections (purpose, Args, Returns). The opening sentence efficiently states the core purpose. The parameter explanations are concise but informative. There's minimal wasted text, though the Returns section could be slightly more detailed given the output schema exists.

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?

For a read-only metadata retrieval tool with 5 parameters and an output schema, the description is reasonably complete. It explains all parameters and states the return format. However, it could better explain what 'metadata' includes and mention common use cases. The existence of an output schema reduces the need to detail return values.

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

Parameters4/5

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

With 0% schema description coverage, the description must compensate. It provides clear explanations for all 5 parameters in the Args section, adding meaningful context beyond the bare schema. The explanations for if_match, if_none_match, and version_id are particularly valuable. However, it doesn't explain parameter formats or constraints (e.g., bucket naming rules).

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 specific action ('Retrieves metadata') and resource ('from an object'), distinguishing it from siblings like get_object (which returns the object content) and copy_object/delete_object (which modify objects). The phrase 'without returning the object itself' explicitly differentiates it from get_object.

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool ('Retrieves metadata from an object without returning the object itself'), which implicitly suggests using get_object when you need the actual content. However, it doesn't explicitly name alternatives or state when NOT to use this tool, keeping it at a 4 rather than a 5.

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/KonMam/s3-mcp'

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