以前、Wikiリンク記法で書いたマークダウンファイルを静的サイトへビルドするCLIツールの紹介をしました。
CLIツールの新機能としてCLIコマンドによるMCPサーバー実装をしたところ、Claude Codeからの接続で良い感じに使えそうだったので利用例を紹介します。
なお似たようなことはObsidian + MCPサーバープラグインでできると思いますが、ScrapsはCLIを中心としているのでマークダウンファイルさえあればすぐに始められるのが強みです。コンセプトは以下のドキュメントにまとめています。
scrapsコマンドがインストールされていれば以下のコマンドでClaude Codeと接続できます
claude mcp add scraps -- scraps mcp serve --path ~/github/boykush/repositories/wiki/
scraps向けにマークダウンファイルをおいてあるディレクトリを --path
で指定します。今回は実際に自身のナレッジをまとめている https://github.com/boykush/wiki リポジトリをローカルへクローンしたパスです。
> /mcp
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Scraps MCP Server │
│ │
│ Status: ✔ connected │
│ Command: scraps │
│ Args: mcp serve --path /Users/boykush/github/boykush/repositories/wiki/ │
│ Config location: /Users/boykush/.claude.json [project: /Users/boykush/github/boykush/repositories/zenn] │
│ Capabilities: tools │
│ Tools: 5 tools │
│ │
│ ❯ 1. View tools │
│ 2. Reconnect │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
2025/09/15 v0.26.1 時点で用意しているツール群は以下です。
> /mcp
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Tools for scraps (5 tools) │
│ │
│ ❯ 1. lookup_tag_backlinks │
│ 2. search_scraps │
│ 3. list_tags │
│ 4. lookup_scrap_backlinks │
│ 5. lookup_scrap_links │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
- search_scraps: タイトル曖昧検索
- lookup_scrap_links: Scrapから貼られている内部リンク一覧
- lookup_scrap_backlinks: Scrapへ向けられている内部リンク一覧
- list_tags: Tag一覧の取得
- lookup_tag_backlinks: Tagへ向けられている内部リンク一覧
それぞれで返却されるリストはマークダウンコンテンツも含むので、これらのみでも比較的まともにLLMとやりとりすることができます。
早速使ってみましょう。Claude Codeから /export
したものを抽出していきます
特定のワードの関連話題をまとめてもらう
プロンプト
╭─────────────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
│ cwd: /Users/boykush/github/boykush/repositories/zenn │
╰─────────────────────────────────────────────────────────╯
> /clear
⎿ (no content)
> 開発サイクルにBDDプロセスを導入したいです。scrapsに溜めてあるBDDの関連話題を参考に、導入方法をまとめてください
途中経過
詳細
⏺ BDD(Behavior Driven Development)の導入方法をまとめるために、まずscrapsに保存されているBDD関連の情報を調べてみます。
⏺ scraps - search_scraps (MCP)(query: "BDD")
⎿ {
"results": [
{
… +70 lines (ctrl+o to expand)
⏺ BDD関連の話題も確認してみます。
⏺ scraps - lookup_scrap_backlinks (MCP)(tag: "BDD")
⎿ {
"results": [
{
… +104 lines (ctrl+o to expand)
⏺ 関連する実例マッピングやTDDについても確認してみます。
⏺ scraps - search_scraps (MCP)(query: "実例マッピング")
⎿ {
"results": [
{
… +17 lines (ctrl+o to expand)
...
結果
Web検索を挟まず、精度の高い情報を得ることができました。
詳細
⏺ scrapsの情報を基に、BDDプロセスの開発サイクルへの導入方法をまとめます:
BDD(Behavior Driven Development)導入ガイド
BDDとは
BDDはDan NorthによってTDDのビジネス要件との乖離を解消するために提唱された手法です。「テスト」という用語を使わず、システムの振る舞い(Behavio
r)に焦点を当てることで、ビジネスチームと開発チームの共通理解を促進します。
BDDの3つの柱
1. 発見(Discovery)
- 目的: 具体例を使った構造化された協調作業
- 実践: **実例マッピング(Example Mapping)**を活用
- Story、Rule、Example、Questionの4つの要素で整理
- スリーアミーゴス(開発者、テスター、プロダクトオーナー)での協議
2. 定式化(Formulation)
- 目的: システムの振る舞いをメンバーが読みやすいシナリオで文書化
- 実践: Given/When/Then形式(Gherkin記法)でシナリオを記述
- 原則: BRIEFの原則に従う
- Business language: ビジネス言語の使用
- Real data: 実際のデータの使用
- Intention revealing: 意図を明確にする
- Essential: 必須要素に絞る
- Focused: 焦点を絞る
- Brief: 簡潔にする
3. 自動化(Automation)
- 目的: 定式化されたシナリオの検証を自動化
- ツール: Cucumber、SpecFlow、SerenityJSなど
導入ステップ
Phase 1: チーム体制の整備
1. スリーアミーゴスの役割定義
2. BDDの基礎知識共有(推奨書籍: The BDD Booksシリーズ)
3. 共通言語の確立(ユビキタス言語との連携)
Phase 2: プロセスの導入
1. 実例マッピングセッションの定期開催
2. ユーザーストーリーごとの具体例作成
3. Given/When/Thenシナリオの文書化
Phase 3: 自動化の実装
1. 自動化ツールの選定・導入
2. Screenplay Patternなどのデザインパターン適用
3. 生きているドキュメントとして活用
開発サイクルへの組み込み
スプリント計画時
- 実例マッピングセッション実施
- シナリオの定式化
- 自動化テストの計画
開発中
- シナリオベースの開発
- 継続的な自動テスト実行
レビュー時
- ビジネス要件との整合性確認
- シナリオの改善・更新
成功のポイント
1. 段階的導入: 小さなフィーチャーから始める
2. チーム全体の参画: 開発者だけでなくビジネス側も巻き込む
3. 継続的改善: シナリオとプロセスの定期的見直し
4. ツール選択: チームの技術スタックに適したツール選定
この導入方法により、ビジネス要件と実装の乖離を減らし、チーム全体でシステムの振る舞いを共通理解できる開発サイクルが実現できます。
自身を模したエージェントの作成依頼
現在scraps mcpが接続している先には私自身のナレッジがまとめられています。あなたはscraps mcp tool群を活用し、私自身のナレッジを反映したエージェントとして振る舞ってください。エージェント設定のファイルには利用するMCPツール一覧を記載しておきましょう
サブエージェントの作成
> /agents
╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ Create new agent │
│ Describe what this agent should do and when it should be used (be comprehensive for best results) │
│ │
│ 現在scraps │
│ mcpが接続している先には私自身のナレッジがまとめられています。あなたはscraps mcp │
│ tool群を活用し、私自身のナレッジを反映したエージェントとして振る舞ってください │
| エージェント設定のファイルには利用するMCPツール一覧を記載しておきましょう . │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
今回は .claude/agents/
ディレクトリ内にファイルを自動生成してもらいましたが、MCPツールを使うことが明記されていれば良いと思います。
.claude/agents/personal-knowledge-assistant.md
---
name: personal-knowledge-assistant
description: Use this agent when you need to access, reference, or utilize the user's personal knowledge base stored in the scraps MCP system. Examples: Context : User wants to find information about a specific topic they've previously documented. user: 'What did I write about React hooks last month?' assistant: 'I'll search through your personal knowledge base using the scraps MCP tools to find your notes about React hooks.' > Since the user is asking about their personal knowledge, use the personal-knowledge-assistant agent to search through their scraps. Context : User is working on a project and wants to reference their previous learnings. user: 'I'm building a new API and want to reference my previous notes on authentication patterns' assistant: 'Let me use the personal-knowledge-assistant to search through your knowledge base for authentication patterns.' > The user needs to access their personal knowledge, so use the personal-knowledge-assistant agent.>>
model: sonnet
color: red
---
You are a Personal Knowledge Assistant with access to the user's comprehensive knowledge base through the scraps MCP tool system. Your primary role is to serve as an intelligent interface to their personal documentation, notes, and accumulated knowledge.
Your capabilities include:
- Searching through the user's personal knowledge base using scraps MCP tools
- Retrieving specific information, notes, and documentation
- Cross-referencing related topics within their knowledge base
- Summarizing and synthesizing information from multiple sources in their collection
- Identifying patterns and connections across their documented knowledge
When responding:
1. Always utilize the available scraps MCP tools to access the user's knowledge base
2. Provide accurate information based on their documented knowledge, not general knowledge
3. When information is not found in their knowledge base, clearly state this limitation
4. Reference the source or context from their knowledge base when providing information
5. Suggest related topics or connections within their knowledge base when relevant
6. If the user's knowledge appears incomplete on a topic, offer to help them expand it
Available MCP Tools:
- scraps search tools for finding relevant content
- scraps retrieval tools for accessing specific documents or notes
- scraps organization tools for understanding the structure of their knowledge base
Always prioritize the user's documented knowledge over general information, and make it clear when you're drawing from their personal knowledge base versus when information might not be available in their collection.
サブエージェントの利用
少しわかりづらいですが、意図通りscrapsのMCPツールを10回呼び出していました。
> @agent-personal-knowledge-assistant 次は何を学びましょう
⏺ personal-knowledge-assistant(Find next learning topic)
⎿ Done (10 tool uses · 19.5k tokens · 38.5s)
⏺ あなたの学習履歴を分析した結果、次に学ぶべき分野として以下をお勧めします:
最優先でお勧めする学習分野
圏論(Category Theory) - あなたの関数型プログラミング(Scala、Haskell)の知識を数学的基盤から深めることができます。
高度なエフェクトシステム - Extensible Effectsの知識を活かして、ZIOやCats Effectをより深く学ぶ
プラットフォームエンジニアリング - あなたのDevOpsとKubernetes知識を発展させる新しい分野
あなたの現在の知識レベルを考えると、特に圏論から始めることで、既に使っているモナドやエフェクトの理論的背景が理解でき、より高度な関数型プログ
ラミングパターンが身につくでしょう。
どの分野に最も興味がありますか?
しっかりとナレッジの内容を反映した回答が返ってきました。もう1人の自分と会話しているようで楽しいですね。
今回のMCPサーバー実装は、既存の静的サイトジェネレーターCLIの資産を活かしすぐに実装できることがわかっていたので機能追加しました。冒頭で少し触れたObsidianや、同じくローカル開発ベースのFoamに比べて軽量にMCPサーバー連携できたと思います(類似ツールを批判したいわけではなく、自分だったらこう使いたい、というあくまで自己満足の範疇です)。
既存のナレッジ管理ツールへのMCPサーバー拡張以外の手段で似たようなことができるとすれば、Wikiリンク向けLSP(例: markdown-oxide)とそのLSPとのMCPサーバー連携(例: Serena MCP)でしょうか。
個人的に手段は問わず、LLMへ自身の脳(ナレッジ)を拡張として挿し込む思案は続けていきたいです。
オレが3人分になる…
Views: 0