@cyanheads/reliefweb-mcp-server 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CLAUDE.md +391 -0
  2. package/Dockerfile +98 -0
  3. package/LICENSE +201 -0
  4. package/README.md +320 -0
  5. package/changelog/0.1.x/0.1.0.md +24 -0
  6. package/changelog/0.1.x/0.1.1.md +29 -0
  7. package/changelog/template.md +119 -0
  8. package/dist/config/server-config.d.ts +14 -0
  9. package/dist/config/server-config.d.ts.map +1 -0
  10. package/dist/config/server-config.js +19 -0
  11. package/dist/config/server-config.js.map +1 -0
  12. package/dist/index.d.ts +7 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +42 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/mcp-server/prompts/definitions/crisis-briefing.prompt.d.ts +14 -0
  17. package/dist/mcp-server/prompts/definitions/crisis-briefing.prompt.d.ts.map +1 -0
  18. package/dist/mcp-server/prompts/definitions/crisis-briefing.prompt.js +62 -0
  19. package/dist/mcp-server/prompts/definitions/crisis-briefing.prompt.js.map +1 -0
  20. package/dist/mcp-server/resources/definitions/country.resource.d.ts +9 -0
  21. package/dist/mcp-server/resources/definitions/country.resource.d.ts.map +1 -0
  22. package/dist/mcp-server/resources/definitions/country.resource.js +30 -0
  23. package/dist/mcp-server/resources/definitions/country.resource.js.map +1 -0
  24. package/dist/mcp-server/resources/definitions/disaster.resource.d.ts +9 -0
  25. package/dist/mcp-server/resources/definitions/disaster.resource.d.ts.map +1 -0
  26. package/dist/mcp-server/resources/definitions/disaster.resource.js +30 -0
  27. package/dist/mcp-server/resources/definitions/disaster.resource.js.map +1 -0
  28. package/dist/mcp-server/resources/definitions/report.resource.d.ts +9 -0
  29. package/dist/mcp-server/resources/definitions/report.resource.d.ts.map +1 -0
  30. package/dist/mcp-server/resources/definitions/report.resource.js +30 -0
  31. package/dist/mcp-server/resources/definitions/report.resource.js.map +1 -0
  32. package/dist/mcp-server/tools/definitions/get-country.tool.d.ts +35 -0
  33. package/dist/mcp-server/tools/definitions/get-country.tool.d.ts.map +1 -0
  34. package/dist/mcp-server/tools/definitions/get-country.tool.js +106 -0
  35. package/dist/mcp-server/tools/definitions/get-country.tool.js.map +1 -0
  36. package/dist/mcp-server/tools/definitions/get-disaster.tool.d.ts +42 -0
  37. package/dist/mcp-server/tools/definitions/get-disaster.tool.d.ts.map +1 -0
  38. package/dist/mcp-server/tools/definitions/get-disaster.tool.js +127 -0
  39. package/dist/mcp-server/tools/definitions/get-disaster.tool.js.map +1 -0
  40. package/dist/mcp-server/tools/definitions/get-report.tool.d.ts +30 -0
  41. package/dist/mcp-server/tools/definitions/get-report.tool.d.ts.map +1 -0
  42. package/dist/mcp-server/tools/definitions/get-report.tool.js +92 -0
  43. package/dist/mcp-server/tools/definitions/get-report.tool.js.map +1 -0
  44. package/dist/mcp-server/tools/definitions/list-countries.tool.d.ts +20 -0
  45. package/dist/mcp-server/tools/definitions/list-countries.tool.d.ts.map +1 -0
  46. package/dist/mcp-server/tools/definitions/list-countries.tool.js +83 -0
  47. package/dist/mcp-server/tools/definitions/list-countries.tool.js.map +1 -0
  48. package/dist/mcp-server/tools/definitions/list-sources.tool.d.ts +22 -0
  49. package/dist/mcp-server/tools/definitions/list-sources.tool.d.ts.map +1 -0
  50. package/dist/mcp-server/tools/definitions/list-sources.tool.js +82 -0
  51. package/dist/mcp-server/tools/definitions/list-sources.tool.js.map +1 -0
  52. package/dist/mcp-server/tools/definitions/search-disasters.tool.d.ts +35 -0
  53. package/dist/mcp-server/tools/definitions/search-disasters.tool.d.ts.map +1 -0
  54. package/dist/mcp-server/tools/definitions/search-disasters.tool.js +163 -0
  55. package/dist/mcp-server/tools/definitions/search-disasters.tool.js.map +1 -0
  56. package/dist/mcp-server/tools/definitions/search-jobs.tool.d.ts +32 -0
  57. package/dist/mcp-server/tools/definitions/search-jobs.tool.d.ts.map +1 -0
  58. package/dist/mcp-server/tools/definitions/search-jobs.tool.js +148 -0
  59. package/dist/mcp-server/tools/definitions/search-jobs.tool.js.map +1 -0
  60. package/dist/mcp-server/tools/definitions/search-reports.tool.d.ts +40 -0
  61. package/dist/mcp-server/tools/definitions/search-reports.tool.d.ts.map +1 -0
  62. package/dist/mcp-server/tools/definitions/search-reports.tool.js +191 -0
  63. package/dist/mcp-server/tools/definitions/search-reports.tool.js.map +1 -0
  64. package/dist/mcp-server/tools/definitions/search-training.tool.d.ts +35 -0
  65. package/dist/mcp-server/tools/definitions/search-training.tool.d.ts.map +1 -0
  66. package/dist/mcp-server/tools/definitions/search-training.tool.js +166 -0
  67. package/dist/mcp-server/tools/definitions/search-training.tool.js.map +1 -0
  68. package/dist/services/reliefweb/reliefweb-service.d.ts +103 -0
  69. package/dist/services/reliefweb/reliefweb-service.d.ts.map +1 -0
  70. package/dist/services/reliefweb/reliefweb-service.js +546 -0
  71. package/dist/services/reliefweb/reliefweb-service.js.map +1 -0
  72. package/dist/services/reliefweb/types.d.ts +345 -0
  73. package/dist/services/reliefweb/types.d.ts.map +1 -0
  74. package/dist/services/reliefweb/types.js +7 -0
  75. package/dist/services/reliefweb/types.js.map +1 -0
  76. package/package.json +78 -0
  77. package/server.json +111 -0
