Skip to main content
Glama
MarkusPfundstein

MCP server for Obsidian

obsidian_get_file_contents

Retrieve content from Obsidian vault files using the MCP server to access specific document text for processing or analysis.

Instructions

Return the content of a single file in your vault.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYesPath to the relevant file (relative to your vault root).

Implementation Reference

  • The `run_tool` method of `GetFileContentsToolHandler` that executes the core tool logic: checks for filepath argument, instantiates Obsidian API client, fetches file contents, and returns as JSON-formatted TextContent.
    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
        if "filepath" not in args:
            raise RuntimeError("filepath argument missing in arguments")
    
        api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
    
        content = api.get_file_contents(args["filepath"])
    
        return [
            TextContent(
                type="text",
                text=json.dumps(content, indent=2)
            )
        ]
  • The `get_tool_description` method returning the Tool object with input schema defining the required 'filepath' parameter.
    def get_tool_description(self):
        return Tool(
            name=self.name,
            description="Return the content of a single file in your vault.",
            inputSchema={
                "type": "object",
                "properties": {
                    "filepath": {
                        "type": "string",
                        "description": "Path to the relevant file (relative to your vault root).",
                        "format": "path"
                    },
                },
                "required": ["filepath"]
            }
        )
  • Registers the `GetFileContentsToolHandler` instance in the global tool_handlers dictionary used by the MCP server.
    add_tool_handler(tools.GetFileContentsToolHandler())
  • The `get_file_contents` method in the `Obsidian` class that sends an HTTP GET request to the Obsidian API endpoint to retrieve and return the raw text content of the specified file.
    def get_file_contents(self, filepath: str) -> Any:
        url = f"{self.get_base_url()}/vault/{filepath}"
    
        def call_fn():
            response = requests.get(url, headers=self._get_headers(), verify=self.verify_ssl, timeout=self.timeout)
            response.raise_for_status()
            
            return response.text
    
        return self._safe_call(call_fn)
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 states the action ('Return the content') but lacks details on error handling (e.g., if the file doesn't exist), performance aspects (e.g., file size limits), or output format (e.g., plain text, Markdown). This is a significant gap for a tool with potential read operations and no structured safety hints.

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, clear sentence with zero wasted words. It's front-loaded with the core action and resource, making it highly efficient and easy to parse. Every part of the sentence earns its place by directly contributing to understanding the tool's purpose.

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 the complexity of file operations and the lack of annotations and output schema, the description is incomplete. It doesn't address key contextual elements like error cases (e.g., missing files), return value details (e.g., content format), or how it fits into the broader vault management context with siblings. This leaves gaps for safe and effective tool invocation.

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?

The input schema has 100% description coverage, with the 'filepath' parameter well-documented in the schema itself. The description doesn't add any extra meaning beyond what the schema provides (e.g., it doesn't clarify path formatting examples or vault-specific nuances), so it meets the baseline for high schema coverage without compensating value.

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

Purpose4/5

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

The description clearly states the verb ('Return') and resource ('content of a single file'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'obsidian_batch_get_file_contents' (which handles multiple files) or 'obsidian_simple_search' (which might return content with search filtering), leaving some ambiguity about when to choose this exact tool.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention scenarios like preferring 'obsidian_batch_get_file_contents' for multiple files or 'obsidian_simple_search' for filtered content, nor does it specify prerequisites like file existence. This lack of context makes it harder for an agent to select the correct tool among siblings.

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