Skip to main content
Glama
nanthansr

second-brain-mcp

by nanthansr

second-brain-mcp

CI License: MIT Node >= 18

あらゆる Obsidian またはプレーンな Markdown ボールトを対象とした読み取り専用の MCP サーバー。取得プロトコルは、文章で要求されるのではなく、サーバー側で強制されます。

Markdown ノートのフォルダに向けると、あらゆる MCP クライアント — Claude Code、Claude Desktop、Cursor、その他何でも — が、4 つの管理されたツールを通じてそのナレッジベースを照会できます。サーバーは物理的に書き込みができず、ボールトディレクトリの外に出ることもできず、ページ読み取りの厳格な予算に達すると、セッションを打ち切ります。

ライブセッション: インデックスを最初に、3 回の予算内読み取り、引用付き回答

なぜ

個人のナレッジベースは、結局ひとつのツールに固定されてしまいます。ノートは Obsidian にあり、それを使える AI アシスタントは別の場所にあるため、コピー&ペーストが必要になります。また、アシスタントがファイルアクセスを得たとしても、「必要なものだけ読んでください」は礼儀上のリクエストであり、ルールではありません。

このサーバーは両方を解決します:

  • ひとつのコネクタで、あらゆるアプリに。 MCP は AI ツールの USB-C です。ボールトコネクタを一度書けば、あらゆる MCP クライアントがそれを使えます。

  • プロトコルは提案ではなく、ルールです。 インデックス優先の取得、厳格なページ読み取り予算、読み取り専用アクセス、パスサンドボックスはコードで強制されます。存在する操作は、管理された操作だけです。

Related MCP server: obsidian-gate

インストール

Node.js 18 以降が必要です。

オプション A - npm から

claude mcp add second-brain -- npx -y @nanthansr/second-brain-mcp /abs/path/to/your/vault

この 1 つのコマンドでサーバーが Claude Code に登録されます。npx がパッケージを自動的に取得して実行します。他のクライアントについては、下の設定ブロックを参照してください。

オプション B - ソースから

git clone https://github.com/nanthansr/second-brain-mcp
cd second-brain-mcp
npm install && npm run build
npm test   # 15-check integration suite - should end with SMOKE PASS
claude mcp add second-brain -- node /abs/path/to/second-brain-mcp/dist/index.js /abs/path/to/your/vault

Claude Desktop

claude_desktop_config.json に追加します(Settings → Developer → Edit Config):

{
  "mcpServers": {
    "second-brain": {
      "command": "npx",
      "args": ["-y", "@nanthansr/second-brain-mcp", "/abs/path/to/your/vault"]
    }
  }
}

Cursor

同じブロックを ~/.cursor/mcp.json に追加します(または Cursor Settings → MCP → Add new server)。

ボールトが手元にない場合?

ボールト引数を完全に省略すると、サーバーは同梱の架空のデモボールト(「Alex Rivera」)を提供します。30 秒で試すのに便利です:

claude mcp add second-brain-demo -- npx -y @nanthansr/second-brain-mcp

Obsidian ボールトを指定する

ボールトは単なるフォルダです。Obsidian が「Open folder as vault」と表示したときに選択したフォルダです。そのフォルダの絶対パスを引数として渡してください:

OS

例

Windows

C:/Users/you/Documents/my-vault

macOS / Linux

/Users/you/Documents/my-vault

注:

  • ボールトのルートにある index.md は、インデックス優先フロー(get_index)を有効にします。各ノートにつき 1 行のカタログページです。これがない場合も、すべては機能します。モデルは search_notes にフォールバックします。

  • Obsidian 自身の設定(.obsidian/)やその他のドットフォルダは、サーバーからは見えません。

  • サーバーは何も変更しません。実行中も Obsidian は開いたままにできます。

使い方

接続したら、質問するだけです。典型的なフロー(デモボールトでの実際のセッションから):

「Alex Rivera は今何に取り組んでいて、Sam は誰ですか?」 → get_index → read_note ×3(それぞれ read 1/5、read 2/5、read 3/5 と記録)→ 引用付きの回答。

「今週、私のボールトで何が変わりましたか?」 → list_recent(days: 7) → 日付付きリスト(新しい順)。

「価格設定についてのノートはどこにありますか?」 → search_notes(query: "pricing") → 一致するページを行番号付きスニペットとともに返します。予算は消費されません。

MCP プロンプトをサポートするクライアントは、vault-retrieval も利用できます。これは、特定の質問に対してモデルをインデックス優先プロトコルに固定するスラッシュコマンドテンプレートです。

クライアントが利用できるもの

種類

名前

説明

予算

ツール

get_index

index.md(1 ページ 1 行のカタログ)を返します。最初に呼び出してください。

消費なし

ツール

search_notes

大文字小文字を区別しない検索。ページと行番号付きスニペットを返します

消費なし

ツール

read_note

ボールト相対パスで指定した 1 ページの完全な内容

消費あり

ツール

list_recent

過去 N 日間に変更されたページを新しい順に返します

消費なし

リソース

vault://index

インデックスを MCP リソースとして提供

消費なし

プロンプト

vault-retrieval

