Skip to main content
Glama
takuya0206

Obsidian MCP

by takuya0206

readNote

Retrieve the contents of a specific note from your Obsidian vault by providing its file path.

Instructions

Read the contents of a specific note

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • Factory function that creates the readNote tool handler. The returned async function executes the tool logic: reads the note content using ObsidianAPI and returns formatted success or error response.
    export function createReadNoteTool(api: ObsidianAPI): ToolHandler {
      return async (params: { path: string }): Promise<ToolResponse> => {
        try {
          const note = await api.readNote(params.path);
          return formatSuccessResponse(note);
        } catch (error) {
          return formatErrorResponse(`Error reading note: ${(error as Error).message}`);
        }
      };
    }
  • Zod schema for validating input parameters of the readNote tool (requires a non-empty 'path' string).
    export const ReadNoteSchema = {
      path: z.string().min(1, "Note path is required")
    };
  • src/server.ts:47-52 (registration)
    Registration of the readNote tool on the MCP server using server.tool() with name, description, schema, and handler factory.
    this.server.tool(
      readNoteDefinition.name,
      readNoteDefinition.description,
      readNoteDefinition.schema,
      createReadNoteTool(this.api)
    );
  • ObsidianAPI method that performs the HTTP GET request to fetch the note content from the vault, used by the tool handler.
    async readNote(path: string): Promise<NoteJson> {
      const normalizedPath = path.startsWith("/") ? path.substring(1) : path;
    
      const response = await this.client.get(
        `/vault/${encodeURIComponent(normalizedPath)}`,
        {
          headers: {
            ...this.defaultHeaders,
            "Content-Type": "application/json",
            accept: "application/vnd.olrapi.note+json",
          },
        }
      );
      return response.data as NoteJson;
    }

Tool Definition Quality

Score is being calculated. Check back soon.

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

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