cosense-mcp-worker
Provides tools for interacting with a Cosense (formerly Scrapbox) project, enabling page retrieval with related links, listing recent pages, full-text search, and inserting lines into pages.
Click on "Install 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., "@cosense-mcp-workerSearch Cosense for 'quarterly goals' and summarize the top result."
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.
cosense-mcp-worker
A stateless Remote MCP server that operates on a single Cosense (formerly Scrapbox) project. It runs on Cloudflare Workers, using Hono for HTTP routing and Cloudflare Agents' createMcpHandler() with MCP SDK v2 for MCP. The Worker does not implement OAuth itself; that is delegated to Cloudflare Access Managed OAuth.
One Worker is fixed to one Cosense project and one connect.sid. Other projects or credentials cannot be specified or changed from MCP tool arguments.
One-click deploy to Cloudflare
From this button, users can create, build, and deploy a Worker to their own Cloudflare account. On the setup screen, enter the Worker name, COSENSE_PROJECT_NAME, CF_ACCESS_TEAM_DOMAIN, CF_ACCESS_AUD, and the Secret COSENSE_SID.
After deployment, users must create the Cloudflare Access Application, enable Managed OAuth, and configure the Access Policy themselves.
Provided endpoints
Endpoint | Description |
| Returns a service overview. Does not return project names or secret information. |
| An unauthenticated health check. |
| A Streamable HTTP MCP endpoint protected by Cloudflare Access. |
MCP tools
Tool | Input | Description |
|
| Retrieves the page body, direct links, 1-hop and 2-hop related pages, and external/other-project links. |
| None | Retrieves up to 100 pages ordered by update time, with descriptions and update timestamps. |
|
| Runs a Cosense full-text search within the configured project. |
|
| Inserts immediately after the first exactly matching line. If there is no match, appends to the end. |
Local setup
What you need: Node.js 20 or later, Corepack, a Cloudflare account that can use Cloudflare Zero Trust, and a session ID with permissions for the target Cosense project.
git clone <リポジトリURL> cosense-mcp-worker
cd cosense-mcp-worker
corepack enable
pnpm installSet non-secret values in wrangler.jsonc.
"vars": {
"COSENSE_PROJECT_NAME": "your-project",
"CF_ACCESS_TEAM_DOMAIN": "https://your-team.cloudflareaccess.com",
"CF_ACCESS_AUD": "YOUR_ACCESS_APPLICATION_AUDIENCE_TAG"
}Always set the session ID as a Worker Secret. Do not save it in wrangler.jsonc, source code, or Git.
pnpm wrangler secret put COSENSE_SIDFor local development only, set it in .dev.vars, which is not committed.
COSENSE_SID=your-connect.sid-valueVerification and local execution are as follows.
pnpm lint
pnpm typecheck
pnpm test
pnpm wrangler dev --localCloudflare Access Managed OAuth settings
Only when you are ready to deploy, run the following command.
pnpm deployNext, in the Cloudflare Zero Trust dashboard, create an Access Application for the Worker's hostname.
Create an MCP server application targeting the Worker's domain and the
/mcppath.Configure an Access Policy with users or ID groups allowed to use the target Cosense project.
Copy the Application Audience (AUD) Tag and set it in
CF_ACCESS_AUD.Confirm that the Zero Trust Team Domain matches
CF_ACCESS_TEAM_DOMAIN.Enable Managed OAuth in the Application's Advanced settings.
Register
https://<worker-host>/mcpwith the MCP client.
Cloudflare Access handles the Authorization Code Flow, PKCE, login, refresh tokens, OAuth discovery, and Access Policy. The Worker itself does not implement an OAuth server.
The Worker receives Cf-Access-Jwt-Assertion and only passes requests to /mcp to the MCP handler after verifying the RS256 signature, issuer, and AUD using the Team's JWKS endpoint.
When using Managed OAuth, OAuth discovery information is returned to the client from the Access layer. Do not add OAuth endpoints or a custom authorization server inside the Worker.
Security properties
Treat
COSENSE_SIDas a Secret binding and do not include it in JSON responses or logs./mcprejects requests with a missing or invalid Access assertion with401.The Access JWT signature is verified at
https://<team-domain>/cdn-cgi/access/certs, and the issuer and AUD are also verified./mcpallows all Origins. Compatibility with Remote MCP clients is prioritized; access control is performed by Cloudflare Access OAuth tokens and JWT validation inside the Worker.Because MCP tool schemas reject undefined inputs, callers cannot override projects or credentials.
Arbitrary error details from Cosense are not returned as-is; errors are limited to operation-level errors.
To avoid unintentionally returning huge responses, tool output is capped at 100,000 characters.
Directory structure
src/
config.ts Worker bindingの検証
index.ts Honoルートとstateless MCP HTTP transport
middleware/access-auth.ts Access JWTの検証
mcp/server.ts MCP SDK v2 server factory
mcp/tools/ ツールごとのスキーマと登録処理
cosense/client.ts Cosense adapter
cosense/formatter.ts LLM向けページ整形
cosense/insert-lines.ts 純粋な挿入位置計算
test/ 外部Cosense APIを呼ばないユニットテストReferences
Inspired by yosider/cosense-mcp-server. This project does not copy code from that repository; it is a new implementation for Cloudflare Workers.
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Hosted remote MCP server for YNAB on Cloudflare Workers with OAuth
Streamable HTTP MCP server for Google Calendar and Sheets with OAuth login.
MCP server for AI agents to plan, verify, and deploy Cloudflare-native apps.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ogatomo21/cosense-mcp-worker'
If you have feedback or need assistance with the MCP directory API, please join our Discord server