Skip to main content
Glama
MarkusPfundstein

MCP server for Obsidian

obsidian_batch_get_file_contents

Retrieve and combine content from multiple Obsidian vault files at once to streamline research and content management workflows.

Instructions

Return the contents of multiple files in your vault, concatenated with headers.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathsYesList of file paths to read

Implementation Reference

  • The run_tool method that executes the core logic of the 'obsidian_batch_get_file_contents' tool. It validates input, instantiates the Obsidian API client, fetches batch file contents, and returns them wrapped in TextContent.
    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
        if "filepaths" not in args:
            raise RuntimeError("filepaths argument missing in arguments")
    
        api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
        content = api.get_batch_file_contents(args["filepaths"])
    
        return [
            TextContent(
                type="text",
                text=content
            )
        ]
  • Defines the Tool schema including name, description, and inputSchema requiring an array of filepaths.
    def get_tool_description(self):
        return Tool(
            name=self.name,
            description="Return the contents of multiple files in your vault, concatenated with headers.",
            inputSchema={
                "type": "object",
                "properties": {
                    "filepaths": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "description": "Path to a file (relative to your vault root)",
                            "format": "path"
                        },
                        "description": "List of file paths to read"
                    },
                },
                "required": ["filepaths"]
            }
        )
  • Registers the BatchGetFileContentsToolHandler instance with the MCP server using add_tool_handler.
    add_tool_handler(tools.BatchGetFileContentsToolHandler())
  • Supporting utility in Obsidian class that implements the batch file reading logic: loops through filepaths, fetches individual contents, formats with headers and separators, handles errors gracefully.
    def get_batch_file_contents(self, filepaths: list[str]) -> str:
        """Get contents of multiple files and concatenate them with headers.
        
        Args:
            filepaths: List of file paths to read
            
        Returns:
            String containing all file contents with headers
        """
        result = []
        
        for filepath in filepaths:
            try:
                content = self.get_file_contents(filepath)
                result.append(f"# {filepath}\n\n{content}\n\n---\n\n")
            except Exception as e:
                # Add error message but continue processing other files
                result.append(f"# {filepath}\n\nError reading file: {str(e)}\n\n---\n\n")
                
        return "".join(result)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions concatenation with headers, which adds useful context beyond the schema, but fails to address critical aspects like error handling (e.g., if a file doesn't exist), performance implications for large batches, or output format details. This is inadequate for a tool with mutation-like behavior (reading multiple files).

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 a single, efficient sentence that front-loads the core functionality ('Return the contents of multiple files') and adds key behavioral detail ('concatenated with headers'). Every word earns its place with zero waste.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete. It lacks details on return values (e.g., format of concatenated output, error responses), and while concise, doesn't compensate for the missing structured data. For a batch operation tool, this leaves significant gaps in understanding its full behavior.

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 100%, so the schema already fully documents the 'filepaths' parameter. The description adds no additional parameter semantics beyond what's in the schema (e.g., no details on header format, ordering, or path validation). Baseline 3 is appropriate as the schema handles the heavy lifting.

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 tool's purpose with a specific verb ('Return') and resource ('contents of multiple files'), and distinguishes it from the sibling 'obsidian_get_file_contents' by specifying batch processing and concatenation with headers. This provides precise differentiation from the single-file version.

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 implies usage context by mentioning 'multiple files' and 'concatenated with headers', which suggests it's for bulk reading with formatted output. However, it doesn't explicitly state when to use this versus alternatives like 'obsidian_get_file_contents' for single files or 'obsidian_list_files_in_dir' for metadata only, leaving some guidance gaps.

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

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