インデックス優先プロトコルを再利用可能なプロンプトテンプレートとして提供

-

意図されたフローは、注意深い人間がウィキを使うのと同じです。カタログを読み、重要と思われる 1、2 ページを開き、引用付きで回答します。探すのはコストがかからず、読むのは予算を消費します。

設定

設定項目

指定方法

デフォルト

ボールトのパス

最初の CLI 引数、または VAULT_PATH 環境変数

同梱の sample-vault/

ページ読み取り予算

VAULT_READ_BUDGET 環境変数

セッションあたり 5

セキュリティモデル

  • 構造上読み取り専用。 コードベースには書き込み・編集・削除ツールは存在しません。

  • パスサンドボックス。 すべてのパスはまず path.resolve で正規化され、その後ボールトルートに対してチェックされます。トラバーサル試行(../…)は拒否されます。読み取り可能なのは .md ファイルのみです。

  • 厳格なページ予算。 read_note 呼び出しが N 回(デフォルト 5)に達すると、サーバーはそれ以上の読み取りを拒否し、モデルに既に取得した内容から合成するよう指示します。失敗した読み取りは予算を消費しません。

  • サイズ上限。 ノートは 50KB で切り詰められます。検索結果と最近のリストにも上限があります。

  • ドットフォルダはスキップ。 .obsidian、.git、その他のドットフォルダは不可視です。

  • コードは公開、データは非公開。 リポジトリにはサーバーコードと架空のデモボールトのみが含まれます。実際のボールトは実行時にマウントするフォルダであり、マシンの外に出ることはありません。

FAQ

私のデータはマシンの外に出ますか? いいえ。サーバーは MCP クライアントの子プロセスとしてローカルで実行され、ディスクからファイルを読み取ります。ネットワークコードは含まれていません。

ノートを変更または削除できますか? いいえ。書き込むツールはありません。これは設定ではなく、コードの性質です。

モデルが予算に達するとどうなりますか? 6 回目の読み取りはエラーを返し、モデルに既に取得済みのページから回答を合成するよう指示します。新しい会話では新しい予算が与えられます。

デモの回答が「Alex Rivera」について話していたのはなぜですか? 同梱の架空のデモボールトを使用しているためです。最初の引数として自分のボールトのパスを渡してください。

開発

npm run build   # tsc -> dist/
npm test        # build + 15-check smoke test (spawns the real server over stdio)

npm test 出力: 15 チェック、SMOKE PASS

スモークテストは、コンパイル済みサーバーに対して SDK 自身のクライアントを使用します。実際のプロトコルであり、モックはありません。4 つのツールすべて、リソース、プロンプト、パストラバーサルの拒否、そして読み取り予算が N+1 回目の読み取りを拒否することを検証します。CI は Linux と Windows で、Node 20 と 22 を使って実行します。

なぜこのように作られたのか知りたいですか? docs/design-notes.md を参照してください。トランスポート、MCP の 3 つのプリミティブ、スキーマをプロンプトとして使う方法、サンドボックスと予算の決定について説明しています。

ロードマップ

  • リモート版(ストリーミング可能な HTTP)。認証付きで、ホスト型クライアントからボールトにアクセスできるようにします

  • オプションのフォルダ単位スコープ(wiki/ のみを提供し、journal/ を非表示にする)

コントリビューション

Issue と PR を歓迎します。不変条件を守ってください。書き込みツールなし、ネットワーク呼び出しなし、スモークテストがグリーンのまま弱体化しないこと。

ライセンス

MIT · 変更履歴は CHANGELOG.md にあります

Available Tools

4 tools
get_indexGet the vault indexA

Returns index.md, the catalog of every page in the vault (one line each). ALWAYS call this first to locate relevant pages, then read only the 1-2 pages that matter. Does not count against the page budget.

NameRequiredDescriptionDefault

No parameters

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses the output behavior (one line per page) and adds a meaningful operational trait: 'Does not count against the page budget,' which is beyond what the schema or title conveys. It could mention side-effect-free/read-only nature, but the context strongly implies a safe read.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short sentences deliver the core purpose, usage directive, and budget behavior in order of importance. No filler or redundant restating of the title.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a zero-parameter tool with no output schema, the description fully covers what the agent needs: what it returns, how to use it first, and why it is safe to invoke. There are no missing details that would prevent a correct call.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters and schema coverage is 100%, so there are no parameter semantics to document. The description adds useful meaning about the returned content, which is more than necessary for a parameterless tool.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb ('Returns') and resource ('index.md'), and precisely defines the output as 'the catalog of every page in the vault (one line each).' This clearly differentiates it from the sibling tools like search_notes or read_note.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly directs the agent to 'ALWAYS call this first' and then 'read only the 1-2 pages that matter,' giving a clear workflow. It does not explicitly name search_notes or list_recent as alternatives, but the sequential guidance is strong enough to establish when this tool should be used.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_recentList recently updated pagesA

Lists pages modified in the last N days (default 7), newest first. Good for 'what changed lately'. Does not count against the page budget.

NameRequiredDescriptionDefault
daysNoLook-back window in days (default 7)

TDQS

