obsidian-mcp-serverlisted
Install: claude install-skill hsb3/dotfiles-agents
# Obsidian MCP Server
Provides guidance for setting up MCP (Model Context Protocol) servers inside Obsidian plugins using Streamable HTTP transport, enabling AI agents to access vault operations.
## Architecture
The plugin hosts an MCP server that external agents connect to:
```
AI Agent / LangGraph (MCP Client)
|
| HTTP POST to localhost:5123/mcp
v
Obsidian Plugin (MCP Server)
|
| app.vault, app.metadataCache
v
Obsidian Vault
```
**Connection direction:** Agent → Plugin (not plugin → agent)
## SDK Setup
Install MCP SDK v2:
```bash
npm install @modelcontextprotocol/sdk zod
```
**Dependencies:**
- `@modelcontextprotocol/sdk` - MCP server and transports
- `zod` - Required peer dependency (v3.25+)
## Stateless Server Pattern
For single-user plugins, create a new server per request:
```typescript
import { createServer, IncomingMessage, ServerResponse } from 'http';
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
import { z } from 'zod';
import { App } from 'obsidian';
export class VaultMcpServer {
private httpServer: ReturnType<typeof createServer> | null = null;
private app: App;
constructor(app: App) {
this.app = app;
}
async start(port: number): Promise<void> {
this.httpServer = createServer(async (req: IncomingMessage, res: ServerResponse) => {
if (req.method === 'POST' && req.url === '/mcp') {