Serena MCP
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Serena MCP – Cloudflare Remote Deployment
Deploy Serena as a remote MCP server reachable from any local AI client (Claude Desktop, Claude Code, Cursor, etc.) via HTTPS.
This repository packages a Cloudflare Workers + Containers deployment wrapper for Serena. It is intended for operators who want a hosted Serena MCP endpoint without modifying Serena's core runtime.
Upstream Serena
Upstream project:
oraios/serenaLicense: MIT (this repository also uses MIT)
Scope of this repository: deployment, routing, auth, and operational docs
Related MCP server: ForgeBridge
Architecture
Local MCP client
│ HTTPS
│ Authorization: Bearer <token>
▼
Cloudflare Worker (TypeScript proxy + auth layer)
│ HTTP proxy
│ route by authenticated token
▼
Cloudflare Container (Python – Serena MCP server)
│ optional R2 snapshot restore/sync via S3 API
└─ serena-mcp-server --transport streamable-http --port 8080Worker – Edge function that validates Bearer tokens and routes
/mcptraffic by authenticated token:API_TOKENonly: legacy singleton routeAPI_TOKENS_JSON: one container route per token (multi-terminal isolation)
Container – Full Python environment running Serena with the Streamable-HTTP transport (port 8080). FastMCP manages MCP sessions inside that one process. Optionally uses the R2 S3-compatible API (
awscli) to restore and periodically snapshot the localSERENA_HOMEdirectory.
Scope and Design Goals
This project is a deployment wrapper for Serena, not a fork of Serena's core runtime. It focuses on:
Cloudflare Workers authentication and request routing
Cloudflare Containers runtime packaging
Optional R2 snapshot persistence for
SERENA_HOMEOperational guardrails for rollouts and remote MCP compatibility
It intentionally does not replace Serena's native project documentation or change Serena's core MCP semantics.
Repository Layout
cloudflare/src/index.ts– Worker auth, routing, and MCP proxy logiccloudflare/bin/start-serena-mcp.sh– container entrypoint with local-state + R2 snapshot syncDockerfile.cloudflare– container image build for Serena MCP on Cloudflare Containerswrangler.toml– Cloudflare deployment configuration (template-safe defaults)cloudflare/README.md– copy of this deployment guide for subdirectory navigation
Prerequisites
Tool | Purpose |
Node package manager | |
Workers Paid plan (required for Containers) | |
Docker (local, for testing) | Optional – build/test the image locally |
Quick Start
1. Install dependencies
# From the project root
pnpm install2. Authenticate with Cloudflare
pnpm wrangler login3. Set Authentication Token Secret(s)
Choose strong, random tokens. These are the Bearer tokens MCP clients will use.
Single terminal / legacy mode:
pnpm wrangler secret put API_TOKEN
# enter your token at the prompt – it is stored encrypted in CloudflareMulti-terminal mode (recommended for concurrent terminals):
pnpm wrangler secret put API_TOKENS_JSONPaste JSON in this format:
{
"terminal-a": "replace-with-real-token-a",
"terminal-b": "replace-with-real-token-b"
}4. (Optional but recommended) Enable R2-backed snapshot persistence for SERENA_HOME
This deployment keeps SERENA_HOME on local container storage and uses the R2
S3-compatible API for startup restore + periodic compressed snapshots.
Suggested bucket name (best-practice style: app-purpose-env):
serena-mcp-state-prodCreate the bucket:
pnpm exec wrangler r2 bucket create serena-mcp-state-prodCreate an R2 Access API key in the Cloudflare dashboard (R2 -> Manage R2 API Tokens), then store the generated credentials as Worker secrets:
pnpm wrangler secret put AWS_ACCESS_KEY_ID
pnpm wrangler secret put AWS_SECRET_ACCESS_KEYUpdate wrangler.toml:
set
R2_ACCOUNT_IDto your Cloudflare account IDkeep
R2_BUCKET_NAME = "serena-mcp-state-prod"(or your preferred name)set
SERENA_R2_STATE_ENABLED = "1"adjust
SERENA_R2_STATE_PREFIXif you want a different path within the bucketkeep
SERENA_R2_STATE_PARTITION_MODE = "durable-object"for multi-terminal isolationoptionally tune
SERENA_R2_SNAPSHOT_INTERVAL_SECONDS/SERENA_R2_SNAPSHOT_RETENTION_COUNT
5. Deploy
pnpm wrangler deployAfter the first deploy, the container image is built and pushed automatically. Container provisioning takes a few minutes on first use.
6. Verify deployment
# Health check (no auth needed)
curl https://serena-mcp.<your-account>.workers.dev/health
# Auth check
curl -H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-X POST \
https://serena-mcp.<your-account>.workers.dev/mcp/health now returns routing and persistence metadata (route generation, route
strategy, and R2 snapshot settings), which is useful for rollouts and debugging.
Connecting a Local Client
Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"serena-remote": {
"command": "npx",
"args": ["-y", "mcp-remote",
"https://serena-mcp.<your-account>.workers.dev/mcp",
"--header", "Authorization: Bearer <token>"]
}
}
}Claude Code (.claude.json or via CLI)
claude mcp add serena-remote \
--transport http \
--url https://serena-mcp.<your-account>.workers.dev/mcp \
--header "Authorization: Bearer <token>"Direct Streamable-HTTP (any MCP client)
URL: https://serena-mcp.<your-account>.workers.dev/mcp
Auth: Authorization: Bearer <your-api-token>
Header: mcp-session-id: <unique-client-id> (optional – for session isolation)Note: the Worker forwards the mcp-session-id header to Serena/FastMCP, but it
does not use that header to select a different container instance. Container
routing is based on the authenticated token (legacy singleton or per-token route).
Useful Commands
pnpm run deploy # deploy Worker + Container
pnpm run dev # local dev mode (Worker only)
pnpm run containers:list # list container resources + health/instance counts
pnpm run containers:images # list container images
pnpm exec wrangler r2 bucket create serena-mcp-state-prod
pnpm exec wrangler r2 bucket info serena-mcp-state-prod
pnpm exec wrangler containers info <CONTAINER_ID>
pnpm exec wrangler containers delete <CONTAINER_ID> # disruptive fallback
pnpm wrangler secret put API_TOKEN # rotate the auth tokenOpen-Source Publishing Notes
If you publish this deployment as a standalone repository, treat the values in
wrangler.toml as templates:
R2_ACCOUNT_IDshould remain empty in source controlR2_BUCKET_NAMEshould be a placeholder or suggested nameSERENA_R2_STATE_ENABLEDshould default to"0"unless you want R2 enabled out of the boxall credentials must be configured via
wrangler secret put
Do not commit:
.wrangler/.serena/memories/local
.envfilesCloudflare API tokens or R2 access keys
For responsible disclosure, see SECURITY.md.
Configuration
| Default | Description |
| 8 | Maximum concurrent container instances (raise for more token-routed terminals) |
|
| Idle timeout before container shutdown |
|
| Generation string used to derive named container routes; bump to force fresh instances |
|
| Enable ( |
|
| Prefix (path) inside the R2 bucket used for Serena snapshots |
|
| Partition R2 snapshot paths per Durable Object/container (recommended for multi-token routing) |
|
| If |
|
| Periodic snapshot interval in seconds ( |
|
| Number of snapshot archives to keep in R2 |
|
| Suggested R2 bucket name for Serena state |
|
| Your Cloudflare account ID for the R2 S3 endpoint |
| (secret) | Legacy single-token auth secret (optional if |
| (secret) | JSON object / array of tokens for multi-terminal token routing |
Container environment variables
Override at deploy time via wrangler.toml [vars] or container envVars:
Variable | Default | Description |
|
| Serena config directory |
|
| Signals to Serena it runs in a container |
| (secret) | R2 Access API key ID (for optional snapshot sync) |
| (secret) | R2 Access API secret (for optional snapshot sync) |
Security Notes
Bearer token comparison uses HMAC-SHA-256 constant-time equality to prevent timing-based token enumeration.
The container is not directly accessible from the public internet; all traffic flows through the authenticating Worker.
Token is stored as a Wrangler secret (encrypted at rest).
Rotate the token with
pnpm wrangler secret put API_TOKEN– no redeploy needed.For multi-terminal mode, manage tokens through
API_TOKENS_JSONand rotate by updating that secret (redeploy not required for Worker secret updates).If you enable R2 persistence, store R2 API credentials as Wrangler secrets (
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY) and scope the R2 API token to the specific state bucket.
Persistence Notes
This deployment persists Serena state by keeping
SERENA_HOMEon local disk and writing compressed snapshots to an R2 bucket prefix via the R2 S3-compatible API (awscli).On startup, the entrypoint restores the latest snapshot (if present) before launching Serena.
During runtime, the entrypoint writes periodic snapshots and a best-effort shutdown snapshot.
In multi-terminal mode, snapshots are partitioned per Durable Object ID so token-routed containers do not overwrite each other's state.
Cloudflare documents this as a valid Containers use case ("Persisting user state"), but note that object storage is not a POSIX filesystem and should not be treated like local SSD storage.
This snapshot pattern avoids live writes to object storage and is safer than mounting
SERENA_HOMEdirectly on a FUSE-backed object store.
Troubleshooting
notifications/initialized Returns 202 Accepted
This deployment intentionally acknowledges MCP
notifications/initialized at the Worker layer (202 Accepted) as a
compatibility shim. In this environment, proxying that notification to the
container can intermittently trigger a Cloudflare Containers internal error
even when the MCP session remains usable.
This behavior is specific to the deployment wrapper and does not change Serena's tool behavior after initialization.
MCP Handshake Fails with HTTP 406 (Not Acceptable)
Symptom (common with some Rust MCP clients): the initialize request succeeds,
but notifications/initialized fails because the client omits the Accept
header and FastMCP's Streamable-HTTP validation rejects it with 406.
This deployment includes a Docker image patch in Dockerfile.cloudflare that
makes a missing Accept header permissive (RFC 7231 behavior).
If you deploy the patch but still see the old behavior, a warm container instance may still be serving traffic. Use one of these options:
Bump
MCP_CONTAINER_ROUTE_GENERATIONinwrangler.toml, then redeploy.Wait for
SerenaContainer.sleepAfterto expire (15mby default).As a disruptive fallback, delete the container via
wrangler containers delete <CONTAINER_ID>and redeploy.
MCP Handshake Step 2 Fails with HTTP 503 (Container unavailable)
If initialize succeeds but notifications/initialized fails with 503, the
container process likely crashed after startup. Common causes include R2 mount
or restore failures.
This deployment defaults to SERENA_R2_STATE_STRICT = "0" so R2 problems
should degrade to local-only mode instead of crashing the container. To debug:
Check
/healthand confirm the route generation matches the current deploy.Temporarily set
SERENA_R2_STATE_ENABLED = "0"and redeploy to isolate R2.If needed, enable strict mode (
SERENA_R2_STATE_STRICT = "1") to surface startup failures deterministically during testing.
notifications/initialized Compatibility Shim
This deployment includes a Worker-side compatibility shim for the MCP
notifications/initialized JSON-RPC notification:
If the request is exactly the
notifications/initializednotification, the Worker returns202 Accepteddirectly instead of proxying it to the container.This is a deployment-specific workaround for a Cloudflare Containers internal error observed on that notification path, while the MCP session itself remains usable (
tools/listand normal requests continue to work).
Limitations
Serena containers start with no pre-loaded project. Use the
activate_projecttool after connecting, or bake a project into the image.Large language-server downloads (e.g., Java, Rust) happen on first use inside the container (may add latency).
Container state is ephemeral – language-server caches are lost when the container sleeps and restarts.
R2 snapshots improve Serena config/state continuity but do not persist FastMCP in-memory session state; clients may still need to re-initialize.
In legacy single-token mode, authenticated clients share one Serena process.
In multi-token mode (
API_TOKENS_JSON), each token is routed to a separate container process (terminal-level isolation).If R2 persistence is disabled,
SERENA_HOMEremains local to the container instance and is lost on restart / sleep / rollout.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Cloud console for a fleet of AI coding agents running on your own machines. OAuth.
Deploy and manage Jade Hosting projects from AI clients. Jade account and OAuth required.
Project context, backlog tasks, and controlled workflows for coding agents. OAuth sign-in.
Hosted backend for AI agents: create projects with persistent collections and keys, no signup.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to access files and terminal of a local computer via a public HTTPS endpoint, secured with GitHub OAuth.-
- AlicenseNot gradedqualityBmaintenanceEnables local, permissioned development workflows from compatible AI clients, including filesystem editing, interactive terminals, durable jobs, Git operations, and semantic browser testing.53 npm1Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables AI clients to access a self-hosted, repository-scoped code map over Streamable HTTP, supporting symbol search, call/reference/dependency tracing, and reading source code pinned to the same published commit.1MIT
- AlicenseNot gradedqualityBmaintenanceEnables Codex and Claude Code to connect over an authenticated local HTTP endpoint to a logged-in Antigravity CLI, allowing shared workspace-authorized task execution and result handling without opening the Antigravity IDE.777 npm7MIT