readActiveNote
Retrieve the content of your currently open note in Obsidian to access information for AI-assisted tasks.
Instructions
Read the contents of the current active note
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/read-active-note.ts:23-32 (handler)The main tool handler factory function that creates the executor for the 'readActiveNote' tool. It calls the ObsidianAPI's readActiveNote method and formats the success or error response.export function createReadActiveNoteTool(api: ObsidianAPI): ToolHandler { return async (): Promise<ToolResponse> => { try { const note = await api.readActiveNote(); return formatSuccessResponse(note); } catch (error) { return formatErrorResponse(`Error reading active note: ${(error as Error).message}`); } }; }
- src/tools/read-active-note.ts:12-16 (schema)The tool definition including name, description, and schema (empty object for no parameters). The schema is defined earlier as ReadActiveNoteSchema = {}.export const readActiveNoteDefinition: ToolDefinition = { name: "readActiveNote", description: "Read the contents of the current active note", schema: ReadActiveNoteSchema };
- src/server.ts:56-60 (registration)Registers the 'readActiveNote' tool with the MCP server by calling server.tool with the definition and the created handler.readActiveNoteDefinition.name, readActiveNoteDefinition.description, readActiveNoteDefinition.schema, createReadActiveNoteTool(this.api) );
- src/api/obsidian-api.ts:41-50 (helper)The underlying API method in ObsidianAPI that performs the HTTP GET request to retrieve the active note contents.async readActiveNote(): Promise<NoteJson> { const response = await this.client.get(`/active/`, { headers: { ...this.defaultHeaders, "Content-Type": "application/json", accept: "application/vnd.olrapi.note+json", }, }); return response.data as NoteJson; }