Scrapbox Cosense MCP Server
An MCP server for Cosense (formerly Scrapbox) that lets an AI agent read, search, create, and edit wiki pages.
Read pages: fetch a page's content, metadata, and linked pages (
get_page)Browse pages: list pages sorted by updated/created/accessed/linked/views/title with pagination up to 1000 (
list_pages)Search content: full-text search with keyword, AND, exclude, and exact-phrase queries, max 100 results (
search_pages)Create pages: make a new page from Markdown (auto-converted) or raw Scrapbox syntax, or just get the creation URL (
create_page)Get URLs: generate a direct link to any page (
get_page_url)Context gathering: retrieve a page plus its 1-hop/2-hop linked pages in AI-optimized format (
get_smart_context)Insert lines: add text after a matched line, falling back to appending at page end (
insert_lines)Edit lines: replace exact-match line(s) or contiguous multi-line blocks, first match or all via
matchAll(edit_lines)Delete lines: remove exact-match line(s) or blocks, refusing to delete the title line (
delete_lines)Multi-project support: target other projects via a
projectNameargument on every tool
Note: whole-page delete_page and rewrite_page exist in the project but are opt-in and not registered in this schema.
Provides access to Scrapbox/Cosense pages, allowing retrieval of page content, metadata, links, and editor information, listing pages in a project, full-text search across pages, and generating page URLs.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Scrapbox Cosense MCP Server search for pages about JavaScript tutorials"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
scrapbox-cosense-mcp
Overview
MCP server for Cosense (formerly Scrapbox).
Tool | Description | Auth Required |
| Get page content, metadata, and links | For private projects |
| Browse pages with sorting and pagination (max 1000) | For private projects |
| Full-text search with keyword highlighting (max 100 results) | For private projects |
| Create a page with a Markdown/Scrapbox body | Yes |
| Generate direct URL for a page | No |
| Insert text after a specified line in a page | Yes |
| Replace exact-match line(s), including a multi-line block (first match, or all with | Yes |
| Delete exact-match line(s), including a multi-line block (first match, or all with | Yes |
| Delete a page — opt-in, see below | Yes |
| Replace a page's entire content — opt-in, see below | Yes |
| Get a page and its linked pages (1-hop/2-hop) in AI-optimized format | Yes |
create_page, insert_lines, edit_lines, and rewrite_page support a format parameter ("markdown" or "scrapbox") to control content conversion.
edit_lines replaces only the first matching line by default. Set matchAll: true to replace every occurrence. The default is deliberately conservative: a line such as a bullet marker or a blank line can repeat many times in a page, and replacing all of them at once is rarely what the caller intended.
targetLineText may contain newlines to match a contiguous block of lines. The block is replaced as a whole, so n lines can become m lines (for example, collapsing several lines into one). Block matches with matchAll: true are non-overlapping.
delete_lines uses the same exact-match (and block) semantics but removes the matched lines instead of replacing them. It refuses to delete the title line (the first line), because that would rename or remove the page itself — use delete_page for that.
delete_page and rewrite_page are opt-in
delete_page and rewrite_page are not registered unless COSENSE_ENABLE_DELETE=true is set. Without it neither tool appears in the tool list at all, so an agent cannot call them even by mistake. This server is often added to a shared MCP configuration, so whole-page destruction is exposed only to those who deliberately turn it on.
The reasoning: insert_lines, edit_lines, and delete_lines all require an exact match, which is only possible if the caller has actually read the page — they can only destroy lines they already know. delete_page and rewrite_page act on the entire page regardless of whether the caller has read it, so they get a separate opt-in gate.
delete_page removes the whole page. There is no undo. Two further guards are built in:
The page must already exist. A missing page returns an error rather than a silent success. (The REST API returns a title line even for a page that was never created, so the check looks at
persistent, the same waycreate_pagedoes.)dryRun: truereports how many lines would be removed and shows the first five of them, without touching the page.
COSENSE_PROJECT_ALLOW_LIST limits reachable projects
Every tool accepts a projectName override, which is how one server serves several projects. A credential (a Personal Access Token or a session ID) often reaches more projects than the default one, so without a limit an agent that names the wrong project can read or write there. COSENSE_PROJECT_ALLOW_LIST is the opt-in fence: when set, only the listed projects and COSENSE_PROJECT_NAME are accepted, and anything else fails before a request is sent. Names are matched exactly, including case, so a spelling variant cannot slip through. Setting the variable to an empty value restricts to the default project alone. Unset keeps the old unrestricted behavior.
rewrite_page replaces a page's entire content (the title is preserved as the first line). It has the same guards, plus two of its own:
The page must already exist — the
persistentcheck is inverted relative tocreate_page, so a typo cannot silently create a new page.Empty content is rejected — removing a page is
delete_page's job.dryRun: truereports the before/after line counts and previews without touching the page.
rewrite_page replaces the whole page. If another edit lands while a rewrite is in flight, the rewrite re-applies on the 409 retry and the concurrent edit is lost silently.
When you run several instances of this server for different projects, set the variable on each instance that should be allowed to delete:
{
"mcpServers": {
"cosense-notes": {
"command": "npx",
"args": ["-y", "scrapbox-cosense-mcp"],
"env": {
"COSENSE_PROJECT_NAME": "notes",
"COSENSE_MCP_PAT": "your-personal-access-token",
"COSENSE_TOOL_SUFFIX": "notes",
"COSENSE_ENABLE_DELETE": "true"
}
},
"cosense-archive": {
"command": "npx",
"args": ["-y", "scrapbox-cosense-mcp"],
"env": {
"COSENSE_PROJECT_NAME": "archive",
"COSENSE_MCP_PAT": "your-personal-access-token",
"COSENSE_TOOL_SUFFIX": "archive"
}
}
}
}Here the notes instance exposes delete_page_notes, while the archive instance exposes no deletion tool at all.
Note that insert_lines and edit_lines behave differently when the target line is absent. insert_lines appends to the end of the page, because "add this text somewhere" still has a reasonable outcome. edit_lines returns an error and leaves the page untouched, because "replace this specific line" has no meaningful fallback — appending the replacement would silently produce a page the caller never asked for.
Related MCP server: scrapbox-cosense-mcp-editable
Quick Start
Desktop Extension (.mcpb) — Easiest
Download
scrapbox-cosense-mcp.mcpbfrom GitHub ReleasesDouble-click — Claude Desktop opens an install dialog
Enter your project name (and a Personal Access Token for private projects or editing)
Claude Code Plugin
Add the marketplace:
/plugin marketplace add worldnine/scrapbox-cosense-mcpInstall the plugin:
/plugin install scrapbox-cosense@worldnine-scrapbox-cosense-mcpInstalls globally by default. Use
--scope projector--scope localfor other scopes.Set environment variables in your settings file:
{ "env": { "COSENSE_PROJECT_NAME": "your_project_name", "COSENSE_MCP_PAT": "your_personal_access_token" } }File
Scope
~/.claude/settings.jsonAll projects (global)
.claude/settings.local.jsonThis project only (gitignored)
The plugin includes MCP server configuration and a /cosense skill for CLI operations.
Claude Code (Manual MCP Setup)
If you prefer manual configuration over the plugin:
claude mcp add scrapbox-cosense-mcp \
-e COSENSE_PROJECT_NAME=your_project \
-e COSENSE_MCP_PAT=your_personal_access_token \
-- npx -y scrapbox-cosense-mcpClaude Desktop / Other MCP Clients
Add to your config file:
Client | Config File |
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_MCP_PAT": "your_personal_access_token"
}
}
}
}Build from Source
git clone https://github.com/worldnine/scrapbox-cosense-mcp.git
cd scrapbox-cosense-mcp
npm install && npm run buildConfiguration
Required
Variable | Description |
| Your Scrapbox/Cosense project name |
Authentication
Public projects can be read without a credential. Private projects, editing, and get_smart_context need one — see Authentication.
Variable | Description |
| Personal Access Token (recommended). Issue one at |
| Session ID ( |
A Service Account access key (Business plan, starts with cs_) also goes in COSENSE_MCP_PAT.
Optional
Variable | Default | Description |
|
| API domain |
|
| Display name in tool descriptions |
|
| Initial page fetch limit (1–1000) |
|
| Initial sort: updated, created, accessed, linked, views, title |
| — | Tool name suffix for multiple instances (e.g. |
|
| Convert numbered lists to bullet lists in Markdown conversion |
|
| Exclude pinned pages from initial resource list |
|
| Register the |
| — | Comma-separated project names that |
| stdio | Set to |
|
| Port for the HTTP transport |
|
| Address the HTTP transport listens on. For anything other than localhost, also set |
| — | Comma-separated |
| — |
|
CLI Usage
The same binary also works as a standalone 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"Flag | Description |
| Token-efficient compact output (recommended for AI agents) |
| Override project name |
| Output as JSON |
| Show help (supports |
Multiple Projects
All tools accept an optional projectName parameter to target a different project from a single server. For multiple private projects with different credentials, run separate server instances with COSENSE_TOOL_SUFFIX.
To limit which projects an agent can reach, set COSENSE_PROJECT_ALLOW_LIST (comma-separated). Requests naming any other project are rejected before any API call, and the error lists the permitted projects. Matching is case-sensitive.
See docs/multiple-projects.md for detailed configuration examples.
Development
Command | Description |
| Build (TypeScript → JavaScript) |
| Auto-rebuild during development |
| Run test suite |
| Run ESLint |
| Debug with MCP Inspector |
Contributing
Create a feature branch from
mainAdd tests for your changes
Run
npm run lint && npm testCreate a pull request — CI runs automatically
Contributors
Thanks to everyone who has contributed to this project:
@kmatsunami — undefined collaborators handling in
get_page, JSR dependency resolution (#20)@vitalibondar —
formatparameter, bare URL doubling fix (#29)@punkpeye, @lwsinclair — README badges (#1, #6)
The full list is on the contributors graph.
License
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.6 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 gradedqualityCmaintenanceA 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