Robert Spaans125 downloadsRun coding agents (Claude Code, Codex, Ollama) inside Obsidian. Ships a built-in terminal and exposes the active selection and open editors over MCP.

Connect Obsidian to coding agents like Claude Code and Codex so they can work with your vault context. The goal is to let LLMs handle the brunt work in maintaining a knowledge base or task manager. (Or both.)
Ships with a built-in terminal, so you can run
claudeorcodexdirectly inside Obsidian — no other plugins required.
PATH.$SHELL and starts in the vault root by default.127.0.0.1 (random port, never network-exposed)~/.claude/ide/ — Claude Code reads this to auto-discover and connect to Obsidian, the same way it connects to VS Code or other editors. The lock is re-asserted on an interval, so if it ever gets cleaned out from under us the connection self-heals instead of going silently dead until the next reload.When Claude Code is connected as an IDE, it routes file edits through the IDE instead of printing the diff in the terminal. The plugin handles this by:
y/n prompt — no mouse, no separate buttons.127.0.0.1:27183/mcp for Codex| Tool | Description | Toggle in settings |
|---|---|---|
getLatestSelection |
Active file path, cursor position, and selected text (falls back to last-known state when Obsidian loses focus) | Always on |
getOpenEditors |
All open markdown tabs with file URI, label, and which is active | Always on |
getWorkspaceFolders |
Vault root path | Always on |
Obsidian desktop on macOS or Linux. Mobile is not supported; on Windows everything except the built-in terminal works (see Compatibility).
Python 3 available on your PATH (or set an explicit path in settings). It runs a small standard-library pseudo-terminal bridge for the built-in terminal — there are no pip packages to install. Use the Check button in settings to verify it.
The agent CLI(s) you want to use, installed separately on your system — the plugin launches them, it does not bundle them:
claude CLI. This is the default agent.claude CLI. This option runs ollama launch claude, which is Claude Code pointed at a local model — so it needs both installed.codex CLI if you use it.The terminal launches agents through your interactive login shell, so each CLI must be reachable on the PATH your shell config sets up (e.g. what which claude / which ollama print in a normal terminal). The plugin detects each agent's CLI the same way, so an agent you haven't installed shows an install prompt (with a link) instead of failing at launch — no need to install a CLI you don't want.
main.js, manifest.json, and styles.css from the latest release..obsidian/plugins/agent-mcp/ inside your vault and place all three files there.git clone https://github.com/rospaans/obsidian-agent-mcp
cd obsidian-agent-mcp
npm install
cp .env.example .env # optional: point at your vault's plugin folder
npm run build
npm run build bundles the whole plugin — including the Python bridge script — into a single main.js. If OBSIDIAN_PLUGIN_DIR is set in .env, the build also deploys main.js and manifest.json into your vault.
The plugin runs two local services, both bound to 127.0.0.1:
| Service | Port | What it does | Used by |
|---|---|---|---|
| WebSocket IDE server | OS-assigned (random) | Streams active file + selection, advertises the lock file in ~/.claude/ide/, and renders edit diffs as terminal-gated previews. Lets Claude Code auto-discover Obsidian as an "IDE". |
Claude Code |
| MCP HTTP server | 127.0.0.1:27183 |
Exposes all tools (getLatestSelection, getOpenEditors, getWorkspaceFolders) over the standard MCP Streamable HTTP transport. |
Claude Code, Codex, any MCP client |
Both routes into the same tool registry — adding one tool makes it available everywhere.
Important: Claude Code treats IDE connections and MCP servers as separate systems. The IDE connection gives Claude live selection awareness; the MCP server is what exposes our tools to the model. You want both registered.
PATH, with a Recheck button to re-probe after installing. Configure the default agent, shell, working directory, and font size in the same tab.Register both channels once, then you're done forever.
# (1) Register our MCP server so Claude can call our tools
claude mcp add --transport http agent-mcp http://127.0.0.1:27183/mcp
The IDE connection is automatic — nothing to register. The plugin's built-in terminal exports CLAUDE_CODE_SSE_PORT, so Claude Code launched there auto-connects to Obsidian on startup (reading the lock file in ~/.claude/ide/ for the auth token), exactly like an IDE-integrated terminal.
Then:
claude and connects to Obsidian automatically./mcp should list agent-mcp as connected.getLatestSelection.Running
claudefrom an external terminal instead? It won't have that env var, so run/ideinside Claude once and pick Obsidian to connect.
Use the command palette command "Send to Claude" in Obsidian to explicitly push your current selection as a context mention.
When Claude edits a note, a read-only diff preview opens in Obsidian and focus returns to the terminal — approve or decline with Claude's y/n prompt as usual.
Codex only needs the MCP server registration:
codex mcp add agent-mcp --url http://127.0.0.1:27183/mcp
Then pick Codex from the Agent dropdown (or set it as the default agent) — the terminal launches codex for you. Run /mcp inside Codex to confirm the connection, then ask anything that benefits from vault context. Codex uses the MCP tools only; the live selection/diff-preview IDE features are Claude Code-specific.
You can run the exact same Claude Code experience against a local model with Ollama. Ollama exposes an Anthropic-compatible endpoint at http://localhost:11434 and ships an ollama launch claude helper that starts Claude Code pointed at a local model. Because it's still Claude Code underneath, the IDE connection, MCP tools, and diff previews all work identically — no extra registration, no proxy.
Setup:
Install Ollama and the claude CLI (this option runs ollama launch claude, so it needs both). Pull a model with a large (64k+) context window and tool-use support — e.g. ollama pull qwen3.5. See Ollama's Claude Code guide for recommended models.
In Settings → Agent MCP → Default agent, choose Ollama and enter your model name (e.g. qwen3.5) — or just pick Ollama from the Agent dropdown at the top of the terminal.
Open the Agent Terminal. It now launches ollama launch claude --model <your-model> instead of claude.
As with Claude Code, register the MCP server once so the model can call our tools:
claude mcp add --transport http agent-mcp http://127.0.0.1:27183/mcp
The IDE connection is still automatic — Claude Code discovers Obsidian via the lock file exactly as before.
Prefer to drive it yourself?
ollama launch claudejust sets these and runs Claude Code:export ANTHROPIC_BASE_URL=http://localhost:11434 export ANTHROPIC_AUTH_TOKEN=ollama export ANTHROPIC_API_KEY="" claude --model qwen3.5
Settings → Agent MCP
ollama launch claude --model <model> (shown only when the Ollama agent is selected).python3 from your PATH. The Check button verifies it.$SHELL.-l).claude. Ignored for the Ollama agent.1. Create a tool file at src/tools/my-tool.ts:
import { wrap, type ToolDefinition } from "./types";
export function createMyTool(/* any context you need */): ToolDefinition {
return {
name: "myTool",
description: "What this tool does.",
inputSchema: { type: "object", properties: {} },
call() {
return wrap({ hello: "world" });
},
};
}
2. Register it in src/main.ts inside getActiveTools():
private getActiveTools(): ToolDefinition[] {
return [
...createEditorTools(this.app, () => this.latestSelection),
createMyTool(/* context */),
];
}
Both the WebSocket and HTTP/SSE transports pick it up automatically. No changes to server or routing code. (If you want it toggleable, add a setting in src/settings.ts and gate the push on it.)
In the interest of transparency (and to meet Obsidian's developer policies), here is exactly what this plugin does with your data, your network, and your machine.
This plugin collects no telemetry or analytics of any kind, sends nothing about you or your vault to its author, and has no server-side component. It is free and requires no account or sign-up to use. (The coding-agent CLIs you drive with it may require their own account or API key — see Network use below.)
Most of the plugin's work stays inside your vault, but it touches a few things outside it, by necessity:
~/.claude/ide/ (lock file). The plugin writes, refreshes, and removes a small lock file here (e.g. ~/.claude/ide/<port>.lock). It contains the local server port, your vault path, the name "Obsidian", and a random per-session token. This is the standard mechanism Claude Code uses to discover editors as "IDEs" — it is how Claude Code finds Obsidian. On startup the plugin also removes stale lock files left behind by crashed Obsidian processes.python3 (or the path you configure) to power a small standard-library pseudo-terminal bridge.The plugin launches local programs that you control and configure: your shell, your Python 3 interpreter (for the terminal bridge), and whichever agent CLI you point it at (claude, codex, ollama, etc.). It does not download, fetch, or evaluate any code from the internet, and it has no self-update mechanism — updates arrive only through Obsidian's normal community-plugin update flow.
The plugin itself makes no outbound internet connections. It runs two servers, both bound strictly to 127.0.0.1 (loopback), reachable only by other processes already on your machine — never exposed to your network or the internet. Over that loopback connection it streams your active file path, cursor position, and selected text to the locally-connected agent. Diff previews are rendered locally inside Obsidian from content the agent already proposed; the plugin never sends your note contents back to the agent.
The coding agent you run through it is third-party software with its own network behavior. To do its job, an agent typically transmits your prompts and the vault context you share to a remote provider:
api.anthropic.com), unless redirected.http://localhost:11434); with Ollama, inference stays on your machine.That data handling is governed by each agent's and provider's own terms and privacy policies, not by this plugin. Review them before sharing sensitive notes, and remember that running an agent may require that provider's account, subscription, or API key.
The plugin bundles xterm.js (MIT) for the terminal UI; full attribution is in NOTICE. The Python pseudo-terminal bridge (src/terminal/bridge.py) is original code in this repository. No other third-party runtime code is bundled.
127.0.0.1 — no network exposurecrypto.randomUUID()x-claude-code-ide-authorization headerHost header and rejects any request carrying an Origin header, blocking browser-based and DNS-rebinding attacksObsidian's automated plugin review reports two capability warnings — direct filesystem access and shell execution. Both are inherent to what this plugin is for (the Claude Code lock file in ~/.claude/ide/ and the built-in terminal) and are disclosed in detail above. All Node.js access goes through a single typed module (src/nodeApi.ts), which documents the exact API surface the plugin uses.
This plugin is licensed under the MIT License (see LICENSE).
Bundled third-party software (see NOTICE for full attribution):
The built-in terminal also runs a small pseudo-terminal bridge on your system's Python 3 at runtime. Python is a prerequisite you provide; it is not bundled with the plugin.
pty module. A ConPTY backend is planned.