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;

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