Skip to main content
Glama
j-shelfwood

Obsidian Local REST API MCP Server

by j-shelfwood

write_file

Create or modify files in Obsidian vaults by writing content with options to overwrite, append, or prepend text to existing files.

Instructions

Write file content with different modes: overwrite (default), append, or prepend. Handles both create and update operations.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to the file
contentYesContent to write
modeNoWrite modeoverwrite

Implementation Reference

  • Core handler function in ObsidianApiClient that performs the HTTP POST request to the Obsidian REST API's /files/write endpoint, passing path, content, and mode parameters to write or update the file.
    async writeFile(path: string, content: string, mode: string = "overwrite") {
      return this.request("/files/write", {
        method: "POST",
        body: JSON.stringify({ path, content, mode }),
      });
    }
  • Input schema and metadata definition for the write_file tool, including required path and content, optional mode (overwrite/append/prepend), description, and name.
    {
      name: "write_file",
      description: "Write file content with different modes: overwrite (default), append, or prepend. Handles both create and update operations.",
      inputSchema: {
        type: "object",
        properties: {
          path: { type: "string", description: "Path to the file" },
          content: { type: "string", description: "Content to write" },
          mode: { type: "string", enum: ["overwrite", "append", "prepend"], description: "Write mode", default: "overwrite" },
        },
        required: ["path", "content"],
      },
    },
  • src/index.ts:464-470 (registration)
    Registration and dispatching logic in the CallToolRequestSchema handler's switch statement, which maps incoming write_file tool calls to the client.writeFile execution.
    case "write_file":
      result = await this.client.writeFile(
        args?.path as string,
        args?.content as string,
        args?.mode as string
      );
      break;
Behavior2/5

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

No annotations are provided, so the description carries full burden. It discloses behavioral traits like modes (overwrite, append, prepend) and handling create/update operations, but lacks critical details: permissions required, error handling (e.g., if file doesn't exist), side effects (e.g., data loss in overwrite), or response format. For a mutation tool with zero annotation coverage, this is insufficient.

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 concise and front-loaded: two sentences that efficiently convey core functionality without waste. Every sentence earns its place by stating the action and key features (modes, create/update).

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 (mutation with modes), lack of annotations, and no output schema, the description is incomplete. It should explain more about behavioral aspects like safety warnings (e.g., overwrite destroys data), prerequisites, or return values. The current text leaves gaps that could hinder correct agent usage.

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 documents all parameters (path, content, mode with enum and default). The description adds minimal value by mentioning modes and default behavior, but does not explain parameter interactions or provide examples. Baseline 3 is appropriate as the schema handles most semantics.

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 tool's purpose: 'Write file content with different modes: overwrite (default), append, or prepend. Handles both create and update operations.' It specifies the verb ('write'), resource ('file content'), and scope (create/update operations with modes). However, it does not explicitly distinguish from sibling tools like 'create_or_update_note' or 'read_file', which could cause confusion in a file system context.

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 mentions modes but does not specify scenarios for overwrite, append, or prepend, nor does it reference sibling tools like 'read_file' for reading or 'delete_item' for removal. Without context, an agent might misuse it in place of other file operations.

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/j-shelfwood/obsidian-local-rest-api-mcp'

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