# leonezz/obsidian-mcp-server architecture

> Architecture diagram of the GitHub repository leonezz/obsidian-mcp-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leonezz/obsidian-mcp-server
- Repository: https://github.com/leonezz/obsidian-mcp-server

## Overview

Obsidian MCP Server is a local plugin that exposes vault context and operations to external AI clients over Streamable HTTP. The main workflow is client request → authenticated MCP session → registered tool → Obsidian vault or metadata → result. Separate capabilities provide prompts, resources, access controls, session visibility, and usage statistics. Edges reflect the excerpts and README; some implementation details for unsampled tool and resource modules are therefore represented at subsystem level.

Main entry points: [`src/server.ts`](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/server.ts) (HTTP MCP server), [`src/tools/index.ts`](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/index.ts) (Tool registration), [`src/main.ts`](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/main.ts) (Plugin lifecycle), [`src/stats.ts`](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/stats.ts) (Usage statistics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Plugin runtime"]
  node_plugin["Plugin lifecycle<br/>[main.ts]"]
  node_settings["Plugin settings<br/>[settings.ts]"]
end

subgraph group_protocol["MCP interface"]
  node_server["HTTP MCP server<br/>[server.ts]"]
  node_toolreg["Tool registration<br/>[index.ts]"]
end

subgraph group_vault["Vault capabilities"]
  node_sessiontools["Context and discovery<br/>[get-active-file.ts]"]
  node_noteops["Note management<br/>[create-note.ts]"]
  node_search["Vault search<br/>[search-content.ts]"]
  node_metadata["Metadata and links"]
  node_attachments["Attachment handling<br/>[add-attachment.ts]"]
  node_daily["Daily capture"]
end

subgraph group_context["Guidance and resources"]
  node_resources["MCP resources<br/>[templates.ts]"]
  node_subscriptions["Resource subscriptions<br/>[subscriptions.ts]"]
  node_prompts["Agent prompts<br/>[obsidian-bases.ts]"]
  node_instructions["Server instructions<br/>[instructions.ts]"]
end

subgraph group_operations["Operations and policy"]
  node_security["Access control<br/>[security.ts]"]
  node_stats[("Usage statistics<br/>[stats.ts]")]
  node_logging["MCP logging<br/>[logging.ts]"]
end

node_client(("AI client"))
node_obsidian[("Obsidian vault")]

node_client -->|"sends requests"| node_server
node_plugin -->|"starts"| node_server
node_plugin -->|"initializes"| node_security
node_plugin -->|"adds settings UI"| node_settings
node_plugin -->|"creates tracker"| node_stats
node_plugin -->|"starts"| node_subscriptions
node_server -->|"reads configuration"| node_settings
node_server -->|"builds instructions"| node_instructions
node_server -->|"records session calls"| node_stats
node_server -->|"exposes tools"| node_toolreg
node_server -->|"exposes resources"| node_resources
node_server -->|"offers prompts"| node_prompts
node_server -->|"manages subscriptions"| node_subscriptions
node_toolreg -->|"registers tools"| node_sessiontools
node_toolreg -->|"registers tools"| node_noteops
node_toolreg -->|"registers tools"| node_search
node_toolreg -->|"registers tools"| node_metadata
node_toolreg -->|"registers tools"| node_attachments
node_toolreg -->|"registers tools"| node_daily
node_sessiontools -->|"reads vault context"| node_obsidian
node_noteops -->|"manages notes"| node_obsidian
node_search -->|"searches notes"| node_obsidian
node_metadata -->|"reads metadata"| node_obsidian
node_attachments -->|"reads and writes files"| node_obsidian
node_daily -->|"appends daily note"| node_obsidian
node_toolreg -->|"wraps tool handlers"| node_stats
node_search -->|"checks access"| node_security
node_plugin -->|"persists statistics"| node_stats

click node_plugin "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/main.ts"
click node_server "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/server.ts"
click node_toolreg "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/index.ts"
click node_settings "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/settings.ts"
click node_security "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/security.ts"
click node_stats "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/stats.ts"
click node_logging "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/logging.ts"
click node_sessiontools "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/get-active-file.ts"
click node_noteops "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/create-note.ts"
click node_search "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/search-content.ts"
click node_metadata "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/get-note-metadata.ts"
click node_attachments "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/add-attachment.ts"
click node_daily "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/append-daily-note.ts"
click node_resources "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/resources/templates.ts"
click node_subscriptions "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/resources/subscriptions.ts"
click node_prompts "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/prompts/obsidian-bases.ts"
click node_instructions "https://github.com/leonezz/obsidian-mcp-server/blob/master/src/instructions.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_plugin,node_settings,node_client toneBlue
class node_server,node_toolreg,node_obsidian toneAmber
class node_sessiontools,node_noteops,node_search,node_metadata,node_attachments,node_daily toneMint
class node_resources,node_subscriptions,node_prompts,node_instructions toneRose
class node_security,node_stats,node_logging toneIndigo
```

## Components

### Plugin runtime

- [Plugin lifecycle](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/main.ts): `src/main.ts`
- [Plugin settings](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/settings.ts): `src/settings.ts`

### MCP interface

- [HTTP MCP server](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/server.ts): `src/server.ts`
- [Tool registration](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/index.ts): `src/tools/index.ts`

### Vault capabilities

- [Context and discovery](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/get-active-file.ts): `src/tools/get-active-file.ts`
- [Note management](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/create-note.ts): `src/tools/create-note.ts`
- [Vault search](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/search-content.ts): `src/tools/search-content.ts`
- [Metadata and links](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/get-note-metadata.ts): `src/tools/get-note-metadata.ts`
- [Attachment handling](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/add-attachment.ts): `src/tools/add-attachment.ts`
- [Daily capture](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/tools/append-daily-note.ts): `src/tools/append-daily-note.ts`

### Guidance and resources

- [MCP resources](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/resources/templates.ts): `src/resources/templates.ts`
- [Resource subscriptions](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/resources/subscriptions.ts): `src/resources/subscriptions.ts`
- [Agent prompts](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/prompts/obsidian-bases.ts): `src/prompts/obsidian-bases.ts`
- [Server instructions](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/instructions.ts): `src/instructions.ts`

### Operations and policy

- [Access control](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/security.ts): `src/security.ts`
- [Usage statistics](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/stats.ts): `src/stats.ts`
- [MCP logging](https://github.com/leonezz/obsidian-mcp-server/blob/master/src/logging.ts): `src/logging.ts`

### Other components

- **AI client**
- **Obsidian vault**

## Connections

- AI client → HTTP MCP server: sends requests (evidence: `README.md`)
- Plugin lifecycle → HTTP MCP server: starts (evidence: `src/main.ts`)
- Plugin lifecycle → Access control: initializes (evidence: `src/main.ts`)
- Plugin lifecycle → Plugin settings: adds settings UI (evidence: `src/main.ts`)
- Plugin lifecycle → Usage statistics: creates tracker (evidence: `src/main.ts`)
- Plugin lifecycle → Resource subscriptions: starts (evidence: `src/main.ts`)
- HTTP MCP server → Plugin settings: reads configuration (evidence: `src/server.ts`)
- HTTP MCP server → Server instructions: builds instructions (evidence: `src/server.ts`)
- HTTP MCP server → Usage statistics: records session calls (evidence: `src/server.ts`)
- HTTP MCP server → Tool registration: exposes tools (evidence: `README.md`)
- HTTP MCP server → MCP resources: exposes resources (evidence: `README.md`)
- HTTP MCP server → Agent prompts: offers prompts (evidence: `README.md`)
- HTTP MCP server → Resource subscriptions: manages subscriptions (evidence: `src/server.ts`)
- Tool registration → Context and discovery: registers tools (evidence: `src/tools/index.ts`)
- Tool registration → Note management: registers tools (evidence: `src/tools/index.ts`)
- Tool registration → Vault search: registers tools (evidence: `src/tools/index.ts`)
- Tool registration → Metadata and links: registers tools (evidence: `src/tools/index.ts`)
- Tool registration → Attachment handling: registers tools (evidence: `src/tools/index.ts`)
- Tool registration → Daily capture: registers tools (evidence: `src/tools/index.ts`)
- Context and discovery → Obsidian vault: reads vault context (evidence: `README.md`)
- Note management → Obsidian vault: manages notes (evidence: `README.md`)
- Vault search → Obsidian vault: searches notes (evidence: `src/tools/search-content.ts`)
- Metadata and links → Obsidian vault: reads metadata (evidence: `README.md`)
- Attachment handling → Obsidian vault: reads and writes files (evidence: `README.md`)
- Daily capture → Obsidian vault: appends daily note (evidence: `README.md`)
- Tool registration → Usage statistics: wraps tool handlers (evidence: `src/stats.ts`)
- Vault search → Access control: checks access (evidence: `src/tools/search-content.ts`)
- Plugin lifecycle → Usage statistics: persists statistics (evidence: `src/main.ts`)
