cyanheads/pubmed-mcp-server/api-workers
Claude Code and agent skill by cyanheads/pubmed-mcp-server
- community
Checking that the SKILL.md file is still in the repository.
Cloudflare Workers deployment using `createWorkerHandler` from `@cyanheads/mcp-ts-core/worker`. Covers the full handler signature, binding types, CloudflareBindings extensibility, runtime compatibility guards, and wrangler.toml requirements.
Install
npx vskill@latest install cyanheads/pubmed-mcp-server/api-workersSKILL.md
The same SKILL.md was published earlier as cyanheads/pubmed-mcp-server/api-workers.
Overview
@cyanheads/mcp-ts-core/worker exports createWorkerHandler — the Workers entry point. It wraps tool/resource/prompt registries into a per-request McpServer factory that integrates with the Cloudflare Workers runtime.
createWorkerHandler(options)
Fresh scaffolds register definitions directly in the entry point as shown above. If your project later adds barrel files for definitions, importing arrays from those barrels is also fine.
Options
| Option | Type | Purpose | ||
|---|---|---|---|---|
tools | AnyToolDefinition[] | Tool definitions to register | ||
resources | AnyResourceDefinition[] | Resource definitions to register | ||
prompts | PromptDefinition[] | Prompt definitions to register | ||
extensions | Record<string, object> | SEP-2133 extensions to advertise in server capabilities | ||
instructions | `string \ | (env: CloudflareBindings) => string` | Server-level orientation forwarded to the model on every initialize. Resolver form runs inside initializeApp(env) so env-derived text is available (see Workers-specific warnings). Empty string treated as unset. | |
skills | `Record<string, string \ | Uint8Array>` | Published skills to serve over MCP (SEP-2640): paths under the skills folder mapped to file contents — see Serving skills | |
setup | `(core: CoreServices) => void \ | Promise<void>` | Runs after core services are ready, during the first request (lazy init inside the fetch handler) | |
decodeResourceParams | boolean | Percent-decode each matched resource URI template variable once before params validation; default false, same as on createApp. Turning it on and deleting a handler's own decodeURIComponent are one change, or the handler decodes twice — see add-resource § Percent-encoded template variables | ||
extraEnvBindings | [bindingKey: string, processEnvKey: string][] | Maps CF string bindings to process.env keys | ||
extraObjectBindings | [bindingKey: string, globalKey: string][] | Maps CF object bindings (KV, R2, D1, AI) to globalThis keys | ||
onScheduled | (controller, env, ctx) => Promise<void> | Cloudflare cron trigger handler |
Key design points
- Per-request `McpServer` factory: a new server instance is created for each request. Required by SDK security advisory GHSA-345p-7cg4-v4c7.
- Env bindings refreshed per-request: Cloudflare may rotate binding object references between requests; the handler re-injects them on every call.
- OTel NodeSDK is disabled in Workers —
canUseNodeSDK()returnsfalsefor V8 isolates, so the framework registers no tracer or meter provider and exports no OTLP spans or metrics itself. Structured logs viactx.logstill work. A Worker that registers its own tracer provider receives the framework's spans under the scopeOTEL_SERVICE_NAME/OTEL_SERVICE_VERSIONnames, andOTEL_ENABLED=trueadds the@hono/otelrequest spans on the MCP endpoint when that optional peer is installed.ctx.waitUntil()is received and passed through toapp.fetchandonScheduledbut not called by the framework (nothing to flush asynchronously). - Singleton app promise with retry-on-failure: the framework init runs once; if it fails, the next request retries rather than leaving the Worker in a permanently broken state.
- Core config is re-parsed on the first request: init drops any config cached before it and parses again after the bindings are injected, with or without
name/version, soMCP_AUTH_MODE,ENVIRONMENT, and the always-httptransport hold even when something readconfigat module load. AresetConfig(overrides)call made before that request does not survive it.
Binding types
Cloudflare Workers bindings come in two kinds with different injection mechanisms:
| Type | Examples | Injection mechanism | Runtime access | |
|---|---|---|---|---|
| String values | API keys, base URLs, feature flags | injectEnvVars() → process.env | process.env.MY_API_KEY | |
| Object bindings | KV namespace, R2 bucket, D1 database, AI | storeBindings() → globalThis | (globalThis as any).MY_CUSTOM_KV |
`extraEnvBindings`: array of [bindingKey, processEnvKey] tuples. The value of env[bindingKey] is assigned to process.env[processEnvKey] at request time.
`extraObjectBindings`: array of [bindingKey, globalKey] tuples. The object at env[bindingKey] is stored on globalThis[globalKey] at request time.
Both are refreshed on every request. Never cache binding references between requests.
Core string bindings
Every variable the core config parser reads is either fed by a core binding or excluded for a stated reason. createWorkerHandler copies each core binding into process.env on every request, before config is parsed, so it applies whether or not the runtime populates process.env from bindings (nodejs_compat_do_not_populate_process_env, disallow_importable_env). CloudflareBindings types each one as an optional string. A blank value is skipped.
| Group | Bindings | |
|---|---|---|
| Renamed | ENVIRONMENT → NODE_ENV; LOG_LEVEL → MCP_LOG_LEVEL (an unrecognized level becomes info) | |
| Identity | MCP_SERVER_NAME, MCP_SERVER_VERSION, MCP_SERVER_DESCRIPTION, MCP_SERVER_HOMEPAGE, PACKAGE_NAME, PACKAGE_VERSION, PACKAGE_DESCRIPTION, PACKAGE_KEYWORDS | |
| Logging | LOG_TOOL_FAILURE_PAYLOADS, LOG_TOOL_FAILURE_PAYLOAD_MAX_BYTES, MCP_LOG_RATE_LIMIT_THRESHOLD, MCP_LOG_RATE_LIMIT_WINDOW_MS, LOG_LLM_INTERACTIONS | |
| HTTP surface | MCP_HTTP_ENDPOINT_PATH, MCP_HTTP_MAX_BODY_BYTES, MCP_PUBLIC_URL, MCP_ALLOWED_ORIGINS, MCP_STATEFUL_SESSION_STALE_TIMEOUT_MS, MCP_HTTP_RESUMABILITY, MCP_HTTP_RESUMABILITY_MAX_EVENTS, MCP_HTTP_RESUMABILITY_TTL_MS | |
| Auth | MCP_AUTH_MODE, MCP_AUTH_SECRET_KEY, MCP_AUTH_DISABLE_SCOPE_CHECKS, MCP_JWT_EXPECTED_AUDIENCE, MCP_JWT_EXPECTED_ISSUER, MCP_SERVER_RESOURCE_IDENTIFIER, MCP_REQUEST_STATE_KEY, OAUTH_ISSUER_URL, OAUTH_AUDIENCE, OAUTH_JWKS_URI, OAUTH_JWKS_COOLDOWN_MS, OAUTH_JWKS_TIMEOUT_MS | |
| Storage and canvas | STORAGE_PROVIDER_TYPE, SUPABASE_URL, SUPABASE_ANON_KEY, SUPABASE_SERVICE_ROLE_KEY, CANVAS_PROVIDER_TYPE (so duckdb reaches the factory and fails closed) | |
| LLM | OPENROUTER_API_KEY, OPENROUTER_APP_URL, OPENROUTER_APP_NAME, LLM_DEFAULT_MODEL, LLM_DEFAULT_TEMPERATURE, LLM_DEFAULT_TOP_P, LLM_DEFAULT_MAX_TOKENS, LLM_DEFAULT_TOP_K, LLM_DEFAULT_MIN_P | |
| Speech | SPEECH_TTS_ENABLED, SPEECH_TTS_PROVIDER, SPEECH_TTS_API_KEY, SPEECH_TTS_BASE_URL, SPEECH_TTS_DEFAULT_VOICE_ID, SPEECH_TTS_DEFAULT_MODEL_ID, SPEECH_TTS_TIMEOUT, SPEECH_STT_ENABLED, SPEECH_STT_PROVIDER, SPEECH_STT_API_KEY, SPEECH_STT_BASE_URL, SPEECH_STT_DEFAULT_MODEL_ID, SPEECH_STT_TIMEOUT | |
| Telemetry | OTEL_ENABLED, OTEL_SERVICE_NAME, OTEL_SERVICE_VERSION (the scope of every framework span and meter), OTEL_EXPORTER_OTLP_TRACES_ENDPOINT, OTEL_EXPORTER_OTLP_METRICS_ENDPOINT |
No core binding feeds these, because none has an effect on a Worker:
| Variables | Reason | |
|---|---|---|
MCP_TRANSPORT_TYPE | The Worker sets http itself | |
MCP_SESSION_MODE | Workers take the sessionMode option, not the env session contract | |
DEV_MCP_AUTH_BYPASS, DEV_MCP_CLIENT_ID, DEV_MCP_SCOPES | Development-only auth bypass | |
MCP_HTTP_PORT, MCP_HTTP_HOST, MCP_HTTP_MAX_PORT_RETRIES, MCP_HTTP_PORT_RETRY_DELAY_MS | A Worker binds no listener | |
MCP_GC_PRESSURE_INTERVAL_MS, MCP_HEARTBEAT_INTERVAL_MS, MCP_HEARTBEAT_MISS_THRESHOLD | Read only by createApp | |
LOGS_DIR, STORAGE_FILESYSTEM_PATH | A Worker has no filesystem | |
CANVAS_DEFAULT_MEMORY_LIMIT_MB, CANVAS_EXPORT_PATH, CANVAS_TEMP_PATH, CANVAS_MAX_CANVASES_PER_TENANT, CANVAS_TTL_MS, CANVAS_ABSOLUTE_CAP_MS, CANVAS_SWEEPER_INTERVAL_MS, CANVAS_DEFAULT_ROW_LIMIT, CANVAS_SCHEMA_SNIFF_ROWS | DuckDB does not run on Workers | |
OTEL_TRACES_SAMPLER_ARG, OTEL_LOG_LEVEL, OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT | The OpenTelemetry SDK does not run on Workers |
On a Worker whose process.env is populated from its bindings, a same-named binding for one of these still reaches the parser; an extraEnvBindings entry reaches it on any Worker.
`DEV_MCP_AUTH_BYPASS` on Workers is honored only when the Worker's environment is explicitly development or testing (or the aliases dev, test), declared by the ENVIRONMENT binding or by a NODE_ENV that reaches process.env. With the flag on and neither set, initialization fails with a ConfigurationError naming DEV_MCP_AUTH_BYPASS and ENVIRONMENT, and the Worker serves nothing; production refuses the flag on every runtime. For local development, set ENVIRONMENT=development beside the flag in .dev.vars:
CloudflareBindings extensibility
Core defines CloudflareBindings without an index signature, so servers extend it via intersection rather than module augmentation:
Pass MyBindings as a type parameter where the framework accepts a generic env type (e.g., Hono route handlers, onScheduled).
Runtime compatibility
runtimeCaps feature detection
runtimeCaps is a snapshot taken at import time. Fields: isNode, isBun, isWorkerLike, isBrowserLike, hasProcess, hasBuffer, hasTextEncoder, hasPerformanceNow. All booleans, never throw.
Serverless storage whitelist
In Workers, only these storage providers are allowed:
| Provider | Notes | |
|---|---|---|
in-memory | Default — data lost on cold start, no persistence | |
cloudflare-kv | KV namespace binding — eventually consistent. Each value is stored under <tenantId>:<key>, capped at 512 bytes: a key past it throws ValidationError before the binding is called | |
cloudflare-r2 | R2 bucket binding — object storage. Each value is stored under <tenantId>:<key>, capped at 1,024 bytes: a key past it throws ValidationError before the binding is called | |
cloudflare-d1 | D1 database binding — SQLite-compatible |
filesystem, supabase, and unknown provider types are not on the whitelist:
- `filesystem` and unknown types throw
ConfigurationErrorin serverless environments. - `supabase` does not silently fall back. The serverless provider whitelist check fires immediately at the top of
createStorageProvider()— Supabase credentials are never validated. Worker startup fails withConfigurationErrorbecause Supabase is not on the serverless whitelist. Do not setSTORAGE_PROVIDER_TYPE=supabasein a Worker.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingframework-skills/api-workers/SKILL.md
Popularity
- Repository stars
- 159
- Repository forks
- 24
- 7-day trend score
- 0
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cyanheads/pubmed-mcp-server/api-workers)