Skip to main content
Glama
YanceyOfficial

Obsidian iCloud MCP

write_file

Write or overwrite text files in Obsidian iCloud vaults, ensuring proper encoding and handling specific paths under the Documents/my-vault directory.

Instructions

Your task is to write file to an appropriate path under /Users/username/Library/Mobile Documents/iCloud~md~obsidian/Documents/my-vault. The path you'll write should follow user's instruction and make sure it hasn't been occupied.Create a new file or completely overwrite an existing file with new content. Use with caution as it will overwrite existing files without warning. Handles text content with proper encoding. Only works within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes
pathYes

Implementation Reference

  • The core handler function that implements the write_file tool. It validates input using WriteFileArgsSchema, writes the file content to the specified path using fs.writeFile, and returns a success message.
    export async function writeFile(args?: Record<string, unknown>) {
      const parsed = WriteFileArgsSchema.safeParse(args)
      if (!parsed.success) {
        throw new Error(`Invalid arguments for write_file: ${parsed.error}`)
      }
    
      await fs.writeFile(parsed.data.path, parsed.data.content, 'utf-8')
      return {
        content: [
          { type: 'text', text: `Successfully wrote to ${parsed.data.path}` }
        ]
      }
    }
  • Zod schema defining the input parameters for the write_file tool: path (string) and content (string). Used for validation in the handler.
    export const WriteFileArgsSchema = z.object({
      path: z.string(),
      content: z.string()
    })
  • src/index.ts:110-114 (registration)
    Tool registration in the ListToolsRequestHandler response. Specifies the tool name 'write_file', a dynamic description generated by writeFilePrompt, and the input schema converted to JSON schema.
    {
      name: 'write_file',
      description: writeFilePrompt(args),
      inputSchema: zodToJsonSchema(WriteFileArgsSchema) as ToolInput
    },
  • src/index.ts:179-181 (registration)
    Dispatch logic in the CallToolRequestHandler switch statement that routes 'write_file' calls to the writeFile handler function.
    case 'write_file': {
      return writeFile(args)
    }
  • Helper function that generates the tool description/prompt for write_file, incorporating the allowed root paths for safety.
    export const writeFilePrompt = (rootPaths: string[]) =>
      `Your task is to write file to an appropriate path under ${rootPaths.join(', ')}. ` +
      "The path you'll write should follow user's instruction and make sure it hasn't been occupied." +
      'Create a new file or completely overwrite an existing file with new content. ' +
      'Use with caution as it will overwrite existing files without warning. ' +
      'Handles text content with proper encoding. Only works within allowed directories.'
Behavior4/5

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

No annotations are provided, so the description carries the full burden. It discloses key behavioral traits: it can create new files or overwrite existing ones without warning (destructive), handles text content with proper encoding, and is restricted to allowed directories. However, it lacks details on error handling, permissions, or rate limits, which are important for a write operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with four sentences that are front-loaded: it starts with the core task, then details behavior, warnings, and constraints. Every sentence adds value, such as the caution about overwriting and directory restrictions, but minor redundancy exists (e.g., 'write file' and 'Create a new file' could be streamlined).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given complexity (a write operation with 2 parameters, no annotations, no output schema), the description is somewhat complete but has gaps. It covers purpose, behavior, and parameters adequately, but lacks details on return values (e.g., success/failure indicators), error cases, or specific encoding standards, which are important for agent invocation in this context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It adds meaning by explaining that 'path' should be 'an appropriate path under /Users/username/Library/Mobile Documents/iCloud~md~obsidian/Documents/my-vault' and must not be occupied, and 'content' is 'text content with proper encoding'. This clarifies usage beyond the bare schema, though it could specify path format or content constraints more precisely.

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 verb 'write file' and specifies the resource as files under a specific directory path. It distinguishes from siblings by explicitly stating it 'Create[s] a new file or completely overwrite[s] an existing file', unlike edit_file which might imply partial updates, and unlike read_file or list_directory which are read-only operations.

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 provides clear context on when to use this tool: for writing files to a specific directory with text content. It implies alternatives by mentioning 'overwrite existing files', suggesting edit_file might be for modifications without full overwrites, but does not explicitly name when-not scenarios or list all sibling alternatives like create_directory for directories instead of files.

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

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

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