@cyanheads/bluesky-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.
- package/AGENTS.md +346 -0
- package/CLAUDE.md +346 -0
- package/Dockerfile +99 -0
- package/LICENSE +201 -0
- package/README.md +307 -0
- package/changelog/0.1.x/0.1.1.md +24 -0
- package/changelog/template.md +127 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +43 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-server/resources/definitions/bsky-profile.resource.d.ts +15 -0
- package/dist/mcp-server/resources/definitions/bsky-profile.resource.d.ts.map +1 -0
- package/dist/mcp-server/resources/definitions/bsky-profile.resource.js +54 -0
- package/dist/mcp-server/resources/definitions/bsky-profile.resource.js.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-get-author-feed.tool.d.ts +49 -0
- package/dist/mcp-server/tools/definitions/bsky-get-author-feed.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-get-author-feed.tool.js +217 -0
- package/dist/mcp-server/tools/definitions/bsky-get-author-feed.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-get-follows.tool.d.ts +43 -0
- package/dist/mcp-server/tools/definitions/bsky-get-follows.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-get-follows.tool.js +165 -0
- package/dist/mcp-server/tools/definitions/bsky-get-follows.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-get-post-thread.tool.d.ts +24 -0
- package/dist/mcp-server/tools/definitions/bsky-get-post-thread.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-get-post-thread.tool.js +166 -0
- package/dist/mcp-server/tools/definitions/bsky-get-post-thread.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-get-profile.tool.d.ts +32 -0
- package/dist/mcp-server/tools/definitions/bsky-get-profile.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-get-profile.tool.js +117 -0
- package/dist/mcp-server/tools/definitions/bsky-get-profile.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-get-trending.tool.d.ts +21 -0
- package/dist/mcp-server/tools/definitions/bsky-get-trending.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-get-trending.tool.js +81 -0
- package/dist/mcp-server/tools/definitions/bsky-get-trending.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-search-actors.tool.d.ts +27 -0
- package/dist/mcp-server/tools/definitions/bsky-search-actors.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-search-actors.tool.js +100 -0
- package/dist/mcp-server/tools/definitions/bsky-search-actors.tool.js.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-search-posts.tool.d.ts +47 -0
- package/dist/mcp-server/tools/definitions/bsky-search-posts.tool.d.ts.map +1 -0
- package/dist/mcp-server/tools/definitions/bsky-search-posts.tool.js +233 -0
- package/dist/mcp-server/tools/definitions/bsky-search-posts.tool.js.map +1 -0
- package/dist/services/bluesky/bluesky-service.d.ts +68 -0
- package/dist/services/bluesky/bluesky-service.d.ts.map +1 -0
- package/dist/services/bluesky/bluesky-service.js +287 -0
- package/dist/services/bluesky/bluesky-service.js.map +1 -0
- package/dist/services/bluesky/types.d.ts +126 -0
- package/dist/services/bluesky/types.d.ts.map +1 -0
- package/dist/services/bluesky/types.js +6 -0
- package/dist/services/bluesky/types.js.map +1 -0
- package/package.json +102 -0
- package/server.json +99 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
# Developer Protocol
|
|
2
|
+
|
|
3
|
+
**Server:** bluesky-mcp-server
|
|
4
|
+
**Version:** 0.1.1
|
|
5
|
+
**Framework:** [@cyanheads/mcp-ts-core](https://www.npmjs.com/package/@cyanheads/mcp-ts-core) `^0.9.21`
|
|
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
|
+
- **Close the loop on issues.** When implementing work tracked by a GitHub issue, comment on the issue with what landed and close it. Do both — a comment without a close leaves stale issues open; a close without a comment leaves no record of what shipped. The comment is for future readers — state the concrete changes, not the conversation that produced them.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Patterns
|
|
45
|
+
|
|
46
|
+
### Tool
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
50
|
+
import { getBlueskyService } from '@/services/bluesky/bluesky-service.js';
|
|
51
|
+
|
|
52
|
+
export const bskySearchActors = tool('bsky_search_actors', {
|
|
53
|
+
description: 'Find Bluesky accounts by name or handle fragment.',
|
|
54
|
+
annotations: { readOnlyHint: true },
|
|
55
|
+
input: z.object({
|
|
56
|
+
query: z.string().describe('Name or handle fragment to search for.'),
|
|
57
|
+
limit: z.number().int().min(1).max(100).default(25).describe('Max results (1–100).'),
|
|
58
|
+
}),
|
|
59
|
+
output: z.object({
|
|
60
|
+
actors: z.array(z.object({
|
|
61
|
+
did: z.string().describe('Permanent DID of the actor.'),
|
|
62
|
+
handle: z.string().describe('Human-readable handle, e.g. "alice.bsky.social".'),
|
|
63
|
+
displayName: z.string().optional().describe('Display name set by the actor.'),
|
|
64
|
+
})).describe('Matching actor profiles.'),
|
|
65
|
+
}),
|
|
66
|
+
|
|
67
|
+
async handler(input, ctx) {
|
|
68
|
+
const result = await getBlueskyService().searchActors(input.query, input.limit, ctx);
|
|
69
|
+
ctx.log.info('Actor search completed', { query: input.query, count: result.actors.length });
|
|
70
|
+
return result;
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
format: (result) => [{
|
|
74
|
+
type: 'text',
|
|
75
|
+
text: result.actors.map(a => `**${a.handle}** (${a.did})${a.displayName ? ` — ${a.displayName}` : ''}`).join('\n'),
|
|
76
|
+
}],
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Resource
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { resource, z } from '@cyanheads/mcp-ts-core';
|
|
84
|
+
import { JsonRpcErrorCode, McpError } from '@cyanheads/mcp-ts-core/errors';
|
|
85
|
+
import { getBlueskyService } from '@/services/bluesky/bluesky-service.js';
|
|
86
|
+
|
|
87
|
+
export const bskyProfileResource = resource('bsky://profile/{actor}', {
|
|
88
|
+
name: 'bsky-profile',
|
|
89
|
+
description: "A Bluesky actor's public profile, addressable by handle or DID.",
|
|
90
|
+
params: z.object({
|
|
91
|
+
actor: z.string().describe('Handle (e.g. "alice.bsky.social") or DID of the actor.'),
|
|
92
|
+
}),
|
|
93
|
+
errors: [
|
|
94
|
+
{
|
|
95
|
+
reason: 'actor_not_found',
|
|
96
|
+
code: JsonRpcErrorCode.NotFound,
|
|
97
|
+
when: 'The handle does not resolve or the profile does not exist.',
|
|
98
|
+
recovery: 'Verify the handle spelling or use bsky_search_actors to find the correct handle.',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
async handler(params, ctx) {
|
|
102
|
+
return await getBlueskyService().getProfile(params.actor, ctx);
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Server instructions
|
|
108
|
+
|
|
109
|
+
`createApp({ instructions })` — optional server-level orientation, sent to clients on every `initialize` as session-level context. Use it for deployment guidance (connection aliases, regional notes, scope hints) instead of repeating the same context across tool descriptions. Client adoption is uneven, but there's no downside when set.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Context
|
|
114
|
+
|
|
115
|
+
Handlers receive a unified `ctx` object. Key properties:
|
|
116
|
+
|
|
117
|
+
| Property | Description |
|
|
118
|
+
|:---------|:------------|
|
|
119
|
+
| `ctx.log` | Request-scoped logger — `.debug()`, `.info()`, `.notice()`, `.warning()`, `.error()`. Auto-correlates requestId, traceId, tenantId. |
|
|
120
|
+
| `ctx.state` | Tenant-scoped KV — `.get(key)`, `.set(key, value, { ttl? })`, `.delete(key)`, `.list(prefix, { cursor, limit })`. Accepts any serializable value. |
|
|
121
|
+
| `ctx.elicit` | Ask user for structured input. **Check for presence first:** `if (ctx.elicit) { ... }` |
|
|
122
|
+
| `ctx.sample` | Request LLM completion from the client. **Check for presence first:** `if (ctx.sample) { ... }` |
|
|
123
|
+
| `ctx.signal` | `AbortSignal` for cancellation. |
|
|
124
|
+
| `ctx.progress` | Task progress (present when `task: true`) — `.setTotal(n)`, `.increment()`, `.update(message)`. |
|
|
125
|
+
| `ctx.requestId` | Unique request ID. |
|
|
126
|
+
| `ctx.tenantId` | Tenant ID from JWT or `'default'` for stdio. |
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Errors
|
|
131
|
+
|
|
132
|
+
Handlers throw — the framework catches, classifies, and formats.
|
|
133
|
+
|
|
134
|
+
**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.
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
import { JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
138
|
+
|
|
139
|
+
errors: [
|
|
140
|
+
{ reason: 'no_match', code: JsonRpcErrorCode.NotFound,
|
|
141
|
+
when: 'No item matched the query',
|
|
142
|
+
recovery: 'Broaden the query or check the spelling and try again.' },
|
|
143
|
+
],
|
|
144
|
+
async handler(input, ctx) {
|
|
145
|
+
const item = await db.find(input.id);
|
|
146
|
+
if (!item) throw ctx.fail('no_match', `No item ${input.id}`);
|
|
147
|
+
return item;
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**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.
|
|
152
|
+
|
|
153
|
+
**Fallback (no contract entry fits):** throw via factories or plain `Error`.
|
|
154
|
+
|
|
155
|
+
```ts
|
|
156
|
+
// Error factories — explicit code
|
|
157
|
+
import { notFound, serviceUnavailable } from '@cyanheads/mcp-ts-core/errors';
|
|
158
|
+
throw notFound('Item not found', { itemId });
|
|
159
|
+
throw serviceUnavailable('API unavailable', { url }, { cause: err });
|
|
160
|
+
|
|
161
|
+
// Plain Error — framework auto-classifies from message patterns
|
|
162
|
+
throw new Error('Item not found'); // → NotFound
|
|
163
|
+
throw new Error('Invalid query format'); // → ValidationError
|
|
164
|
+
|
|
165
|
+
// McpError — when no factory exists for the code
|
|
166
|
+
import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
167
|
+
throw new McpError(JsonRpcErrorCode.DatabaseError, 'Connection failed', { pool: 'primary' });
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
See framework CLAUDE.md and the `api-errors` skill for the full auto-classification table, all available factories, and the contract reference.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Structure
|
|
175
|
+
|
|
176
|
+
```text
|
|
177
|
+
src/
|
|
178
|
+
index.ts # createApp() entry point — registers tools, resource, service
|
|
179
|
+
services/
|
|
180
|
+
bluesky/
|
|
181
|
+
bluesky-service.ts # AT Protocol AppView HTTP client (retry, timeout, User-Agent)
|
|
182
|
+
types.ts # Domain types: Post, Actor, Thread, Trend, Embed
|
|
183
|
+
mcp-server/
|
|
184
|
+
tools/definitions/
|
|
185
|
+
bsky-search-posts.tool.ts # Full-text post search with filters
|
|
186
|
+
bsky-get-profile.tool.ts # Actor profile lookup by handle or DID
|
|
187
|
+
bsky-get-author-feed.tool.ts # User's recent posts (filtered by type)
|
|
188
|
+
bsky-get-post-thread.tool.ts # Full conversation thread by AT-URI
|
|
189
|
+
bsky-search-actors.tool.ts # Actor discovery by name/handle fragment
|
|
190
|
+
bsky-get-follows.tool.ts # Social graph edges (followers/following)
|
|
191
|
+
bsky-get-trending.tool.ts # Real-time trending topics
|
|
192
|
+
resources/definitions/
|
|
193
|
+
bsky-profile.resource.ts # bsky://profile/{actor} — actor profile by handle or DID
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Naming
|
|
199
|
+
|
|
200
|
+
| What | Convention | Example |
|
|
201
|
+
|:-----|:-----------|:--------|
|
|
202
|
+
| Files | kebab-case with suffix | `search-docs.tool.ts` |
|
|
203
|
+
| Tool/resource/prompt names | snake_case | `search_docs` |
|
|
204
|
+
| Directories | kebab-case | `src/services/doc-search/` |
|
|
205
|
+
| Descriptions | Single string or template literal, no `+` concatenation | `'Search items by query and filter.'` |
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Skills
|
|
210
|
+
|
|
211
|
+
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.
|
|
212
|
+
|
|
213
|
+
**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.
|
|
214
|
+
|
|
215
|
+
Available skills:
|
|
216
|
+
|
|
217
|
+
| Skill | Purpose |
|
|
218
|
+
|:------|:--------|
|
|
219
|
+
| `setup` | Post-init project orientation |
|
|
220
|
+
| `design-mcp-server` | Design tool surface, resources, and services for a new server |
|
|
221
|
+
| `add-tool` | Scaffold a new tool definition |
|
|
222
|
+
| `add-app-tool` | Scaffold an MCP App tool + paired UI resource |
|
|
223
|
+
| `add-resource` | Scaffold a new resource definition |
|
|
224
|
+
| `add-prompt` | Scaffold a new prompt definition |
|
|
225
|
+
| `add-service` | Scaffold a new service integration |
|
|
226
|
+
| `add-test` | Scaffold test file for a tool, resource, or service |
|
|
227
|
+
| `field-test` | Exercise tools/resources/prompts with real inputs, verify behavior, report issues |
|
|
228
|
+
| `tool-defs-analysis` | Read-only audit of MCP definition language across the surface — voice, leaks, defaults, recovery hints, output descriptions |
|
|
229
|
+
| `security-pass` | Audit server for MCP-flavored security gaps: output injection, scope blast radius, input sinks, tenant isolation |
|
|
230
|
+
| `code-simplifier` | Post-session cleanup against `git diff` — modernize syntax, consolidate duplication, align with the codebase |
|
|
231
|
+
| `devcheck` | Lint, format, typecheck, audit |
|
|
232
|
+
| `polish-docs-meta` | Finalize docs, README, metadata, and agent protocol for shipping |
|
|
233
|
+
| `git-wrapup` | Land working-tree changes as a versioned commit + annotated tag — version bump, changelog, verify, tag. Local only. |
|
|
234
|
+
| `release-and-publish` | Push + npm + MCP Registry + GH Release + Docker. Picks up from `git-wrapup` |
|
|
235
|
+
| `maintenance` | Investigate changelogs, adopt upstream changes, sync skills to agent dirs |
|
|
236
|
+
| `orchestrations` | Chain task skills into a gated multi-phase pipeline — build-out, QA-fix, update-ship — when you can spawn sub-agents |
|
|
237
|
+
| `report-issue-framework` | File a bug or feature request against `@cyanheads/mcp-ts-core` via `gh` CLI |
|
|
238
|
+
| `report-issue-local` | File a bug or feature request against this server's own repo via `gh` CLI |
|
|
239
|
+
| `api-auth` | Auth modes, scopes, JWT/OAuth |
|
|
240
|
+
| `api-canvas` | DataCanvas: register tabular data, run SQL, export, plus the `spillover()` helper for big result sets — Tier 3 opt-in |
|
|
241
|
+
| `api-config` | AppConfig, parseConfig, env vars |
|
|
242
|
+
| `api-context` | Context interface, logger, state, progress |
|
|
243
|
+
| `api-errors` | McpError, JsonRpcErrorCode, error patterns |
|
|
244
|
+
| `api-linter` | Definition linter rule catalog — invoked by `bun run lint:mcp` and `devcheck` |
|
|
245
|
+
| `api-services` | LLM, Speech, Graph services |
|
|
246
|
+
| `api-testing` | createMockContext, test patterns |
|
|
247
|
+
| `api-utils` | Formatting, parsing, security, pagination, scheduling, telemetry helpers |
|
|
248
|
+
| `api-telemetry` | OTel catalog: spans, metrics, completion logs, env config, cardinality rules |
|
|
249
|
+
| `api-workers` | Cloudflare Workers runtime |
|
|
250
|
+
|
|
251
|
+
**Chaining skills into pipelines.** When the user wants a multi-phase effort — build this server out, QA-and-fix the surface, update-and-ship — *and you can spawn sub-agents*, `skills/orchestrations/SKILL.md` sequences the task skills above into a gated pipeline with verification at each step. Read it to drive the run. Optional: skip it if you can't orchestrate sub-agents, and ignore it entirely if you were *spawned* as one — you've already been scoped to a single phase.
|
|
252
|
+
|
|
253
|
+
When you complete a skill's checklist, check the boxes and add a completion timestamp at the end (e.g., `Completed: 2026-03-11`).
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Commands
|
|
258
|
+
|
|
259
|
+
**Runtime:** Scripts use `tsx` — both `npm run <cmd>` and `bun run <cmd>` work. `bun` is slightly faster for script invocation but not required.
|
|
260
|
+
|
|
261
|
+
| Command | Purpose |
|
|
262
|
+
|:--------|:--------|
|
|
263
|
+
| `npm run build` | Compile TypeScript |
|
|
264
|
+
| `npm run rebuild` | Clean + build |
|
|
265
|
+
| `npm run clean` | Remove build artifacts |
|
|
266
|
+
| `npm run devcheck` | Lint + format + typecheck + security + changelog sync |
|
|
267
|
+
| `bun run audit:refresh` | Delete `bun.lock`, reinstall, and re-run `bun audit`. Use when `devcheck` flags a transitive advisory — Bun's `update` is sticky on transitive resolutions, so the advisory may be a stale-lockfile false positive. If it survives the refresh, it's real. |
|
|
268
|
+
| `npm run tree` | Generate directory structure doc |
|
|
269
|
+
| `npm run format` | Auto-fix formatting (safe fixes only) |
|
|
270
|
+
| `npm run format:unsafe` | Also apply Biome's unsafe autofixes — review the diff; they can change behavior |
|
|
271
|
+
| `npm test` | Run tests |
|
|
272
|
+
| `npm run start:stdio` | Production mode (stdio) |
|
|
273
|
+
| `npm run start:http` | Production mode (HTTP) |
|
|
274
|
+
| `npm run changelog:build` | Regenerate `CHANGELOG.md` from `changelog/*.md` |
|
|
275
|
+
| `npm run changelog:check` | Verify `CHANGELOG.md` is in sync (used by devcheck) |
|
|
276
|
+
| `npm run bundle` | Build and pack as `.mcpb` for one-click Claude Desktop install |
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Bundling
|
|
281
|
+
|
|
282
|
+
`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.
|
|
283
|
+
|
|
284
|
+
**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.
|
|
285
|
+
|
|
286
|
+
**README install badges** (Claude Desktop `.mcpb`, Cursor, VS Code) and the `base64` / `encodeURIComponent` config-generation commands are ship-time concerns — run the `polish-docs-meta` skill, which carries the badge format, layout, and generation snippets in `skills/polish-docs-meta/references/readme.md`.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Changelog
|
|
291
|
+
|
|
292
|
+
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.
|
|
293
|
+
|
|
294
|
+
Each per-version file opens with YAML frontmatter:
|
|
295
|
+
|
|
296
|
+
```markdown
|
|
297
|
+
---
|
|
298
|
+
summary: "One-line headline, ≤350 chars" # required — powers the rollup index
|
|
299
|
+
breaking: false # optional — true flags breaking changes
|
|
300
|
+
security: false # optional — true flags security fixes
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
# 0.1.0 — YYYY-MM-DD
|
|
304
|
+
...
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
`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`.
|
|
308
|
+
|
|
309
|
+
`agent-notes` is an optional free-form field for maintenance agents processing the release downstream. Content here won't appear in the rendered CHANGELOG — it's consumed by agents running the `maintenance` skill. Use it for adoption instructions that don't fit the human-facing sections: new files to create, fields to populate, one-time migration steps. Omit entirely when there's nothing to say.
|
|
310
|
+
|
|
311
|
+
**Section order** (Keep a Changelog): Added, Changed, Deprecated, Removed, Fixed, Security. Include only sections with entries — don't ship empty headers.
|
|
312
|
+
|
|
313
|
+
**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.
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Imports
|
|
318
|
+
|
|
319
|
+
```ts
|
|
320
|
+
// Framework — z is re-exported, no separate zod import needed
|
|
321
|
+
import { tool, z } from '@cyanheads/mcp-ts-core';
|
|
322
|
+
import { McpError, JsonRpcErrorCode } from '@cyanheads/mcp-ts-core/errors';
|
|
323
|
+
|
|
324
|
+
// Server's own code — via path alias
|
|
325
|
+
import { getMyService } from '@/services/my-domain/my-service.js';
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## Checklist
|
|
331
|
+
|
|
332
|
+
- [ ] 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()`)
|
|
333
|
+
- [ ] 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`.
|
|
334
|
+
- [ ] JSDoc `@fileoverview` + `@module` on every file
|
|
335
|
+
- [ ] `ctx.log` for logging, `ctx.state` for storage
|
|
336
|
+
- [ ] Handlers throw on failure — error factories or plain `Error`, no try/catch
|
|
337
|
+
- [ ] `format()` renders all data the LLM needs — different clients forward different surfaces (Claude Code → `structuredContent`, Claude Desktop → `content[]`); both must carry the same data
|
|
338
|
+
- [ ] If wrapping external API: raw/domain/output schemas reviewed against real upstream sparsity/nullability before finalizing required vs optional fields
|
|
339
|
+
- [ ] If wrapping external API: normalization and `format()` preserve uncertainty; do not fabricate facts from missing upstream data
|
|
340
|
+
- [ ] If wrapping external API: tests include at least one sparse payload case with omitted upstream fields
|
|
341
|
+
- [ ] Registered in `createApp()` arrays (directly or via barrel exports)
|
|
342
|
+
- [ ] Tests use `createMockContext()` from `@cyanheads/mcp-ts-core/testing`
|
|
343
|
+
- [ ] `.codex-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; `interface.displayName` = package name; `interface.shortDescription` from `package.json` description
|
|
344
|
+
- [ ] `.codex-plugin/mcp.json` updated — server name key matches `package.json` name; env vars added for any required API keys
|
|
345
|
+
- [ ] `.claude-plugin/plugin.json` populated — `name`, `version`, `description`, `repository`, `license` from `package.json`; inline `mcpServers` entry with server name key, env vars for any required API keys
|
|
346
|
+
- [ ] `npm run devcheck` passes
|