Skip to main content
Glama
ToKiDoO

Advanced Obsidian MCP Server

by ToKiDoO

obsidian_put_file

Create or update files in your Obsidian vault through AI agents using the Local REST API.

Instructions

Create a new file in your vault or update the content of an existing one in your vault.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYesPath to the relevant file (relative to your vault root)
contentYesContent of the file you would like to upload

Implementation Reference

  • The PutContentToolHandler class provides the core implementation of the 'obsidian_put_file' tool. It defines the tool schema and executes the logic by calling api.put_content with filepath and content arguments.
    class PutContentToolHandler(ToolHandler):
       def __init__(self):
           super().__init__(TOOL_PUT_CONTENT)
    
       def get_tool_description(self):
           return Tool(
               name=self.name,
               description="Create a new file in your vault or update the content of an existing one in your vault.",
               inputSchema={
                   "type": "object",
                   "properties": {
                       "filepath": {
                           "type": "string",
                           "description": "Path to the relevant file (relative to your vault root)",
                           "format": "path"
                       },
                       "content": {
                           "type": "string",
                           "description": "Content of the file you would like to upload"
                       }
                   },
                   "required": ["filepath", "content"]
               }
           )
    
       def run_tool(self, args: dict) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
           if "filepath" not in args or "content" not in args:
               raise RuntimeError("filepath and content arguments required")
    
           api.put_content(args.get("filepath", ""), args["content"])
    
           return [
               TextContent(
                   type="text",
                   text=f"Successfully uploaded content to {args['filepath']}"
               )
           ]
  • Input schema definition for the obsidian_put_file tool, specifying filepath and content parameters.
    return Tool(
        name=self.name,
        description="Create a new file in your vault or update the content of an existing one in your vault.",
        inputSchema={
            "type": "object",
            "properties": {
                "filepath": {
                    "type": "string",
                    "description": "Path to the relevant file (relative to your vault root)",
                    "format": "path"
                },
                "content": {
                    "type": "string",
                    "description": "Content of the file you would like to upload"
                }
            },
            "required": ["filepath", "content"]
        }
    )
  • TOOL_MAPPING dictionary registers 'obsidian_put_file' (TOOL_PUT_CONTENT) with its handler class PutContentToolHandler.
    TOOL_MAPPING = {
        tools.TOOL_LIST_FILES_IN_DIR: tools.ListFilesInDirToolHandler,
        tools.TOOL_SIMPLE_SEARCH: tools.SearchToolHandler,
        tools.TOOL_PATCH_CONTENT: tools.PatchContentToolHandler,
        tools.TOOL_PUT_CONTENT: tools.PutContentToolHandler,
        tools.TOOL_APPEND_CONTENT: tools.AppendContentToolHandler,
        tools.TOOL_DELETE_FILE: tools.DeleteFileToolHandler,
        tools.TOOL_COMPLEX_SEARCH: tools.ComplexSearchToolHandler,
        tools.TOOL_BATCH_GET_FILES: tools.BatchGetFilesToolHandler,
        tools.TOOL_PERIODIC_NOTES: tools.PeriodicNotesToolHandler,
        tools.TOOL_RECENT_PERIODIC_NOTES: tools.RecentPeriodicNotesToolHandler,
        tools.TOOL_RECENT_CHANGES: tools.RecentChangesToolHandler,
        tools.TOOL_UNDERSTAND_VAULT: tools.UnderstandVaultToolHandler,
        tools.TOOL_GET_ACTIVE_NOTE: tools.GetActiveNoteToolHandler,
        tools.TOOL_OPEN_FILES: tools.OpenFilesToolHandler,
        tools.TOOL_LIST_COMMANDS: tools.ListCommandsToolHandler,
        tools.TOOL_EXECUTE_COMMANDS: tools.ExecuteCommandsToolHandler,
    }
  • register_tools function instantiates handlers from TOOL_MAPPING (including obsidian_put_file) and adds them to the server.
    def register_tools():
        """Register the selected tools with the server."""
        tools_to_include = parse_include_tools()
        
        registered_count = 0
        for tool_name in tools_to_include:
            if tool_name in TOOL_MAPPING:
                handler_class = TOOL_MAPPING[tool_name]
                handler_instance = handler_class()
                add_tool_handler(handler_instance)
                registered_count += 1
                logger.debug(f"Registered tool: {tool_name}")
        
        logger.info(f"Successfully registered {registered_count} tools")
  • The underlying api.put_content method that performs the HTTP PUT request to the Obsidian API to create or update the file content.
    def put_content(self, filepath: str, content: str) -> Any:
        url = f"{self.get_base_url()}/vault/{filepath}"
        
        def call_fn():
            response = requests.put(
                url, 
                headers=self._get_headers() | {'Content-Type': 'text/markdown'}, 
                data=content,
                verify=self.verify_ssl,
                timeout=self.timeout
            )
            response.raise_for_status()
            return None
    
        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 mentions creating or updating files, implying mutation, but fails to detail critical aspects like whether it overwrites existing content entirely, requires specific permissions, or handles errors. This leaves significant gaps in understanding the tool's 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, efficient sentence that directly states the tool's function without unnecessary words. It is front-loaded and wastes no space, making it highly concise and well-structured for quick comprehension.

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 tool's complexity as a file mutation operation with no annotations and no output schema, the description is insufficient. It lacks details on behavioral traits, error handling, or return values, making it incomplete for safe and effective use by an AI agent in a vault environment.

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, clearly documenting both parameters ('filepath' and 'content'). The description adds no additional semantic details beyond what the schema provides, such as file format constraints or content handling specifics, so it meets the baseline for adequate but unenhanced parameter information.

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 ('create' or 'update') and resource ('file in your vault'), making the purpose evident. However, it does not explicitly differentiate from sibling tools like 'obsidian_append_to_file' or 'obsidian_patch_file', which also modify files, so it lacks sibling distinction for a perfect score.

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, such as 'obsidian_append_to_file' for appending content or 'obsidian_patch_file' for partial updates. It also omits prerequisites like file permissions or vault accessibility, leaving usage context unclear.

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

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