cosensecli
Read-only access to Cosense/Scrapbox wiki projects: browse a page in full (metadata, icons, Infobox, body with attachments, related pages), explore a page's 1-hop and 2-hop neighbourhood, run full-text and semantic (vector) search over a project, list pages sorted by backlinks or views, track changes to a page including renames, read attached files and their extracted text, and list the projects the configured credentials belong to. A default project can be set so tools accept a bare page title.
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., "@cosensecliwhat did I write about maps, and what links to it?"
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.
@yuiseki/cosensecli
Your Cosense projects, readable by an assistant.
Cosense (formerly Scrapbox) is a wiki whose pages link
into a graph, and a page there often means little on its own: the context lives
in what links to it. cosensecli runs as an MCP server so an
assistant can read a page, walk its neighbourhood, and search a project without
you translating each question into a command.
It reads. It does not write. See what it will not do.
How it relates to the cosense CLI
This package holds no knowledge of the Cosense API. All of it is in
@helpfeel/cosense-cli, which is
Helpfeel's own, and which keeps that knowledge current as Cosense changes.
cosensecli depends on it, runs it as a child process, and passes its output
back as the tool result.
That works because the cosense CLI already formats for a reader rather than a
parser. browsePage returns Markdown carrying the page metadata, the icons, a
per-author summary of who wrote which lines, any Infobox, the body with its
attachments expanded, and the related page titles. A JSON dump of the same page
would say less. So the wrapper is thin on purpose, and the work it does is
choosing a command, building its arguments, and staying out of the way.
The cosense CLI is designed as a harness for an
Agent Skill,
where the Skill carries the domain knowledge and the CLI carries the mechanics.
An MCP client gets no Skill, so what a Skill would have said has to travel in
the tool descriptions instead. That is the one place this package adds rather
than forwards. See ADR 004.
Related MCP server: Enterprise Knowledge MCP Server
A default project
The cosense CLI has no current project: every command names one, which is
right for a command line. Over MCP it is not, because naming the project in
every sentence is the plumbing an assistant was meant to absorb.
export COSENSECLI_DEFAULT_PROJECT=https://scrapbox.io/yuisekiWith that set, "what did I write about maps" is answerable as asked. Every tool
still takes project_url, and a given one wins, so other projects stay
reachable through the same connector. The page tools also take a bare title
once there is a default, since search answers in titles.
See ADR 005.
Install
npm i -g @yuiseki/cosensecliNeeds Node 24 or newer, which is what the CLI underneath declares.
Getting started
cosensecli doctor # is the CLI underneath usable, and am I logged in?
cosensecli --mcp-serverThere is nothing to sync and nothing to configure. Every answer is live, and a public project reads with no credentials at all:
cosensecli doctor
# cosense binary: .../node_modules/@helpfeel/cosense-cli/bin/cosense
# authenticated: no (public projects still readable; run `cosense login` for private ones)Private projects
Everything above works with no credentials at all, because a public project reads anonymously. A private one answers 401 until you log in, and the credentials are the CLI's underneath, not this package's.
There are two kinds, and which one you pick decides how much this server can reach:
cosense login https://scrapbox.io # a personal access token
cosense login https://scrapbox.io/yuiseki # a service account, for one projectA personal access token covers every project you belong to. A service account
is registered against one project and covers only that one, so it is the way
to hand an assistant part of your wiki rather than all of it. When both apply,
the project's service account wins; COSENSE_PAT in the environment wins over
both.
Three things about this are easy to get wrong:
cosense loginreads the secret with the terminal in raw mode, so it needs a TTY. It cannot be run from a service manager, a hook or an assistant. Log in at a terminal first, then start the server.A default project is not a permission.
COSENSECLI_DEFAULT_PROJECTonly fills in an argument that was left out, and every tool still acceptsproject_url. Narrowing what this server can read is done by the credential, never by the default.Adding credentials does not need a restart. Each tool call spawns a fresh
cosense, which reads the settings file itself, so a login lands on the next call. The line this server prints at startup is a snapshot of that moment and says so;cosensecli doctorre-reads.
Under a sandbox that mounts the home directory read-only, a settings file written after the service started is still visible, because the mount is of the live directory rather than a copy. The same sandbox stops anything here from writing it, which is the right way round: reading credentials is this server's job and writing them is not.
MCP server
cosensecli --mcp-server--mcp, mcp-server and mcp start the same thing. stdout carries only
JSON-RPC; anything meant for a human goes to stderr, including a line saying
which credentials it found, so a 401 from a private project is not a surprise.
Configured in a client:
{
"mcpServers": {
"cosense": {
"command": "npx",
"args": ["-y", "@yuiseki/cosensecli", "--mcp-server"],
"env": { "COSENSECLI_DEFAULT_PROJECT": "https://scrapbox.io/yuiseki" }
}
}
}Tools
Eight, all read-only.
Tool | Answers |
| One page, whole: metadata, icons, telomere, Infobox, body, related pages. By URL or by title |
| The 1-hop and 2-hop neighbourhood of a page, or its literate database when the page defines an Infobox |
| Full-text search across a project |
| Search by meaning, over titles and the link notation in bodies |
| The pages of a project, sortable by backlinks or views to find the ones acting as categories |
| What changed on a page, including a rename, by pageId |
| An attached file, and the text extracted from it |
| The projects the credentials belong to. The one tool that needs them |
Each is one command of the cosense CLI, and returns what that command printed.
What it says on stderr
Every call is announced: the tool, its arguments, whether it worked and how long it took.
[cosense-mcp] cosense_search ok 412ms query="地図"
[cosense-mcp] cosense_browse_page failed 380ms title="秘密"Under systemd that is the audit trail. It also means the titles and search terms a model asked about are written to the journal, which is worth knowing before pointing this at a private wiki.
What it will not do
The cosense CLI can edit, delete and upload. None of that is reachable here.
The allowlist in src/cosense.ts is the only path to a command name, and
previewEdit, submitEdit, previewDelete, replaceLinks, uploadFile,
deleteFile and login are not on it. A tool that asked for one would be
refused before a process started.
This is a property of the code rather than a promise in a document, which is
the point: the server is meant to be reachable from an assistant, and the
question of what an assistant can do to your wiki should not rest on what a
README says. Run the write commands yourself with cosense. See
ADR 002.
Where things live
Credentials |
|
| a personal access token, and it wins over the stored ones |
| the project a call is about when it names none |
| the |
There is no cache. The CLI underneath keeps none, so there is no stale day to explain and no directory to make writable when the server runs sandboxed.
Development
npm install
npm run build
npm testThe tests spawn the built CLI and speak JSON-RPC to it over a pipe, so they
cover the framing too. Nothing in them reaches Cosense: COSENSECLI_COSENSE_BIN
points at a stub that records the argv it was called with and prints a canned
answer, which is what makes the argument building testable at all.
The decisions behind the shape of this thing are in docs/ADR, including why it wraps the CLI instead of reimplementing it, why it starts without credentials, and why reach is scoped by the credential rather than by the default project.
This server cannot be deployed
Maintenance
Related MCP Connectors
Read-only access to your Citlyze workspace: AI search visibility, citations, and recommendations.
Read-only access to your CodeMouse accounts, repositories, and AI pull-request reviews.
Read-only search of your Sortio knowledge graph (files and entities) for Claude and ChatGPT.
Read-only search and page retrieval from the public Atisbo documentation corpus. No authentication.
Related MCP Servers
AlicenseNot gradedqualityDmaintenanceSecure read-only access to Coddie project planning data, enabling AI assistants to manage and query projects, phases, and steps.7 npmMIT- FlicenseNot gradedqualityCmaintenanceProvides read-only, citation-backed semantic search and retrieval-augmented generation over enterprise documents via standardized MCP tools, with local embeddings for privacy.-
- FlicenseNot gradedqualityCmaintenanceProvides read-only access to Confluence, GitHub, Jira, Figma, Outlook, Teams, and browser automation for AI clients, enabling safe discovery, retrieval, and summarization of company knowledge without modifying source systems.-
- AlicenseNot gradedqualityAmaintenanceEnables read-only file-management operations from AI assistants, including health checks, connection and folder listings, search, share-link resolution, metadata retrieval, and on-demand document reading.MIT