Scrapbox Cosense MCP Server
scrapbox-cosense-mcp
概要
Cosense(旧 Scrapbox) 用の MCP サーバーです。
ツール | 説明 | 認証が必要 |
| ページのコンテンツ、メタデータ、リンクを取得します | 非公開プロジェクトの場合 |
| 並べ替えとページネーションでページを閲覧します(最大1000件) | 非公開プロジェクトの場合 |
| キーワードハイライト付きの全文検索(最大100件) | 非公開プロジェクトの場合 |
| WebSocket API を使用して Markdown / Scrapbox ボディでページを作成します | はい |
| ページの直接 URL を生成します | いいえ |
| ページ内の指定行の後にテキストを挿入します | はい |
| 完全一致する行を置換します(複数行ブロックを含む。最初の一致、または | はい |
| 完全一致する行を削除します(複数行ブロックを含む。最初の一致、または | はい |
| すべての行を空にしてページを削除します — オプトイン、後述 | はい |
| ページの全コンテンツを置き換えます — オプトイン、後述 | はい |
| AI 向けに最適化された形式でページとそのリンク先ページ(1-hop/2-hop)を取得します | はい |
create_page、insert_lines、edit_lines、rewrite_page は、コンテンツ変換を制御する format パラメータ("markdown" または "scrapbox")をサポートしています。
edit_lines はデフォルトでは最初に一致した行のみを置換します。すべての出現箇所を置換するには matchAll: true を設定します。デフォルトは意図的に慎重になっています。箇条書きマーカーや空行などの行はページ内で何度も繰り返される可能性があり、一度にすべてを置換することは呼び出し側の意図と一致しないことがほとんどだからです。
targetLineText は改行を含めて連続する複数行のブロックに一致させることができます。ブロックは全体として置換されるため、n 行を m 行にできます(例: 複数行を1行にまとめる)。matchAll: true のブロック一致は重複しません。
delete_lines は同じ完全一致(およびブロック)のセマンティクスを使用しますが、一致した行を置換するのではなく削除します。タイトル行(最初の行)の削除は拒否されます。ページ自体の名前変更や削除につながるためです。その場合は delete_page を使用してください。
delete_page と rewrite_page はオプトイン
delete_page と rewrite_page は、COSENSE_ENABLE_DELETE=true が設定されない限り登録されません。設定がない場合、どちらのツールもツールリストに一切表示されないため、エージェントが誤って呼び出すこともできません。このサーバーは共有の MCP 構成に追加されることが多いため、ページ全体の破壊は意図的に有効にした人だけに公開されます。
理由: insert_lines、edit_lines、delete_lines はすべて完全一致を必要とし、それは呼び出し側が実際にページを読んだ場合にのみ可能です。つまり、すでに知っている行しか破壊できません。delete_page と rewrite_page は呼び出し側がページを読んだかどうかに関係なくページ全体に作用するため、別のオプトインゲートを設けています。
delete_page はページのすべての行を空にし、Cosense はすべての行が空になるとページを削除します。元に戻すことはできません。さらに2つのガードが組み込まれています:
ページが存在している必要があります。存在しないページは、黙って成功するのではなくエラーを返します。(REST API は作成されていないページでもタイトル行を返すため、
create_pageと同じ方法でpersistentを確認します。)dryRun: trueは、削除される行数と最初の5行を表示しますが、ページには触れません。
rewrite_page はページの全コンテンツを置き換えます(タイトルは最初の行として保持されます)。同じガードに加えて、独自のガードが2つあります:
ページが存在している必要があります —
persistentの確認はcreate_pageと逆で、タイプミスによって新しいページが黙って作成されることはありません。空のコンテンツは拒否されます — ページの削除は
delete_pageの役割です。dryRun: trueは、変更前後の行数とプレビューを表示しますが、ページには触れません。
異なるプロジェクト用にこのサーバーの複数のインスタンスを実行する場合、削除を許可する各インスタンスに変数を設定してください:
{
"mcpServers": {
"cosense-notes": {
"command": "npx",
"args": ["-y", "scrapbox-cosense-mcp"],
"env": {
"COSENSE_PROJECT_NAME": "notes",
"COSENSE_SID": "s:your-session-id",
"COSENSE_TOOL_SUFFIX": "notes",
"COSENSE_ENABLE_DELETE": "true"
}
},
"cosense-archive": {
"command": "npx",
"args": ["-y", "scrapbox-cosense-mcp"],
"env": {
"COSENSE_PROJECT_NAME": "archive",
"COSENSE_SID": "s:your-session-id",
"COSENSE_TOOL_SUFFIX": "archive"
}
}
}
}ここでは、notes インスタンスは delete_page_notes を公開し、archive インスタンスは削除ツールを一切公開しません。
insert_lines と edit_lines は、対象の行が存在しない場合の動作が異なります。insert_lines はページの末尾に追記します。「このテキストをどこかに追加」にはまだ妥当な結果があるためです。edit_lines はエラーを返し、ページには触れません。「この特定の行を置換」には意味のあるフォールバックがないためです。置換テキストを追記すると、呼び出し側が求めていないページが黙って生成されることになります。
Related MCP server: scrapbox-cosense-mcp-editable
クイックスタート
デスクトップ拡張機能(.mcpb)— 最も簡単
GitHub Releases から
scrapbox-cosense-mcp.mcpbをダウンロードしますダブルクリック — Claude Desktop にインストールダイアログが表示されます
プロジェクト名を入力します(非公開プロジェクトの場合はセッション ID も)
Claude Code プラグイン
マーケットプレイスを追加:
/plugin marketplace add worldnine/scrapbox-cosense-mcpプラグインをインストール:
/plugin install scrapbox-cosense@worldnine-scrapbox-cosense-mcpデフォルトではグローバルにインストールされます。他のスコープには
--scope projectまたは--scope localを使用します。設定ファイルに環境変数を設定:
{ "env": { "COSENSE_PROJECT_NAME": "your_project_name", "COSENSE_SID": "your_sid" } }ファイル
スコープ
~/.claude/settings.jsonすべてのプロジェクト(グローバル)
.claude/settings.local.jsonこのプロジェクトのみ(gitignore 対象)
プラグインには MCP サーバー設定と CLI 操作用の /cosense スキルが含まれています。
Claude Code(手動 MCP セットアップ)
プラグインではなく手動で設定する場合は:
claude mcp add scrapbox-cosense-mcp \
-e COSENSE_PROJECT_NAME=your_project \
-e COSENSE_SID=your_sid \
-- npx -y scrapbox-cosense-mcpClaude Desktop / その他の MCP クライアント
設定ファイルに追加:
クライアント | 設定ファイル |
Claude Desktop (macOS) |
|
Claude Desktop (Windows) |
|
Cursor |
|
Windsurf |
|
{
"mcpServers": {
"scrapbox-cosense-mcp": {
"command": "npx",
"args": ["-y", "scrapbox-cosense-mcp"],
"env": {
"COSENSE_PROJECT_NAME": "your_project_name",
"COSENSE_SID": "your_sid"
}
}
}
}ソースからビルド
git clone https://github.com/worldnine/scrapbox-cosense-mcp.git
cd scrapbox-cosense-mcp
npm install && npm run build設定
必須
変数 | 説明 |
| あなたの Scrapbox/Cosense プロジェクト名 |
| 非公開プロジェクト用のセッション ID( |
オプション
変数 | デフォルト | 説明 |
|
| API ドメイン |
|
| ツール説明内の表示名 |
|
| 初回ページ取得制限(1〜1000) |
|
| 初期ソート: updated、created、accessed、linked、views、title |
| — | 複数インスタンス用のツール名サフィックス(例: |
|
| Markdown 変換で番号付きリストを箇条書きリストに変換します |
|
| 初期リソースリストからピン留めページを除外します |
|
|
|
CLI の使用法
同じバイナリはスタンドアロン CLI としても機能します:
scrapbox-cosense-mcp get "Page Title"
scrapbox-cosense-mcp search "keyword"
scrapbox-cosense-mcp list --sort=updated --limit=20
scrapbox-cosense-mcp create "New Page" --body="Markdown content"
scrapbox-cosense-mcp insert "Page" --after="target line" --text="new text"
scrapbox-cosense-mcp edit "Page" --target="old line" --text="new text"
scrapbox-cosense-mcp delete-lines "Page" --target="old line"
scrapbox-cosense-mcp delete "Page" --dry-run # needs COSENSE_ENABLE_DELETE=true
scrapbox-cosense-mcp rewrite "Page" --body="new content" --dry-run # needs COSENSE_ENABLE_DELETE=true
scrapbox-cosense-mcp url "Page Title"フラグ | 説明 |
| トークン効率の良いコンパクトな出力(AI エージェント推奨) |
| プロジェクト名を上書き |
| JSON として出力 |
| ヘルプを表示(詳細は |
複数プロジェクト
すべてのツールは、単一のサーバーから別のプロジェクトを対象にするためのオプションの projectName パラメータを受け入れます。資格情報が異なる複数の非公開プロジェクトの場合は、COSENSE_TOOL_SUFFIX を使用して個別のサーバーインスタンスを実行します。
詳細な設定例については docs/multiple-projects.md を参照してください。
開発
コマンド | 説明 |
| ビルド(TypeScript → JavaScript) |
| 開発中の自動リビルド |
| テストスイートを実行 |
| ESLint を実行 |
| MCP Inspector でデバッグ |
コントリビューション
mainからフィーチャーブランチを作成します変更に対するテストを追加します
npm run lint && npm testを実行しますプルリクエストを作成します — CI が自動的に実行されます
ライセンス
MIT
Available Tools
9 toolscreate_pageB
Create a new page in Scrapbox project on cosense (scrapbox). Creates a new page with the specified title and optional body text. Returns the page creation URL without opening browser. Uses my-cosense-project project as default if projectName is not specified.
Inputs: title (required), body, format, projectName, +1 more.
delete_linesA
Delete one or more lines from a Scrapbox page on cosense (scrapbox). Matches the target by exact text. If targetLineText contains newline characters, it is matched as a contiguous block of lines and removed as a whole. By default only the first match is removed; set matchAll to remove every (non-overlapping) occurrence. Refuses to delete the title line (the first line), which would rename or remove the page — use delete_page for that. Returns an error if no match is found. Requires COSENSE_MCP_PAT or COSENSE_SID. Uses my-cosense-project project as default if projectName is not specified.
Inputs: pageTitle (required), targetLineText (required), matchAll, projectName.
edit_linesA
Replace one or more lines in a Scrapbox page on cosense (scrapbox). Matches the target by exact text and substitutes it with new content (which may span multiple lines). If targetLineText contains newline characters, it is matched as a contiguous block of lines, so any n lines can be replaced with m lines. By default only the first match is replaced; set matchAll to replace every (non-overlapping) occurrence. Returns an error if no match is found. Requires COSENSE_MCP_PAT or COSENSE_SID. Uses my-cosense-project project as default if projectName is not specified.
Inputs: newText (required), pageTitle (required), targetLineText (required), format, +2 more.
get_pageB
Get a page from Scrapbox project on cosense (scrapbox). Returns page content and its linked pages. Page content includes title and description in plain text format. Uses my-cosense-project project as default if projectName is not specified.
Inputs: pageTitle (required), projectName.
get_page_urlA
Generate URL for a page in Scrapbox project on cosense (scrapbox). Returns the direct URL to the specified page without opening it in browser. Uses my-cosense-project project as default if projectName is not specified.
Inputs: title (required), projectName.
get_smart_contextA
Get smart context for a page on cosense (scrapbox). Returns the target page and its linked pages (1-hop or 2-hop) with full content in AI-optimized format. Useful for understanding the context and related knowledge around a specific topic. Requires COSENSE_MCP_PAT or COSENSE_SID. Uses my-cosense-project project as default if projectName is not specified.
Inputs: title (required), hopCount, projectName.
insert_linesA
Insert text after a specified line in a Scrapbox page on cosense (scrapbox). If target line not found, text is appended to the end of the page. Uses my-cosense-project project as default if projectName is not specified.
Inputs: text (required), pageTitle (required), targetLineText (required), format, +1 more.
list_pagesA
Browse and list pages from Scrapbox project on cosense (scrapbox) with flexible sorting and pagination. Use this tool to discover pages by recency, popularity, or alphabetically. Returns page metadata and first 5 lines of content. Available sorting methods: updated (last update time), created (creation time), accessed (access time), linked (number of incoming links), views (view count), title (alphabetical). Different from search_pages which finds content by keywords. Uses my-cosense-project project as default if projectName is not specified.
Inputs: skip, sort, limit, projectName, +1 more.
search_pagesA
Search for content within pages in Scrapbox project on cosense (scrapbox). Use this tool to find pages containing specific keywords or phrases. Returns matching pages with highlighted search terms and content snippets. Limited to 100 results maximum. Supports basic search ("keyword"), multiple keywords ("word1 word2" for AND search), exclude words ("word1 -word2"), and exact phrases (""exact phrase""). Different from list_pages which browses pages by metadata. Uses my-cosense-project project as default if projectName is not specified.
Inputs: query (required), projectName.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Most tools target distinct operations (URL, create, edit, delete, insert, list, search). However, get_page and get_smart_context overlap notably since both return page content plus linked pages, differing mainly in formatting and hop depth, which could cause misselection.
All tools follow a consistent snake_case verb_noun pattern (get_page_url, get_smart_context, create_page, edit_lines, delete_lines, get_page, insert_lines, list_pages, search_pages). No mixed conventions or vague verbs.
Nine tools is well-scoped for a note-taking/wiki server, with each tool earning its place across read, write, discovery, and navigation operations.
The surface covers create, read, line-level edit/insert/delete, list, and search, but lacks a page-level delete or rename tool—ironically delete_lines explicitly references a delete_page tool that is not present, creating a dead end for removing or renaming whole pages.
Maintenance
Related MCP Connectors
OAuth-protected, read-only-by-default MCP server for provenance-labeled QuillCaddie project memory.
Private journal MCP server to search, analyze, and create Dabble Me entries securely via OAuth.
Shared project wiki for AI agents: read and write pages, next actions, and activity logs over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceAn MCP server for Wiki.js projects that enables full-text search, page retrieval, and page management capabilities. It allows LLMs to interact with wiki content through specialized tools for searching, listing, and creating pages.ISC
- AlicenseNot gradedqualityCmaintenanceMCP server for Cosense (formerly Scrapbox) that enables page creation, editing, deletion, and searching with WebSocket-based operations. Extends the original server with page-deletion and line-editing tools.2 npmMIT
- FlicenseNot gradedqualityDmaintenanceRead-only MCP server for the Cosense project 'shiyui' that provides tools for fetching pages, full-text search, vector search, and related page retrieval. It uses Cloudflare Access OAuth for authentication.-
- AlicenseNot gradedqualityDmaintenanceA stateless Remote MCP server on Cloudflare Workers for operating a single Cosense (formerly Scrapbox) project. It enables page retrieval, listing, full-text search, and line insertion via natural language, protected by Cloudflare Access Managed OAuth and JWT validation.MIT