package/CLAUDE.md ADDED
@@ -0,0 +1,391 @@
1
+ # Developer Protocol
2
+
3
+ **Server:** @cyanheads/reliefweb-mcp-server
4
+ **Version:** 0.1.1
5
+ **Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.9.7`
6
+ **Engines:** Bun ≥1.3.0, Node ≥24.0.0
7
+ **MCP SDK:** `@modelcontextprotocol/sdk` ^1.29.0
8
+ **Zod:** ^4.4.3
9
+
10
+ > **Read the framework docs first:** `node_modules/@cyanheads/mcp-ts-core/CLAUDE.md` contains the full API reference — builders, Context, error codes, exports, patterns. This file covers server-specific conventions only.
11
+
12
+ ---
13
+
14
+ ## What's Next?
15
+
16
+ When the user asks what's next or needs direction, suggest options based on the current project state. Common next steps:
17
+
18
+ 1. **Re-run the `setup` skill** — ensures CLAUDE.md, skills, structure, and metadata are populated and up to date with the current codebase
19
+ 2. **Run the `design-mcp-server` skill** — if the tool/resource surface hasn't been mapped yet, work through domain design
20
+ 3. **Add tools/resources/prompts** — scaffold new definitions using the `add-tool`, `add-app-tool`, `add-resource`, `add-prompt` skills
21
+ 4. **Add services** — scaffold domain service integrations using the `add-service` skill
22
+ 5. **Add tests** — scaffold tests for existing definitions using the `add-test` skill
23
+ 6. **Field-test definitions** — exercise tools/resources/prompts with real inputs using the `field-test` skill, get a report of issues and pain points
24
+ 7. **Run `devcheck`** — lint, format, typecheck, and security audit
25
+ 8. **Run the `security-pass` skill** — audit handlers for MCP-specific security gaps: output injection, scope blast radius, input sinks, tenant isolation
26
+ 9. **Run the `polish-docs-meta` skill** — finalize README, CHANGELOG, metadata, and agent protocol for shipping
27
+ 10. **Run the `maintenance` skill** — investigate changelogs, adopt upstream changes, and sync skills after `bun update --latest`
28
+
29
+ Tailor suggestions to what's actually missing or stale — don't recite the full list every time.
30
+
31
+ ---
32
+
33
+ ## Core Rules
34
+
35
+ - **Logic throws, framework catches.** Tool/resource handlers are pure — throw on failure, no `try/catch`. Plain `Error` is fine; the framework catches, classifies, and formats. Use error factories (`notFound()`, `validationError()`, etc.) when the error code matters.
36
+ - **Use `ctx.log`** for request-scoped logging. No `console` calls.
37
+ - **Use `ctx.state`** for tenant-scoped storage. Never access persistence directly.
38
+ - **Check `ctx.elicit` / `ctx.sample`** for presence before calling.
39
+ - **Secrets in env vars only** — never hardcoded.
40
+
41
+ ---
42
+
43
+ ## Patterns
44
+
45
+ ### Tool
46
+
47
+ ```ts
48
+ import { tool, z } from '@cyanheads/mcp-ts-core';
49
+
50
+ export const searchItems = tool('search_items', {
51
+ description: 'Search inventory items by query.',
52
+ annotations: { readOnlyHint: true },
53
+ input: z.object({
54
+ query: z.string().describe('Search terms'),
55
+ limit: z.number().default(10).describe('Max results'),
56
+ }),
57
+ output: z.object({
58
+ items: z.array(z.object({
59
+ id: z.string().describe('Item ID'),
60
+ name: z.string().describe('Item name'),
61
+ })).describe('Matching items'),
62
+ }),
63
+ auth: ['inventory:read'],
64
+
65
+ async handler(input, ctx) {
66
+ const items = await findItems(input.query, input.limit);
67
+ ctx.log.info('Search completed', { query: input.query, count: items.length });
68
+ return { items };
69
+ },
70
+
71
+ // format() populates content[] — the markdown twin of structuredContent.
72
+ // Different clients read different surfaces (Claude Code → structuredContent,
73
+ // Claude Desktop → content[]); both must carry the same data.
74
+ // Enforced at lint time: every field in `output` must appear in the rendered text.
75
+ format: (result) => [{
76
+ type: 'text',
77
+ text: result.items.map(i => `**${i.id}**: ${i.name}`).join('\n'),
78
+ }],
79
+ });
80
+ ```
81
+
82
+ ### Resource
83
+
84
+ ```ts
85
+ import { resource, z } from '@cyanheads/mcp-ts-core';
86
+ import { notFound } from '@cyanheads/mcp-ts-core/errors';
87
+
88
+ export const itemData = resource('inventory://{itemId}', {
89
+ description: 'Fetch an inventory item by ID.',
90
+ params: z.object({ itemId: z.string().describe('Item identifier') }),
91
+ auth: ['inventory:read'],
92
+ async handler(params, ctx) {
93
+ const item = await ctx.state.get(`item:${params.itemId}`);
94
+ if (!item) throw notFound(`Item ${params.itemId} not found`, { itemId: params.itemId });
95
+ return item;
96
+ },
97
+ });
98
+ ```
99
+
100
+ ### Prompt
101
+
102
+ ```ts
103
+ import { prompt, z } from '@cyanheads/mcp-ts-core';
104
+
105
+ export const reviewCode = prompt('review_code', {
106
+ description: 'Review code for issues and best practices.',
107
+ args: z.object({
108
+ code: z.string().describe('Code to review'),
109
+ language: z.string().optional().describe('Programming language'),
110
+ }),
111
+ generate: (args) => [
112
+ { role: 'user', content: { type: 'text', text: `Review this ${args.language ?? ''} code:\n${args.code}` } },
113
+ ],
114
+ });
115
+ ```
116
+
117
+ ### Server config
118
+
119
+ ```ts
120
+ // src/config/server-config.ts — lazy-parsed, separate from framework config
121
+ import { z } from '@cyanheads/mcp-ts-core';
122
+ import { parseEnvConfig } from '@cyanheads/mcp-ts-core/config';
123
+
124
+ const ServerConfigSchema = z.object({
125
+ apiKey: z.string().describe('External API key'),
126
+ maxResults: z.coerce.number().default(100),
127
+ });
128
+
129
+ let _config: z.infer<typeof ServerConfigSchema> | undefined;
130
+ export function getServerConfig() {
131
+ _config ??= parseEnvConfig(ServerConfigSchema, {
132
+ apiKey: 'MY_API_KEY',
133
+ maxResults: 'MY_MAX_RESULTS',
134
+ });
135
+ return _config;
136
+ }
137
+ ```
138
+
139
+ `parseEnvConfig` maps Zod schema paths → env var names so errors name the variable (`MY_API_KEY`) not the path (`apiKey`). Throws `ConfigurationError`, which the framework prints as a clean startup banner.
140
+
141
+ ---
142
+
143
+ ## Context
144
+
145
+ Handlers receive a unified `ctx` object. Key properties:
146
+
147
+ | Property | Description |
148
+ |:---------|:------------|
149
+ | `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. |
150
+ | `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
151
+ | `ctx.elicit` | Ask user for structured input. **Check for presence first:** `if (ctx.elicit) { ... }` |
152
+ | `ctx.sample` | Request LLM completion from the client. **Check for presence first:** `if (ctx.sample) { ... }` |
153
+ | `ctx.signal` | `AbortSignal` for cancellation. |
154
+ | `ctx.progress` | Task progress (present when `task: true`) — `.setTotal(n)`, `.increment()`, `.update(message)`. |
155
+ | `ctx.requestId` | Unique request ID. |
156
+ | `ctx.tenantId` | Tenant ID from JWT or `'default'` for stdio. |
157
+
158
+ ---
159
+
160
+ ## Errors
161
+
162
+ Handlers throw — the framework catches, classifies, and formats.
163
+
164
+ **Recommended: typed error contract.** Declare `errors: [{ reason, code, when, recovery, retryable? }]` on `tool()` / `resource()` to receive `ctx.fail(reason, …)` typed against the reason union. TypeScript catches typos at compile time, `data.reason` is auto-populated for observability, linter enforces conformance against the handler body. `recovery` is required descriptive metadata for the agent's next move (≥ 5 words, lint-validated); for the wire `data.recovery.hint` (mirrored into `content[]` text), pass explicitly at the throw site when dynamic context matters: `ctx.fail('reason', msg, { recovery: { hint: '...' } })`. Baseline codes (`InternalError`, `ServiceUnavailable`, `Timeout`, `ValidationError`, `SerializationError`) bubble freely and don't need declaring.
165
+
166
+ ```ts
167
+ errors: [
168
+ { reason: 'no_match', code: JsonRpcErrorCode.NotFound,
169
+ when: 'No item matched the query',
170
+ recovery: 'Broaden the query or check the spelling and try again.' },
171
+ ],
172
+ async handler(input, ctx) {
173
+ const item = await db.find(input.id);
174
+ if (!item) throw ctx.fail('no_match', `No item ${input.id}`);
175
+ return item;
176
+ }
177
+ ```
178
+
179
+ **Declare contracts inline on each tool.** The contract is part of the tool's public surface — one file should give the full picture. Don't extract a shared `errors[]` constant; per-tool repetition is the intended cost of locality.
180
+
181
+ **Fallback (no contract entry fits):** throw via factories or plain `Error`.
182
+
183
+ ```ts
184
+ // Error factories — explicit code
185
+ import { notFound, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
186
+ throw notFound('Item not found', { itemId });
187
+ throw serviceUnavailable('API unavailable', { url }, { cause: err });
188
+
189
+ // Plain Error — framework auto-classifies from message patterns
190
+ throw new Error('Item not found'); // → NotFound
191
+ throw new Error('Invalid query format'); // → ValidationError
192
+
193
+ // McpError — when no factory exists for the code
194
+ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
195
+ throw new McpError(JsonRpcErrorCode.DatabaseError, 'Connection failed', { pool: 'primary' });
196
+ ```
197
+
198
+ See framework CLAUDE.md and the `api-errors` skill for the full auto-classification table, all available factories, and the contract reference.
199
+
200
+ ---
201
+
202
+ ## Structure
203
+
204
+ ```text
205
+ src/
206
+ index.ts # createApp() entry point
207
+ config/
208
+ server-config.ts # Server-specific env vars (Zod schema)
209
+ services/
210
+ [domain]/
211
+ [domain]-service.ts # Domain service (init/accessor pattern)
212
+ types.ts # Domain types
213
+ mcp-server/
214
+ tools/definitions/
215
+ [tool-name].tool.ts # Tool definitions
216
+ resources/definitions/
217
+ [resource-name].resource.ts # Resource definitions
218
+ prompts/definitions/
219
+ [prompt-name].prompt.ts # Prompt definitions
220
+ ```
221
+
222
+ ---
223
+
224
+ ## Naming
225
+
226
+ | What | Convention | Example |
227
+ |:-----|:-----------|:--------|
228
+ | Files | kebab-case with suffix | `search-docs.tool.ts` |
229
+ | Tool/resource/prompt names | snake_case | `search_docs` |
230
+ | Directories | kebab-case | `src/services/doc-search/` |
231
+ | Descriptions | Single string or template literal, no `+` concatenation | `'Search items by query and filter.'` |
232
+
233
+ ---
234
+
235
+ ## Skills
236
+
237
+ Skills are modular instructions in `skills/` at the project root. Read them directly when a task matches — e.g., `skills/add-tool/SKILL.md` when adding a tool.
238
+
239
+ **Agent skill directory:** Copy skills into the directory your agent discovers (Claude Code: `.claude/skills/`, others: equivalent). Skills then load as context without referencing `skills/` paths. After framework updates, run the `maintenance` skill — Phase B re-syncs the agent directory.
240
+
241
+ Available skills:
242
+
243
+ | Skill | Purpose |
244
+ |:------|:--------|
245
+ | `setup` | Post-init project orientation |
246
+ | `design-mcp-server` | Design tool surface, resources, and services for a new server |
247
+ | `add-tool` | Scaffold a new tool definition |
248
+ | `add-app-tool` | Scaffold an MCP App tool + paired UI resource |
249
+ | `add-resource` | Scaffold a new resource definition |
250
+ | `add-prompt` | Scaffold a new prompt definition |
251
+ | `add-service` | Scaffold a new service integration |
252
+ | `add-test` | Scaffold test file for a tool, resource, or service |
253
+ | `field-test` | Exercise tools/resources/prompts with real inputs, verify behavior, report issues |
254
+ | `security-pass` | Audit server for MCP-flavored security gaps: output injection, scope blast radius, input sinks, tenant isolation |
255
+ | `devcheck` | Lint, format, typecheck, audit |
256
+ | `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
257
+ | `maintenance` | Investigate changelogs, adopt upstream changes, sync skills to agent dirs |
258
+ | `report-issue-framework` | File a bug or feature request against `@cyanheads/mcp-ts-core` via `gh` CLI |
259
+ | `report-issue-local` | File a bug or feature request against this server's own repo via `gh` CLI |
260
+ | `api-auth` | Auth modes, scopes, JWT/OAuth |
261
+ | `api-canvas` | DataCanvas: register tabular data, run SQL, export, plus the `spillover()` helper for big result sets — Tier 3 opt-in |
262
+ | `api-config` | AppConfig, parseConfig, env vars |
263
+ | `api-context` | Context interface, logger, state, progress |
264
+ | `api-errors` | McpError, JsonRpcErrorCode, error patterns |
265
+ | `api-services` | LLM, Speech, Graph services |
266
+ | `api-testing` | createMockContext, test patterns |
267
+ | `api-utils` | Formatting, parsing, security, pagination, scheduling, telemetry helpers |
268
+ | `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
269
+ | `api-workers` | Cloudflare Workers runtime |
270
+
271
+ When you complete a skill's checklist, check the boxes and add a completion timestamp at the end (e.g., `Completed: 2026-03-11`).
272
+
273
+ ---
274
+
275
+ ## Commands
276
+
277
+ **Runtime:** Scripts use `tsx` — both `npm run <cmd>` and `bun run <cmd>` work. `bun` is slightly faster for script invocation but not required.
278
+
279
+ | Command | Purpose |
280
+ |:--------|:--------|
281
+ | `npm run build` | Compile TypeScript |
282
+ | `npm run rebuild` | Clean + build |
283
+ | `npm run clean` | Remove build artifacts |
284
+ | `npm run devcheck` | Lint + format + typecheck + security + changelog sync |
285
+ | `bun run audit:refresh` | Delete `bun.lock`, reinstall, re-audit. Use when `devcheck` flags a transitive advisory — stale lockfile can mask already-patched deps. If advisory survives, it's real. |
286
+ | `npm run tree` | Generate directory structure doc |
287
+ | `npm run format` | Auto-fix formatting |
288
+ | `npm test` | Run tests |
289
+ | `npm run start:stdio` | Production mode (stdio) |
290
+ | `npm run start:http` | Production mode (HTTP) |
291
+ | `npm run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
292
+ | `npm run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
293
+ | `npm run bundle` | Build and pack as `.mcpb` for one-click Claude Desktop install |
294
+
295
+ ---
296
+
297
+ ## Bundling
298
+
299
+ `npm run bundle` produces a `.mcpb` extension bundle for one-click install in Claude Desktop. MCPB is stdio-only — HTTP and Cloudflare Workers deployments are unaffected. Consumers who don't need it can delete `manifest.json` and `.mcpbignore`; `lint:packaging` skips cleanly.
300
+
301
+ **Adding an env var requires both files:** `server.json` (registry discovery, `environmentVariables[]`) and `manifest.json` (bundle install UX, `mcp_config.env` + `user_config`). `lint:packaging` (run by `devcheck`) verifies the env var names match.
302
+
303
+ **README install badges.** Drop these into the project README to give users one-click install paths. Fill in `<OWNER>` / `<REPO>` / `<PACKAGE_NAME>` and encode the per-server config. Cursor + VS Code badges assume the server is published to npm; Claude Desktop downloads the `.mcpb` directly so npm publishing isn't required.
304
+
305
+ | Client | Mechanism |
306
+ |:-------|:----------|
307
+ | Claude Desktop | Browser downloads the `.mcpb` from the latest GitHub Release; OS file handler routes it to Claude Desktop, which opens the install dialog. No deep-link URL scheme yet — this is the canonical path. |
308
+ | Cursor | Official `https://cursor.com/en/install-mcp` endpoint with base64 JSON config. |
309
+ | VS Code / Insiders | Official `vscode:mcp/install?...` deep link, wrapped in `https://vscode.dev/redirect?url=` so GitHub-rendered markdown doesn't strip the non-HTTP scheme. |
310
+ | Claude Code / Codex | CLI only (`claude mcp add` / `codex mcp add`); no URL scheme. |
311
+
312
+ ```markdown
313
+ [![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/<OWNER>/<REPO>/releases/latest/download/<PACKAGE_NAME>.mcpb)
314
+ [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=<PACKAGE_NAME>&config=<BASE64_CONFIG>)
315
+ [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?<URLENCODED_JSON>)
316
+ ```
317
+
318
+ Both install links route through HTTPS endpoints (`cursor.com/en/install-mcp` and `vscode.dev/redirect`) — GitHub-rendered markdown strips non-HTTP URL schemes from anchors, so a raw `cursor://` or `vscode:` link won't click through from github.com.
319
+
320
+ Generate the encoded configs (replace `<PACKAGE_NAME>` and add env vars for any required API keys):
321
+
322
+ ```bash
323
+ # Cursor: base64-encoded JSON. Split command/args, add env when keys are needed.
324
+ echo -n '{"command":"npx","args":["-y","<PACKAGE_NAME>"],"env":{"API_KEY":"your-api-key"}}' | base64
325
+ # Without env (no required keys):
326
+ echo -n '{"command":"npx","args":["-y","<PACKAGE_NAME>"]}' | base64
327
+
328
+ # VS Code: URL-encoded JSON. Same shape plus a `name` field.
329
+ node -p 'encodeURIComponent(JSON.stringify({name:"<SHORT_NAME>",command:"npx",args:["-y","<PACKAGE_NAME>"],env:{API_KEY:"your-api-key"}}))'
330
+ # Without env:
331
+ node -p 'encodeURIComponent(JSON.stringify({name:"<SHORT_NAME>",command:"npx",args:["-y","<PACKAGE_NAME>"]}))'
332
+ ```
333
+
334
+ Both clients use the same `{command, args, env}` shape (matching `mcp.json` schema). VS Code adds a top-level `name` field. Omit `env` entirely when no API keys are needed — don't include empty objects or framework-only vars like `MCP_TRANSPORT_TYPE`.
335
+
336
+ The Claude Desktop badge requires the bundle to ship with a stable filename — `bun run bundle` outputs `dist/<PACKAGE_NAME>.mcpb`, and `release-and-publish` attaches that file to the GitHub Release. `releases/latest/download/<PACKAGE_NAME>.mcpb` then redirects to the most recent release.
337
+
338
+ ---
339
+
340
+ ## Changelog
341
+
342
+ Directory-based, grouped by minor series via the `.x` semver-wildcard convention. Source of truth: `changelog/<major.minor>.x/<version>.md` (e.g. `changelog/0.1.x/0.1.0.md`) — one file per release, shipped in the npm package. At release, author the per-version file with a concrete version and date, then run `npm run changelog:build` to regenerate the rollup. `changelog/template.md` is a **pristine format reference** — never edited or moved; read it for the frontmatter + section layout when scaffolding. `CHANGELOG.md` is a **navigation index** (header + link + summary per version), regenerated by `npm run changelog:build` — devcheck hard-fails on drift; never hand-edit it.
343
+
344
+ Each per-version file opens with YAML frontmatter:
345
+
346
+ ```markdown
347
+ ---
348
+ summary: "One-line headline, ≤350 chars" # required — powers the rollup index
349
+ breaking: false # optional — true flags breaking changes
350
+ security: false # optional — true flags security fixes
351
+ ---
352
+
353
+ # 0.1.0 — YYYY-MM-DD
354
+ ...
355
+ ```
356
+
357
+ `breaking: true` renders a `· ⚠️ Breaking` badge — use it when consumers must update code on upgrade (signature changes, removed APIs, config renames). `security: true` renders a `· 🛡️ Security` badge and pairs with a `## Security` body section. When both are set, badges render `· ⚠️ Breaking · 🛡️ Security`.
358
+
359
+ **Section order** (Keep a Changelog): Added, Changed, Deprecated, Removed, Fixed, Security. Include only sections with entries — don't ship empty headers.
360
+
361
+ **Tag annotations** render as GitHub Release bodies via `--notes-from-tag`. They must be structured markdown — never a flat comma-separated string. Subject omits the version number (GitHub prepends it). See `changelog/template.md` for the full format reference.
362
+
363
+ ---
364
+
365
+ ## Imports
366
+
367
+ ```ts
368
+ // Framework — z is re-exported, no separate zod import needed
369
+ import { tool, z } from '@cyanheads/mcp-ts-core';
370
+ import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
371
+
372
+ // Server's own code — via path alias
373
+ import { getMyService } from '@/services/my-domain/my-service.js';
374
+ ```
375
+
376
+ ---
377
+
378
+ ## Checklist
379
+
380
+ - [ ] Zod schemas: all fields have `.describe()`, only JSON-Schema-serializable types (no `z.custom()`, `z.date()`, `z.transform()`, `z.bigint()`, `z.symbol()`, `z.void()`, `z.map()`, `z.set()`, `z.function()`, `z.nan()`)
381
+ - [ ] Optional nested objects: handler guards for empty inner values from form-based clients (`if (input.obj?.field && ...)`, not just `if (input.obj)`). When regex/length constraints matter, use `z.union([z.literal(''), z.string().regex(...).describe(...)])` — literal variants are exempt from `describe-on-fields`.
382
+ - [ ] JSDoc `@fileoverview` + `@module` on every file
383
+ - [ ] `ctx.log` for logging, `ctx.state` for storage
384
+ - [ ] Handlers throw on failure — error factories or plain `Error`, no try/catch
385
+ - [ ] `format()` renders all data the LLM needs — different clients forward different surfaces (Claude Code → `structuredContent`, Claude Desktop → `content[]`); both must carry the same data
386
+ - [ ] If wrapping external API: raw/domain/output schemas reviewed against real upstream sparsity/nullability before finalizing required vs optional fields
387
+ - [ ] If wrapping external API: normalization and `format()` preserve uncertainty; do not fabricate facts from missing upstream data
388
+ - [ ] If wrapping external API: tests include at least one sparse payload case with omitted upstream fields
389
+ - [ ] Registered in `createApp()` arrays (directly or via barrel exports)
390
+ - [ ] Tests use `createMockContext()` from `@cyanheads/mcp-ts-core/testing`
391
+ - [ ] `npm run devcheck` passes
package/Dockerfile ADDED
@@ -0,0 +1,98 @@
1
+ # ==============================================================================
2
+ # Build Stage
3
+ #
4
+ # This stage installs all dependencies (including dev), builds the TypeScript
5
+ # source code into JavaScript, and prepares the production assets.
6
+ # ==============================================================================
7
+ FROM oven/bun:1.3 AS build
8
+
9
+ WORKDIR /usr/src/app
10
+
11
+ # Copy dependency manifests for optimized layer caching
12
+ COPY package.json bun.lock ./
13
+
14
+ # Install all dependencies (including dev dependencies for building)
15
+ RUN bun install --frozen-lockfile
16
+
17
+ # Copy the rest of the source code
18
+ COPY . .
19
+
20
+ # Build the application
21
+ RUN bun run build
22
+
23
+
24
+ # ==============================================================================
25
+ # Production Stage
26
+ #
27
+ # This stage creates a minimal, optimized, and secure image for running the
28
+ # application. It uses a slim base image and only includes production
29
+ # dependencies and build artifacts.
30
+ # ==============================================================================
31
+ FROM oven/bun:1.3-slim AS production
32
+
33
+ WORKDIR /usr/src/app
34
+
35
+ # Set the environment to production for performance and to ensure only
36
+ # production dependencies are installed.
37
+ ENV NODE_ENV=production
38
+
39
+ # OCI image metadata (https://github.com/opencontainers/image-spec/blob/main/annotations.md)
40
+ LABEL org.opencontainers.image.title="reliefweb-mcp-server"
41
+ LABEL org.opencontainers.image.description=""
42
+ LABEL org.opencontainers.image.licenses="Apache-2.0"
43
+
44
+ # Copy dependency manifests
45
+ COPY package.json bun.lock ./
46
+
47
+ # Install only production dependencies, ignoring any lifecycle scripts (like 'prepare')
48
+ # that are not needed in the final production image.
49
+ RUN bun install --production --frozen-lockfile --ignore-scripts
50
+
51
+ # Conditionally install OpenTelemetry optional peer dependencies (Tier 3).
52
+ # These are not bundled by default to keep the base image lean. Enable at build time
53
+ # with: docker build --build-arg OTEL_ENABLED=true
54
+ ARG OTEL_ENABLED=true
55
+ RUN if [ "$OTEL_ENABLED" = "true" ]; then \
56
+ bun add @hono/otel \
57
+ @opentelemetry/instrumentation-http \
58
+ @opentelemetry/exporter-metrics-otlp-http \
59
+ @opentelemetry/exporter-trace-otlp-http \
60
+ @opentelemetry/instrumentation-pino \
61
+ @opentelemetry/resources \
62
+ @opentelemetry/sdk-metrics \
63
+ @opentelemetry/sdk-node \
64
+ @opentelemetry/sdk-trace-node \
65
+ @opentelemetry/semantic-conventions; \
66
+ fi
67
+
68
+ # Copy the compiled application code from the build stage
69
+ COPY --from=build /usr/src/app/dist ./dist
70
+
71
+ # The 'oven/bun' image already provides a non-root user named 'bun'.
72
+ # We will use this existing user for enhanced security.
73
+
74
+ # Create and set permissions for the log directory, assigning ownership to the 'bun' user.
75
+ RUN mkdir -p /var/log/reliefweb-mcp-server && chown -R bun:bun /var/log/reliefweb-mcp-server
76
+
77
+ # Switch to the non-root user
78
+ USER bun
79
+
80
+ # Define an argument for the port, allowing it to be overridden at build time.
81
+ # The `PORT` variable is often injected by cloud environments at runtime.
82
+ ARG PORT
83
+
84
+ # Set runtime environment variables
85
+ # Note: PORT is an automatic variable in many cloud environments (e.g., Cloud Run)
86
+ ENV MCP_HTTP_PORT=${PORT:-3010}
87
+ ENV MCP_HTTP_HOST="0.0.0.0"
88
+ ENV MCP_TRANSPORT_TYPE="http"
89
+ ENV MCP_SESSION_MODE="stateless"
90
+ ENV MCP_LOG_LEVEL="info"
91
+ ENV LOGS_DIR="/var/log/reliefweb-mcp-server"
92
+ ENV MCP_FORCE_CONSOLE_LOGGING="true"
93
+
94
+ # Expose the port the server listens on
95
+ EXPOSE ${MCP_HTTP_PORT}
96
+
97
+ # The command to start the server
98
+ CMD ["bun", "run", "dist/index.js"]