A4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and does disclose useful behavioral traits: a default look-back window, newest-first ordering, and that it does not consume page budget. It does not describe the returned page format or any limits beyond the schema, but for a simple read-only list tool this is solid transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short sentences carry the core behavior, the primary use case, and a key operational constraint with no filler. The most important information is front-loaded, and every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple tool with one fully documented optional parameter and no output schema, the description covers the essential behaviors: what is listed, the time window, ordering, and budget impact. It could be more complete by describing what fields/details appear in the returned page list, but it is sufficient for an agent to select and invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and the single 'days' parameter is already documented with type, range, and default. The description only repeats the default window, adding no new semantic meaning beyond what the schema already provides, so the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states a specific verb ('Lists') and resource ('pages'), with a defined time window and sort order ('last N days (default 7), newest first'). It does not explicitly name or differentiate itself from sibling tools like search_notes or get_index, but the 'recently modified' framing makes its distinct purpose reasonably clear.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear usage context with 'Good for what changed lately' and adds a practical benefit ('Does not count against the page budget'). However, it does not mention when not to use it or point to alternative sibling tools, so it stops short of full routing guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

read_noteRead one pageA

Returns the full content of one markdown page by vault-relative path (e.g. wiki/people/sam-okafor.md). Counts against the hard page budget of 5 reads per session - locate pages via get_index or search_notes first, then read only what matters.

NameRequiredDescriptionDefault
pathYesVault-relative path to a .md file

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and discloses a key non-obvious behavior: the hard page budget of 5 reads per session. It also clarifies that the tool returns full content. It could additionally mention error behavior for missing paths or confirm it is a pure read, but it is already meaningfully transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no filler. The first sentence establishes the core function and path format; the second adds the budget constraint and recommended preceding workflow. Every sentence earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a single-parameter read tool with no output schema, the description is complete: it states what is returned, how to address the resource, and a critical usage constraint. It also routes the agent to the right discovery tools before reading.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3. The description adds value with a concrete path example ('wiki/people/sam-okafor.md') and reinforces the vault-relative .md semantics, making the expected input format clearer to the agent.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('Returns the full content') and a precise resource ('one markdown page by vault-relative path'). With the title 'Read one page' and sibling tools like search_notes and list_recent, it is immediately distinguishable as a targeted read operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It explicitly tells the agent to locate pages via get_index or search_notes first and to 'read only what matters', plus it warns about the hard 5-read budget. It does not explicitly mention list_recent or state when not to use this tool, so it falls just short of full exclusion guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_notesSearch the vaultA

Case-insensitive text search across every markdown page. Returns matching pages with line-numbered snippets. Use when the index does not answer 'where does this live'. Does not count against the page budget.

NameRequiredDescriptionDefault
queryYesText to search for (literal, not regex)
max_resultsNoMax pages to return (default 10, cap 30)

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the behavioral disclosure burden. It discloses case-insensitive matching, global scope, snippet return format, and the useful operational fact that it does not count against the page budget. It does not explicitly state read-only behavior, but this is strongly implied by 'search'.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, each carrying distinct value: the core behavior, the return format, and the usage trigger plus budget note. It is front-loaded and free of filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple two-parameter search tool with no output schema, the description covers scope, matching behavior, return shape, and when to use it. Nothing essential for correct invocation is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the parameters are already fully documented. The description adds context about case-insensitivity and scope but does not materially extend what the schema provides for query and max_results.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('search') and resource ('every markdown page'), with concrete details like case-insensitivity and line-numbered snippets. It is clearly distinct from sibling tools like get_index, read_note, and list_recent.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly says to use it 'when the index does not answer where does this live', giving a clear trigger condition. It does not enumerate exclusions or compare against read_note/list_recent, but the context is unambiguous enough for an agent to route correctly.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 4 tool updatesv0.1.0
    • First observedget_index
    • First observedlist_recent
    • First observedread_note
    • First observedsearch_notes

TDQS

A4.3/5.0

Scored across 4 tools

Disambiguation5/5

Each tool has a clearly distinct role: index for catalog lookup, search for text search, read for content retrieval, and list_recent for recency. The descriptions even specify when to prefer one over another, removing ambiguity.

Naming Consistency4/5

All tool names use snake_case with an imperative verb first, creating a predictable pattern. list_recent is slightly less parallel than list_recent_notes, but the deviation is minor and does not confuse the set.

Tool Count5/5

Four tools is well-scoped for a retrieval-focused note vault: discovery via index/search/recent and content access via read. Each tool serves a distinct workflow step with no redundancy.

Completeness4/5

The surface fully covers read-oriented workflows: locating notes, finding content by text, checking recent changes, and reading full pages. The only notable gap is write/edit operations, but the tool descriptions consistently frame this as a read-only vault interface.

Maintenance

ActivityStale
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Provides read-only access to an Obsidian vault, enabling file listing, content reading, and text search across notes via MCP.
    4
    2
    Apache 2.0
  • F
    license
    Not graded
    quality
    C
    maintenance
    Enables MCP clients to search, read, list, and append to markdown notes in a local Obsidian vault or folder of .md files.
    -