ficaviolaodorata520/met-museum-mcp-server/add-service
Claude Code and agent skill by ficaviolaodorata520/met-museum-mcp-server
- community
Checking that the SKILL.md file is still in the repository.
Scaffold a new service integration. Use when the user asks to add a service, integrate an external API, or create a reusable domain module with its own initialization and state.
Install
npx vskill@latest install ficaviolaodorata520/met-museum-mcp-server/add-serviceSKILL.md
The same SKILL.md was published earlier as ficaviolaodorata520/met-museum-mcp-server/add-service.
Context
Services use the init/accessor pattern: initialized once in createApp's setup() callback, then accessed at request time via a lazy getter. Each service lives in src/services/[domain]/ with an init function and accessor.
Service methods receive Context for correlated logging (ctx.log) and tenant-scoped storage (ctx.state). Convention: ctx.elicit and ctx.sample should only be called from tool handlers, not from services.
For the full service pattern, CoreServices, and Context interface, read the framework's CLAUDE.md/AGENTS.md (loaded at session start).
Steps
- Gather the service domain name and what it integrates with from the user's request — ask only if genuinely absent
- Create the directory at
src/services/{{domain}}/ - Create the service file at
src/services/{{domain}}/{{domain}}-service.ts - Create types at
src/services/{{domain}}/types.tsif needed - Register in `setup()` in the server's entry point (
src/index.ts, orsrc/worker.tsfor Worker-only servers) - Run `bun run devcheck` to verify
Template
Service file
Entry point registration
Add the setup() callback and import to the existing createApp() call — preserve the existing tool/resource/prompt arrays:
Usage in tool handlers
Resilience (External API Services)
When a service wraps an external API, apply these patterns. For the framework retry contract, see skills/api-utils/SKILL.md.
Retry wraps the full pipeline
Place retry at the service method level — covering both HTTP fetch and response parsing/validation. The HTTP client should be single-attempt; the service owns retry. Use withRetry from @cyanheads/mcp-ts-core/utils:
Key principles
- Calibrate backoff to the upstream. 200–500ms for ephemeral failures, 1–2s for rate-limited APIs, 2–5s for service degradation. The default
baseDelayMs: 1000suits most APIs. - Check HTTP status before parsing.
fetchWithTimeoutalready throws on non-OK responses with granular status mapping (401→Unauthorized, 403→Forbidden, 404→NotFound, 408/425→Timeout, 422→ValidationError, 429→RateLimited, 5xx→ServiceUnavailable/InternalError) — this prevents feeding HTML error pages into XML/JSON parsers. - Classify parse failures by content. If the upstream returns HTTP 200 with an HTML error page, detect it and throw
ServiceUnavailable(transient) instead ofSerializationError(non-transient). Exception — deterministic HTTP 200 errors fail fast, not transient. Some upstreams return HTTP 200 with a structured error body for failures that will never succeed regardless of how many times you retry: a query too expensive for the server's budget, an oversized result set, or a malformed request the server rejects. Retrying these wastes upstream capacity and delays the client. Declare them in the contract withretryable: false(or pass{ retryable: false }indataat the throw site) —withRetry's default predicate readserror.data.retryable === falseand fails immediately, even forTimeout/ServiceUnavailablecodes.ctx.failauto-populatesdata.retryablefrom the contract entry, so declaring it once inerrors[]is enough. - Exhausted retries say so.
withRetryautomatically enriches the final error with attempt count — callers know retries were already attempted.
When you need finer-grained HTTP error classification
fetchWithTimeout already maps status codes to appropriate error codes (see key principle 2 above). Use httpErrorFromResponse instead when you need Retry-After header capture, request body passthrough in error data, or custom service/data fields on the thrown error:
httpErrorFromResponse maps the full status table (401/403/408/422/429/5xx) to the appropriate JsonRpcErrorCode, captures the response body (truncated), and forwards Retry-After headers into error.data.retryAfter. The codes it produces line up with withRetry's transient-code set, so retryable HTTP failures (429, 503, 504) are retried automatically and non-retryable ones (401, 404, 422) fail immediately.
Response handler pattern
Sparse upstream payloads
Third-party APIs often omit fields entirely instead of returning null. If your raw response types, normalized domain types, or tool output schemas are stricter than the real upstream payloads, you'll either fail validation or silently invent facts.
Guidance:
- Raw upstream types default to optional unless presence is guaranteed. Trust the docs only after you've verified real payloads.
- Preserve absence when it means "unknown". Missing data is different from
false,0,'', or an empty array. - Don't fabricate defaults during normalization unless the upstream contract or your own tool semantics explicitly define them.
- With `exactOptionalPropertyTypes`, omit absent fields instead of returning `undefined`. Conditional spreads keep the normalized object honest.
Error Handling in Services
Services don't declare errors: [...] contracts and don't have ctx.fail — that contract surface is tool/resource-only. Inside services:
- Throw via factories when a specific code matters:
throw notFound(...),throw rateLimited(...),throw serviceUnavailable(...). The framework's auto-classifier catches anything else. - Wrap risky pipelines in `ErrorHandler.tryCatch` when you want structured logging + auto-classification without writing try/catch boilerplate. It always rethrows — never swallows. Useful for parsing untrusted input (JSON, config) or third-party SDK calls whose error types you don't control:
```ts import { ErrorHandler } from '@cyanheads/mcp-ts-core/utils';
const parsed = await ErrorHandler.tryCatch( () => JSON.parse(rawConfig), { operation: 'MyService.parseConfig', errorCode: JsonRpcErrorCode.ConfigurationError }, ); ```
- Tool/resource handlers bubble service errors unchanged — the contract advertises the advertised failure surface, and any code thrown from a service still reaches the client correctly via the auto-classifier. The conformance lint scans handler source text only, so service-thrown codes aren't flagged.
- Carry contract `reason` via `data: { reason }` when the calling tool declares an
errors[]contract entry for this failure mode. Services can't callctx.fail, but passing the reason indataflows through the auto-classifier untouched, so clients see the sameerror.data.reasonthey'd see fromctx.fail— no handler-side catch-and-rethrow needed:
``ts // tool declares: errors: [{ reason: 'empty_expression', code: JsonRpcErrorCode.ValidationError, when: '…', recovery: '…' }] throw validationError('Expression cannot be empty.', { reason: 'empty_expression' }); ``
- Resolve contract `recovery` via `ctx.recoveryFor` to land the contract's recovery hint on the wire without duplicating the string. Always-present on
Context, returns{}when the calling tool has no matching reason — spread-safe regardless:
``ts throw validationError('Parse failed: ' + err.message, { reason: 'parse_failed', ...ctx.recoveryFor('parse_failed'), // resolves from caller's contract }); ``
The contract recovery (validated ≥5 words at lint time) is the single source of truth. Services that opt in via the resolver carry the same hint to the wire that handler-level ctx.fail callers do — no drift, no auto-population. For dynamic recovery (interpolating runtime values into the hint), pass an explicit { recovery: { hint: '…' } } instead.
API Efficiency
When a service wraps an external API, design methods to minimize upstream calls. These patterns compound — a tool calling 3 service methods that each make N requests is 3N calls; batching drops it to 3.
Batch over N+1
If the API supports filter-by-IDs, bulk GET, or batch query endpoints, expose a batch method instead of (or alongside) the single-item method. One request for 20 items beats 20 sequential requests — it eliminates serial latency, avoids rate-limit accumulation, and simplifies error handling.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 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 repositoryCheckingskills/add-service/SKILL.md
Popularity
- 7-day trend score
- 0
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/ficaviolaodorata520/met-museum-mcp-server/add-service)