# markuspfundstein/mcp-obsidian architecture

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

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

## Overview

##### Main Components
- MCP Server Core: Represented primarily by src/mcp_obsidian/server.py which sets up the MCP server logic.
- Obsidian Tools Module: Located in src/mcp_obsidian/tools.py and obsidian.py – these encapsulate the logic for file listing, content retrieval, search functions, patching/appending content, and deletion.
- API Specification: The openapi.yaml in the root folder defines the API contract that the server adheres to, so include an “API Specification” component that influences how requests/responses are handled.
- Configuration & Environment: Highlight configuration layers (e.g., reading the OBSIDIAN_API_KEY either via a config in the server config JSON or a .env file).

##### Establish Relationships and Interactions
- That configuration (OBSIDIAN_API_KEY) and environmental setup (via pyproject.toml and .env) inject necessary credentials into the server at startup.
- Optionally, include a debugging layer as noted in the README – showing how the server logs flow to the log file and how the MCP Inspector tool connects to the server for debugging.

##### Architectural Patterns & Design Principles
- The separation of concerns is evident: one module handles server communications (server.py) while another module (tools.py & obsidian.py) encapsulate the business logic.
- That the tools act as application “commands” encapsulating operations—each tool maps to a specific feature (list, get, search, patch, etc.).
- The API specification (openapi.yaml) reinforces contract-first design principles.
- The project follows a modular structure where configuration is decoupled from core logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        Client["MCP Client"]:::external
    end

    %% Server Layer
    subgraph "Server Layer"
        Config["Environment Config"]:::config
        Server["MCP Server (server.py)"]:::core
        Debug["Debugging/Monitoring (MCP Inspector)"]:::debug
    end

    %% Application Modules
    subgraph "Application Modules"
        Tools["Tools Module (tools.py)"]:::tools
        Obsidian["Obsidian Connector (obsidian.py)"]:::tools
    end

    %% External Dependencies
    subgraph "External Dependencies"
        APISpec["API Spec (openapi.yaml)"]:::doc
        ObsidianAPI["Obsidian REST API Plugin"]:::external
        Vault["Obsidian Vault (File System)"]:::storage
    end

    %% Connections - Vertical Flow
    Client -->|"send_command"| Server
    Config -->|"load_credentials"| Server
    Server -->|"log_events"| Debug
    Server -->|"dispatch_command"| Tools
    Server -->|"dispatch_command"| Obsidian
    Tools -->|"process_operations"| Obsidian
    Tools -->|"call_API"| ObsidianAPI
    Obsidian -->|"access_notes"| Vault

    %% Click Events
    click Server "https://github.com/markuspfundstein/mcp-obsidian/blob/main/src/mcp_obsidian/server.py"
    click Tools "https://github.com/markuspfundstein/mcp-obsidian/blob/main/src/mcp_obsidian/tools.py"
    click Obsidian "https://github.com/markuspfundstein/mcp-obsidian/blob/main/src/mcp_obsidian/obsidian.py"
    click APISpec "https://github.com/markuspfundstein/mcp-obsidian/blob/main/openapi.yaml"
    click Config "https://github.com/markuspfundstein/mcp-obsidian/blob/main/pyproject.toml"

    %% Styles
    classDef core fill:#FFCCCB,stroke:#333,stroke-width:2px;
    classDef tools fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef config fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef external fill:#D8BFD8,stroke:#333,stroke-width:2px;
    classDef doc fill:#FFDAB9,stroke:#333,stroke-width:2px;
    classDef debug fill:#F0E68C,stroke:#333,stroke-width:2px;
    classDef storage fill:#FFE4E1,stroke:#333,stroke-width:2px;
```
