Skip to main content
Glama
j-shelfwood

Obsidian Local REST API MCP Server

by j-shelfwood

write_file

Create or update files in an Obsidian vault by writing content. Choose modes: overwrite, append, or prepend. Simplifies file management via REST API.

Instructions

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

Input Schema

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

Implementation Reference

  • Core handler function in ObsidianApiClient that executes the write_file tool by making a POST request to the Obsidian REST API's /files/write endpoint.
    async writeFile(path: string, content: string, mode: string = "overwrite") { return this.request("/files/write", { method: "POST", body: JSON.stringify({ path, content, mode }), }); }
  • Schema and definition for the write_file tool, including input schema with parameters path (required), content (required), and mode (optional with enum).
    { 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 CallToolRequestHandler switch statement that routes write_file tool calls to the client.writeFile method.
    case "write_file": result = await this.client.writeFile( args?.path as string, args?.content as string, args?.mode as string ); break;

Other Tools

Related 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