Skip to main content
Glama

obsidian_batch_get_file_contents

Read-onlyIdempotent

Read multiple related notes simultaneously to understand connections and context before creating new atomic notes in your Zettelkasten workflow.

Instructions

Read multiple files at once, concatenated with headers.

Efficient way to read several related Zettelkasten notes together to understand
connections and context before creating new atomic notes.

Args:
    params (BatchGetFilesInput): Contains:
        - filepaths (List[str]): List of file paths to read (max 20)

Returns:
    str: All file contents concatenated with clear separators
    
Example:
    Reads multiple related notes to understand a concept network.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function that implements the core logic of the 'obsidian_batch_get_file_contents' tool. It iterates over the provided list of filepaths, reads each file's content using obsidian_client.read_file(), formats them with headers and error handling, concatenates the results, and applies truncation if necessary.
    @mcp.tool(
        name="obsidian_batch_get_file_contents",
        annotations={
            "title": "Batch Get File Contents",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": False
        }
    )
    async def batch_get_files(params: BatchGetFilesInput) -> str:
        """Read multiple files at once, concatenated with headers.
        
        Efficient way to read several related Zettelkasten notes together to understand
        connections and context before creating new atomic notes.
        
        Args:
            params (BatchGetFilesInput): Contains:
                - filepaths (List[str]): List of file paths to read (max 20)
        
        Returns:
            str: All file contents concatenated with clear separators
            
        Example:
            Reads multiple related notes to understand a concept network.
        """
        results = []
        
        for filepath in params.filepaths:
            try:
                content = await obsidian_client.read_file(filepath)
                results.append(f"# File: {filepath}\n\n{content}\n\n{'='*80}\n")
            except ObsidianAPIError as e:
                results.append(f"# File: {filepath}\n\nError: {str(e)}\n\n{'='*80}\n")
        
        output = "\n".join(results)
        return truncate_response(output, "batch file read")
  • Pydantic input schema/model for the tool, defining a list of up to 20 file paths as strings.
    class BatchGetFilesInput(BaseModel):
        """Input for batch reading multiple files."""
        model_config = ConfigDict(str_strip_whitespace=True, extra='forbid')
        
        filepaths: List[str] = Field(
            description="List of file paths to read",
            min_items=1,
            max_items=20
        )
  • Utility helper function called by the handler to truncate overly long responses, ensuring they fit within limits.
    def truncate_response(content: str, description: str = "response") -> str:
        """Truncate content if it exceeds CHARACTER_LIMIT."""
        if len(content) <= CHARACTER_LIMIT:
            return content
        
        truncated = content[:CHARACTER_LIMIT]
        message = f"\n\n[Response truncated at {CHARACTER_LIMIT} characters. Original {description} was {len(content)} characters. Use filters or pagination to reduce results.]"
        return truncated + message
  • The MCP tool registration decorator that registers the batch_get_files function with the name 'obsidian_batch_get_file_contents' and appropriate annotations.
    @mcp.tool(
        name="obsidian_batch_get_file_contents",
        annotations={
            "title": "Batch Get File Contents",
            "readOnlyHint": True,
            "destructiveHint": False,
            "idempotentHint": True,
            "openWorldHint": False
        }
    )
Behavior4/5

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

Annotations already provide readOnlyHint=true, destructiveHint=false, idempotentHint=true, and openWorldHint=false. The description adds valuable behavioral context beyond annotations: it specifies that contents are concatenated with clear separators, mentions the maximum of 20 files, and explains the efficiency rationale for batch reading related notes. No contradiction with annotations.

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, Example) and front-loaded key information. It's appropriately sized, though the example could be more concrete. Every sentence adds value without redundancy.

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

Completeness5/5

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

Given the tool's moderate complexity, rich annotations (read-only, idempotent), and the presence of an output schema (returns str), the description is complete. It covers purpose, usage context, parameter semantics, and behavioral details like concatenation and limits, leaving output specifics to the schema.

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%, but the description compensates by explaining the 'filepaths' parameter in the Args section, including the max 20 constraint. However, it doesn't provide format details (e.g., path syntax, relative/absolute) or error handling. With one parameter documented, this meets the baseline for adequate coverage.

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 ('Read multiple files at once, concatenated with headers') and distinguishes it from sibling tools like 'obsidian_get_file_contents' (single file) and 'obsidian_search' (search-based). It explicitly mentions the Zettelkasten context and purpose of understanding connections between notes.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool: 'Efficient way to read several related Zettelkasten notes together to understand connections and context before creating new atomic notes.' It distinguishes this batch operation from single-file reading and suggests it's for preparatory analysis of related notes.

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/Shepherd-Creative/obsidian-mcp'

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