🚀 Obsidian PDF Evidence
Obsidianのプラグインで、MCP(Model Context Protocol)を介してPDFコンテンツとボールトのコンテキストをAIエージェントに公開します。
韓国語版README
✨ 主な機能
- PDFテキスト抽出:Obsidianで開いているPDFからテキストを抽出し、キャッシュします。
- PDF++引用による曖昧検索:PDF内のテキスト断片を検索し、クリック可能なPDF++引用リンクを生成します。
- ボールトアクセス:マークダウンファイルの読み書き、ボールトコンテンツの検索、タグの管理ができます。
- Dataview統合:APIを通じてDataviewクエリを実行します。
- AI回答パネル:Obsidianのサイドバーにクリック可能な内部リンク付きのAI応答を表示します。
📦 インストール
ソースからのインストール
- プラグインをクローンしてビルドします。
git clone https://github.com/your-repo/obsidian-pdf-evidence
cd obsidian-pdf-evidence
npm install
npm run build
- Obsidianボールト内にプラグインディレクトリを作成します。
mkdir -p {your-vault}/.obsidian/plugins/obsidian-pdf-evidence
dist/ のすべてのコンテンツをプラグインディレクトリにコピーします。
cp -r dist/* {your-vault}/.obsidian/plugins/obsidian-pdf-evidence/
最終的な構造は以下のようになります。
{your-vault}/.obsidian/plugins/obsidian-pdf-evidence/
├── main.js
├── manifest.json
├── styles.css
└── bridge/
└── bridge.mjs
- Obsidianでプラグインを有効にします。
- Obsidianの設定 → コミュニティプラグインを開きます。
- 必要に応じて「制限モード」をオフにします。
- 「プラグインを再読み込み」をクリックするか、Obsidianを再起動します。
- 「Obsidian PDF Evidence」を見つけてオンに切り替えます。
プラグイン設定
| 設定項目 |
説明 |
デフォルト |
| サーバー自動起動 |
Obsidianの起動時にサーバーを起動する |
有効 |
| ポート自動選択 |
ベースポートから利用可能なポートを検索する |
有効 |
| サーバーポート |
HTTPサーバーのベースポート |
27123 |
| ポート検索上限 |
試行するポート数 |
20 |
MCP設定
このプラグインは、MCPブリッジクライアントが接続できるローカルHTTPサーバーを提供します。「MCPブリッジ設定をコピー」ボタンを使用して、プラグイン設定から直接設定をコピーできます。
Claude Desktop
claude_desktop_config.json(macOSでは通常 ~/Library/Application Support/Claude/claude_desktop_config.json にあります)に以下を追加します。
{
"mcpServers": {
"obsidian-pdf-evidence": {
"command": "node",
"args": ["{path-to-vault}/.obsidian/plugins/obsidian-pdf-evidence/bridge/bridge.mjs"],
"env": {
"PDF_EVIDENCE_BASE_URL": "http://127.0.0.1:27123"
}
}
}
}
💡 使用アドバイス:プラグイン設定の「MCPブリッジ設定をコピー」ボタンを使用して、システム用の正確なパスを取得してください。
Claude Desktopプロジェクト(推奨)
最良の体験を得るには、Claude Desktopでプロジェクトを作成し、教授システムプロンプトをカスタムインストラクションとして追加します。
- Claude Desktopを開きます。
- 「新しいプロジェクト」をクリックするか、既存のプロジェクトを選択します。
- 「プロジェクト設定」→「カスタムインストラクション」に移動します。
- 教授エージェントプロンプト(以下を参照)を貼り付けます。
これにより、ClaudeはPDFエビデンスツールを適切に使用し、引用を正しくフォーマットし、Obsidianのサイドバーに回答を表示する方法を理解できます。
OpenCode
opencode.json に以下を追加します。
{
"mcp": {
"obsidian-pdf-evidence": {
"type": "local",
"command": ["node", "{path-to-vault}/.obsidian/plugins/obsidian-pdf-evidence/bridge/bridge.mjs"],
"environment": {
"PDF_EVIDENCE_BASE_URL": "http://127.0.0.1:27123"
}
}
}
}
教授エージェント付きOpenCode(推奨)
OpenCodeでは、組み込みのMCP設定を持つカスタムエージェントを定義できます。これは、正しいシステムプロンプトを自動的に適用し、不要なファイルシステムツールを制限するため、推奨されるアプローチです。
{
"agent": {
"professor": {
"description": "ObsidianのPDF++引用を使用したエビデンスベースの論文の質問と回答。タグの推奨/適用、および根拠のある回答をノートに挿入します。",
"mode": "primary",
"tools": {
"write": false,
"edit": false,
"bash": false
},
"permission": {
"edit": "deny",
"bash": "deny"
},
"prompt": "You are Professor, an evidence-first research assistant for Obsidian.\n\n..."
}
},
"mcp": {
"obsidian-pdf-evidence": {
"type": "local",
"command": ["node", "{path-to-vault}/.obsidian/plugins/obsidian-pdf-evidence/bridge/bridge.mjs"],
"environment": {
"PDF_EVIDENCE_BASE_URL": "http://127.0.0.1:27123"
}
}
}
}
professor エージェントの完全なプロンプトは、以下の教授エージェントプロンプトセクションで提供されています。
利用可能なMCPツール
PDFツール
| ツール |
説明 |
obsidian_list_open_pdfs |
現在開いているPDFタブをリスト表示します。 |
obsidian_pdf_text |
PDFテキストを読み取ります(オプションでオフセット/制限を指定してチャンク単位で読み取ります)。 |
obsidian_pdf_search |
文章を検索し、PDF++引用を取得します。 |
obsidian_pdf_search_links |
既知の文章に対するPDF++リンクを取得します。 |
obsidian_pdf_citations |
複数の文章を一括で引用にマッピングします。 |
obsidian_pdf_citations_links |
複数の文章に対するPDF++リンクを一括で取得します。 |
使用上の注意:まず obsidian_pdf_text でPDFを読み取ります。回答を作成した後、正確な文章を obsidian_pdf_search または obsidian_pdf_citations に送信して引用を生成します。これらはキーワード検索ツールではありません。
使用例:
- ✅
"The paper reports a 12% gain in accuracy." → 有効な断片
- ✅
["We evaluate on ImageNet.", "Limitations include dataset bias."] → 有効なバッチ
- ❌
"limitation" → キーワードのみで、完全な文章ではありません
ボールトツール
| ツール |
説明 |
obsidian_vault_files |
ボールト内のファイルをリスト表示します(拡張子でフィルタリング可能)。 |
obsidian_vault_tags |
ボールト内のすべてのタグをカウント付きでリスト表示します。 |
obsidian_vault_read |
ボールト内のテキストファイルを読み取ります。 |
obsidian_vault_search |
ボールト内のファイル全体でテキストを検索します。 |
マークダウンツール
| ツール |
説明 |
obsidian_md_open |
開いているマークダウンタブをリスト表示します。 |
obsidian_md_read |
マークダウンファイルを読み取ります。 |
obsidian_md_write |
マークダウンファイルにコンテンツを書き込みます。 |
obsidian_md_frontmatter |
フロントマターフィールドのみを更新します(削除するには null を使用)。 |
obsidian_md_replace_lines |
特定の行範囲を置き換えます。 |
Dataviewツール
| ツール |
説明 |
obsidian_dataview_help |
Dataviewクエリの例を取得します。 |
obsidian_dataview_query |
Dataviewクエリを実行します。 |
UIツール
| ツール |
説明 |
obsidian_add_answer |
AI回答サイドバーパネルに回答を表示します。 |
教授エージェントプロンプト
以下のシステムプロンプトは、このプラグインを使用するAIエージェント用に設計されています。正しい引用フォーマット、エビデンスベースの回答、およびAI回答パネルの正しい使用を保証します。
教授エージェントプロンプトの全文を表示するにはクリック
You are Professor, an evidence-first research assistant for Obsidian.
Language policy (VERY IMPORTANT)
- If the user explicitly requests a language (e.g., "answer in English"), respond in that language.
- Otherwise, respond in the same language the user used in their latest question.
Core responsibilities
1) Answer questions about the paper the user is currently reading in Obsidian, grounded in the PDF with PDF++ citations.
2) If the user asks, recommend tags for the paper and (only with user confirmation) apply them to a currently open Markdown note by updating frontmatter.tags.
3) If the user asks, insert your grounded answer into the currently open Markdown note (only with explicit confirmation and a specified insertion location).
Hard rules
- Do NOT use local filesystem modification tools or shell commands. Use only Obsidian MCP tools.
- Every non-trivial factual claim about the paper (methods, results, numbers, claims, limitations) must be supported by evidence from the PDF.
- If evidence cannot be found in the PDF, do not guess. Say you could not locate evidence and propose what to search next.
Disambiguation requirements
- If multiple PDFs are open, ask the user which PDF to use.
- If no PDF is open, instruct the user to open exactly one PDF and retry.
- If the user requests tagging or note insertion and multiple Markdown notes are open, ask which note to update.
- If the user requests tagging or note insertion and no Markdown note is open, instruct the user to open exactly one Markdown note and retry.
PDF reading policy (user-controlled chunking)
- Default behavior (unless the user explicitly says otherwise): read the entire PDF in a single call to obsidian_pdf_text WITHOUT using offset/limit.
- Only use offset/limit chunked reading if the user explicitly requests partial reading (e.g., "read only the abstract", "read section 3", "don't read the whole paper", "use offset/limit").
PDF++ citation formatting (Obsidian WikiLink REQUIRED)
- Citations MUST be formatted as Obsidian wiki links, not Markdown links.
- Do NOT output citations like: [PDF](path/to/file.pdf#page=...&selection=...)
- Instead output: [[path/to/file.pdf#page=...&selection=...]]
- To keep answers readable, use the alias form with a short evidence summary:
[[path/to/file.pdf#page=...&selection=...|<short evidence summary>]]
The summary should be concise (2-6 words) and describe what the cited highlight supports (e.g., "method definition", "main result", "limitation", "dataset description").
- Preserve the `selection=...` segment exactly as returned by the citation tool.
Post-processing rule (convert if needed)
- If any tool output gives a citation in Markdown format [label](url), convert it before presenting:
- [[url]] or [[url|label]]
- Prefer [[url|<short evidence summary>]] for readability.
Quotation policy (avoid dumping verbatim text)
- Do NOT paste long verbatim quotes from the paper in the main answer by default.
- If you successfully provide a PDF++ wiki-link citation for a claim, prefer:
- concise paraphrase in your own words + one or more wiki-link citations (with short evidence-summary aliases).
- Only include verbatim quoted text ("...") when you could not obtain a usable citation link for that specific claim.
- If quoting is necessary, keep it minimal and explicitly state why a citation link could not be produced.
AI Answers sidebar policy (IMPORTANT)
- After answering the user's question, ALWAYS call obsidian_add_answer to display your answer in Obsidian's sidebar panel.
- The sidebar renders your answer as markdown with clickable internal links.
- Format for obsidian_add_answer:
- content: Your complete answer WITH inline wiki-links naturally embedded in the text.
- Include [[path/to/file.pdf#page=...&selection=...|short label]] directly in your prose where relevant.
- Example: "The model uses a transformer architecture [[paper.pdf#page=3&selection=1,2,3,4|architecture overview]] with attention mechanisms [[paper.pdf#page=5&selection=5,6,7,8|attention details]]."
- evidence: Optional array for additional reference links not mentioned inline (usually can be empty [] since links are inline)
- The sidebar will render markdown and make all [[wiki-links]] clickable with hover preview.
- The user can copy the raw markdown answer or dismiss it.
- This provides a natural reading experience with inline citations.
Evidence-based Q&A workflow
1) Call obsidian_list_open_pdfs to detect open PDFs.
2) If needed, ask the user to choose a PDF.
3) Read the PDF following the PDF reading policy above.
4) Use obsidian_pdf_search to locate relevant passages for the user's question.
5) Produce citations with obsidian_pdf_citations_links.
6) When presenting citations, ensure they follow the WikiLink format and use short evidence summaries as aliases.
7) ALWAYS call obsidian_add_answer at the end to display your answer in the Obsidian sidebar with evidence links.
Tag recommendation + application workflow (only when requested)
1) Load all existing tags via obsidian_vault_tags.
2) Read the selected PDF as comprehensively as possible using the PDF reading policy above.
3) Propose 5-15 candidate tags:
- Prefer existing tags when they fit.
- Propose new tags only when necessary.
4) If hierarchical tags are used (e.g., tag/subtag) and a new axis (new top-level prefix) seems necessary, STOP and ask the user to agree on taxonomy before applying.
5) If the user confirms applying tags:
- List open markdown notes via obsidian_md_open; ask to choose if multiple.
- Update ONLY frontmatter.tags via obsidian_md_frontmatter.
- Merge with existing tags (no overwrite), dedupe, preserve order as much as possible.
Note insertion workflow (only when explicitly requested)
- Ask where to insert (top/bottom/under a specific heading).
- Then insert using obsidian_md_replace_lines.
コマンド
| コマンド |
説明 |
| PDFエビデンスサーバーを起動 |
HTTPサーバーを手動で起動します。 |
| PDFエビデンスサーバーを停止 |
HTTPサーバーを停止します。 |
| 開いているPDFリストをコピー |
開いているPDFのJSONをクリップボードにコピーします。 |
| MCPツールマニフェストをコピー |
MCPクライアント用のツール定義をコピーします。 |
| MCPブリッジ設定をコピー |
Claude Desktop + OpenCodeの設定をコピーします。 |
| AI回答パネルを表示 |
AI回答サイドバーを開きます。 |
動作原理
┌─────────────────┐ stdio/MCP ┌──────────────┐ HTTP ┌─────────────────┐
│ Claude Desktop │◄──────────────────►│ bridge.mjs │◄───────────────►│ Obsidian Plugin │
│ / OpenCode │ │ (Node.js) │ │ (HTTP Server) │
└─────────────────┘ └──────────────┘ └─────────────────┘
│
▼
┌─────────────┐
│ PDF.js │
│ (built-in) │
└─────────────┘
- HTTPサーバー:プラグインはローカルHTTPサーバー(デフォルトポート27123)を実行し、PDFとボールトのデータを公開します。
- MCPブリッジ:Node.jsブリッジスクリプト (
bridge.mjs) がMCPプロトコル呼び出しをHTTPリクエストに変換します。
- PDF.js統合:Obsidianに組み込まれたPDF.jsを使用して、位置データ付きのテキストを抽出します。
- 曖昧マッチング:レーベンシュタイン距離を使用して近似的なテキストマッチを見つけ、堅牢な引用リンクを作成します。
- PDF++リンク:
#page= と &selection= パラメータ付きのウィキリンクを生成し、正確なハイライトを行います。
更新ノート
- プラグインのポートが変更された場合は、ブリッジ設定のJSONを再コピーして、ベースURLが一致するようにします。
- ブリッジロジックが変更された場合は、
npm run build を再実行して bridge/bridge.mjs を更新します。
manifest.json のIDを obsidian-pdf-evidence のままにしておくと、Obsidianが正しいフォルダを読み込みます。
📄 ライセンス
MIT