Skip to main content
Glama
MarkusPfundstein

MCP server for Obsidian

obsidian_patch_content

Insert content into Obsidian notes relative to headings, blocks, or frontmatter fields using append, prepend, or replace operations.

Instructions

Insert content into an existing note relative to a heading, block reference, or frontmatter field.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYesPath to the file (relative to vault root)
operationYesOperation to perform (append, prepend, or replace)
target_typeYesType of target to patch
targetYesTarget identifier (heading path, block reference, or frontmatter field)
contentYesContent to insert

Implementation Reference

  • Registers the PatchContentToolHandler for the 'obsidian_patch_content' tool.
    add_tool_handler(tools.PatchContentToolHandler())
  • Executes the tool by validating arguments and calling obsidian.patch_content API method.
    def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
        if not all(k in args for k in ["filepath", "operation", "target_type", "target", "content"]):
            raise RuntimeError("filepath, operation, target_type, target and content arguments required")
    
        api = obsidian.Obsidian(api_key=api_key, host=obsidian_host)
        api.patch_content(
            args.get("filepath", ""),
            args.get("operation", ""),
            args.get("target_type", ""),
            args.get("target", ""),
            args.get("content", "")
        )
    
        return [
            TextContent(
                type="text",
                text=f"Successfully patched content in {args['filepath']}"
            )
        ]
  • Defines the input schema and description for the obsidian_patch_content tool.
    def get_tool_description(self):
        return Tool(
            name=self.name,
            description="Insert content into an existing note relative to a heading, block reference, or frontmatter field.",
            inputSchema={
                "type": "object",
                "properties": {
                    "filepath": {
                        "type": "string",
                        "description": "Path to the file (relative to vault root)",
                        "format": "path"
                    },
                    "operation": {
                        "type": "string",
                        "description": "Operation to perform (append, prepend, or replace)",
                        "enum": ["append", "prepend", "replace"]
                    },
                    "target_type": {
                        "type": "string",
                        "description": "Type of target to patch",
                        "enum": ["heading", "block", "frontmatter"]
                    },
                    "target": {
                        "type": "string", 
                        "description": "Target identifier (heading path, block reference, or frontmatter field)"
                    },
                    "content": {
                        "type": "string",
                        "description": "Content to insert"
                    }
                },
                "required": ["filepath", "operation", "target_type", "target", "content"]
            }
        )
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks critical behavioral details. It doesn't disclose whether this operation is destructive (e.g., 'replace' operation could overwrite content), what happens if the target doesn't exist, error conditions, or formatting expectations. For a mutation tool with 5 parameters, this leaves significant gaps in understanding tool behavior.

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, well-structured sentence that efficiently communicates the core functionality without unnecessary words. Every element (verb, resource, method) earns its place, making it easy to parse and understand at a glance.

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?

For a mutation tool with 5 parameters, no annotations, and no output schema, the description is insufficient. It doesn't cover behavioral aspects (destructiveness, error handling), doesn't explain return values, and provides minimal parameter guidance beyond what's in the schema. Given the complexity, more context about how operations work and what to expect is needed.

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%, providing clear documentation for all 5 parameters. The description adds minimal value beyond schema, only vaguely referencing parameter concepts ('heading, block reference, or frontmatter field' relates to target_type/target). No additional syntax, format details, or examples are provided, so baseline 3 is appropriate.

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 ('Insert content'), target resource ('existing note'), and positioning method ('relative to a heading, block reference, or frontmatter field'). It distinguishes from siblings like obsidian_append_content (which likely appends to end of file) and obsidian_put_content (which likely replaces entire file) by specifying targeted insertion.

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 specifying 'relative to a heading, block reference, or frontmatter field,' suggesting this tool is for targeted modifications rather than whole-file operations. However, it doesn't explicitly state when to choose this over alternatives like obsidian_append_content or obsidian_put_content, nor does it mention prerequisites like file existence.

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