Second Brain MCP
Reads and writes an Obsidian vault stored in a GitHub repository via the GitHub REST API, supporting listing Markdown notes, searching note contents, reading notes, appending inbox entries, and creating or replacing notes as commits on the configured branch.
Provides tools for working with an Obsidian vault: listing .md notes, searching note contents, reading notes, appending inbox items, and creating or replacing notes.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
second-brain-mcp
An MCP server that lets ChatGPT, Claude and other MCP clients list, search, read and append notes in an Obsidian vault stored in a GitHub repository.
The vault stays a normal Git repository: you keep editing it in Obsidian and syncing it with Git. The server is a small Cloudflare Worker that reads and writes files through the GitHub REST API, so every change made by an AI client is an ordinary commit you can review or revert.
Architecture
MCP client (ChatGPT, Claude, Claude Code, Cursor, ...)
│ Streamable HTTP + OAuth 2.1 bearer token
▼
Cloudflare Worker
├─ @cloudflare/workers-oauth-provider OAuth 2.1 authorization server (tokens stored in Workers KV)
│ └─ /authorize → consent page → Google sign-in → email allowlist
└─ Hono + @hono/mcp MCP endpoint at /mcp
│ GitHub REST API (fine-grained token)
▼
GitHub repository with the Obsidian vault (source of truth)Cloudflare Worker: stateless. It stores OAuth grants and tokens in a KV namespace and nothing else.
Hono + @hono/mcp: the MCP server (
@modelcontextprotocol/sdk) is exposed through the Streamable HTTP transport on/mcp.OAuth:
workers-oauth-providerimplements the authorization server side (metadata discovery, dynamic client registration, client ID metadata documents, token endpoint, PKCE). The app only handles/authorize: it shows a consent page, sends the user to Google, checks that the returned email is inGOOGLE_ALLOWED_EMAILSand then completes the authorization for the MCP client.GitHub REST API: the list of notes comes from the Git tree API; reads and writes use the contents API. There is no cache or local copy.
The server is in src/index.ts; the consent screen and browser binding are in src/consent.ts.
Related MCP server: vault-mcp
Tools
Tool | Arguments | What it does | Writes |
| none | Lists every | no |
|
| Returns the full content of one note | no |
|
| Case-insensitive text search over all notes; returns matching files with up to 3 matching lines each | no |
|
| Appends a dated checkbox line to the inbox note ( | yes, inbox note only |
|
| Creates or replaces a note | yes, inbox folder only unless |
Write safety
add_to_inboxis the default way to save something. It only appends a line to one file, and it sends the file's current SHA to GitHub, so a concurrent change makes the commit fail instead of being overwritten.write_noteaccepts only paths inside the inbox folder (the folder ofINBOX_PATH). Writing anywhere else requiresallow_anywhere: true; the tool description tells the model to set it only when the user explicitly asked. Paths must end in.mdand cannot contain...Every write is one commit on the configured branch, with a message, so it shows up in the Git history and can be reverted.
The GitHub token should be a fine-grained token limited to the vault repository with
Contents: Read and write.
The allow_anywhere flag is a convention that depends on the client and the model following the tool description; it is not an access control. Access control is the Google allowlist plus the scope of the GitHub token.
Sign-in security
Client registration is open (any MCP client can register itself, as the MCP spec expects), so a registered client is not trusted by itself. Without extra checks, someone could register a client with their own redirect URI, send you a crafted /authorize link and receive a token for your vault as soon as you sign in with Google. The sign-in flow closes that gap:
Consent screen.
GET /authorizevalidates the request, then shows a page with the client's name, client ID, website, the scopes (read and write to the vault) and, most prominently, the exact redirect URI that will receive the token. Every client-supplied string is HTML-escaped; the page loads no external assets and cannot be framed. It is shown for every client, including well-known ones; nothing is auto-approved.CSRF protection. The Approve / Deny form carries a random token that must equal a
__Host-cookie (HttpOnly, Secure, SameSite=Lax, 10 minutes) and the token stored with the pending request in KV. Comparisons are constant-time. The pending request lives server-side under a one-time id.Browser-bound state. On Approve, the Worker creates the Google
state, stores the request under it in KV (one-time, 10 minutes) and sets a second__Host-cookie with that state. The Google callback is accepted only if the cookie matchesstate, so a Google sign-in link started in someone else's browser cannot complete in yours. Both KV entries are deleted on use and the cookies are cleared at the end.Deny redirects back to the client with
error=access_deniedand the client'sstate, as OAuth requires.Identity is read only from the ID token in Google's token-endpoint response (server to server over TLS), then checked against
GOOGLE_ALLOWED_EMAILS.
Before pressing Approve, check that you started the connection yourself and that you recognise the redirect address (for example claude.ai, chatgpt.com or localhost for a local client).
Why OAuth instead of a Cloudflare Access service token
An earlier version put the Worker behind Cloudflare Access and required a service token (CF-Access-Client-Id / CF-Access-Client-Secret headers). That works for clients where you can configure custom headers (Claude Desktop config, Claude Code, Codex, VS Code), but not for clients that only accept a server URL, such as ChatGPT and Claude on the web.
Those clients follow the MCP authorization spec instead: they discover the authorization server from /.well-known/oauth-protected-resource, register themselves, and open a browser window where the user signs in. With OAuth on the Worker, every client connects with only the URL, and access is still limited to the Google accounts in the allowlist.
Setup
Requirements: Node.js 20 or newer, a Cloudflare account (the Workers free plan is enough), a Google Cloud project for the OAuth client, and a GitHub repository with your vault.
Install dependencies:
npm installCreate the KV namespace for OAuth state and put its id in
wrangler.jsonc:npx wrangler kv namespace create OAUTH_KVEdit the
varsinwrangler.jsonc:Variable
Meaning
OWNERGitHub user or organization that owns the vault repository
REPOVault repository name
BRANCHBranch to read and commit to (default
main)INBOX_PATHInbox note used by
add_to_inbox; its folder is the default write area (default00-INBOX/Inbox.md)GOOGLE_ALLOWED_EMAILSComma-separated Google accounts that may sign in
Create a Google OAuth client (Google Cloud Console → APIs & Services → Credentials → OAuth client ID, type "Web application") with the redirect URI
https://<your-worker-host>/oauth/google/callback. For local development also addhttp://localhost:8787/oauth/google/callback.Create a fine-grained GitHub token for the vault repository with
Contents: Read and write.
Run locally
cp .dev.vars.example .dev.vars # fill in GITHUB_TOKEN, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET
npm run dev # http://localhost:8787, MCP endpoint at /mcp
npm run typecheck
npm test # unit tests for the consent flow (Node 22.6+)You can test it with the MCP Inspector (npx @modelcontextprotocol/inspector) pointed at http://localhost:8787/mcp.
Deploy
npx wrangler login
npx wrangler secret put GITHUB_TOKEN
npx wrangler secret put GOOGLE_CLIENT_ID
npx wrangler secret put GOOGLE_CLIENT_SECRET
npm run deployThe MCP endpoint is https://<your-worker-host>/mcp.
Connecting clients
All clients use the same URL and sign in through the browser on first use.
ChatGPT: Settings → Apps & Connectors → add a custom connector (developer mode) with the
/mcpURL.Claude (web and desktop): Settings → Connectors → Add custom connector with the
/mcpURL.Claude Code:
claude mcp add --transport http brain https://<your-worker-host>/mcp, then/mcpto sign in.Other clients (Cursor, VS Code, Codex): add a Streamable HTTP server with the
/mcpURL; clients that support MCP OAuth start the sign-in themselves.
The exact menu names change between client versions.
Limitations
search_notesreads every note through the GitHub API on each call. It is fine for a vault of a few hundred notes; larger vaults will be slow and can hit the GitHub rate limit (5,000 requests per hour for a token). The contents API also does not return files larger than 1 MB.There is no delete, move or rename tool.
write_notereplaces the whole file and does not check for concurrent edits.Every allowed user gets both read and write access; the
mcp:read/mcp:writescopes are declared but not enforced per tool.The MCP transport runs in stateless mode; there are no server-initiated notifications.
Only Google is supported as the identity provider.
License
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Hosted MCP server for Obsidian Sync vaults: read, search, edit notes. Not affiliated with Obsidian.
Notes and memory assistant: one Markdown vault that Claude, ChatGPT and any MCP client can share.
Connect AI assistants to your GitHub-hosted Obsidian vault to seamlessly access, search, and analy…
Markdown-based note-taking with a hosted MCP server. Your notes serve you and your AI.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceRemote MCP server that exposes a personal git repository of markdown notes to Claude, enabling reading, writing, searching, and running scripts with automatic git commits and GitHub OAuth authentication.MIT
- AlicenseNot gradedqualityBmaintenanceAuthenticated remote MCP server that exposes a private GitHub-hosted Obsidian vault to Claude, enabling list, read, write, and search operations on notes.9MIT
- AlicenseNot gradedqualityCmaintenanceA small, authenticated remote MCP server that lets an AI app safely read and write one GitHub repository, built for a second-brain / Obsidian vault stored on GitHub.4MIT
- AlicenseNot gradedqualityDmaintenanceSelf-hosted MCP server for private Obsidian vaults on GitHub, exposing tools to search, read, write, and analyze Markdown notes and their link graph.MIT