@agentailor/create-mcp-server 0.7.1 → 0.8.0

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 (53) hide show
  1. package/README.md +27 -3
  2. package/dist/assets/skills/tool-design/SKILL.md +107 -0
  3. package/dist/assets/skills/tool-design/references/examples.md +273 -0
  4. package/dist/assets/skills/tool-design/references/principles.md +261 -0
  5. package/dist/assets/skills/tool-design/references/testing.md +195 -0
  6. package/dist/cli.d.ts +1 -0
  7. package/dist/cli.js +4 -2
  8. package/dist/cli.test.js +19 -0
  9. package/dist/index.js +1 -0
  10. package/dist/interactive.js +8 -0
  11. package/dist/project-generator.d.ts +1 -0
  12. package/dist/project-generator.js +27 -4
  13. package/dist/skills.d.ts +43 -0
  14. package/dist/skills.js +64 -0
  15. package/dist/skills.test.d.ts +1 -0
  16. package/dist/skills.test.js +85 -0
  17. package/dist/templates/common/agents.md.d.ts +9 -0
  18. package/dist/templates/common/agents.md.js +221 -0
  19. package/dist/templates/common/agents.md.test.d.ts +1 -0
  20. package/dist/templates/common/agents.md.test.js +142 -0
  21. package/dist/templates/common/package.json.js +19 -8
  22. package/dist/templates/common/tsconfig.json.d.ts +3 -1
  23. package/dist/templates/common/tsconfig.json.js +8 -2
  24. package/dist/templates/fastmcp/index.js +5 -3
  25. package/dist/templates/fastmcp/readme.js +13 -0
  26. package/dist/templates/sdk/stateful/auth.js +5 -1
  27. package/dist/templates/sdk/stateful/auth.test.js +6 -2
  28. package/dist/templates/sdk/stateful/index.d.ts +6 -0
  29. package/dist/templates/sdk/stateful/index.js +7 -1
  30. package/dist/templates/sdk/stateful/readme.js +1 -1
  31. package/dist/templates/sdk/stateful/templates.test.js +6 -7
  32. package/dist/templates/sdk/stateless/index.d.ts +6 -0
  33. package/dist/templates/sdk/stateless/index.js +10 -1
  34. package/dist/templates/sdk/stateless/prompts.d.ts +1 -0
  35. package/dist/templates/sdk/stateless/prompts.js +32 -0
  36. package/dist/templates/sdk/stateless/readme.js +72 -13
  37. package/dist/templates/sdk/stateless/resources.d.ts +1 -0
  38. package/dist/templates/sdk/stateless/resources.js +49 -0
  39. package/dist/templates/sdk/stateless/server-test.d.ts +1 -0
  40. package/dist/templates/sdk/stateless/server-test.js +175 -0
  41. package/dist/templates/sdk/stateless/server.js +14 -68
  42. package/dist/templates/sdk/stateless/store-test.d.ts +1 -0
  43. package/dist/templates/sdk/stateless/store-test.js +38 -0
  44. package/dist/templates/sdk/stateless/store.d.ts +1 -0
  45. package/dist/templates/sdk/stateless/store.js +107 -0
  46. package/dist/templates/sdk/stateless/templates.test.js +160 -14
  47. package/dist/templates/sdk/stateless/tools.d.ts +1 -0
  48. package/dist/templates/sdk/stateless/tools.js +172 -0
  49. package/dist/templates/sdk/stdio/index.d.ts +6 -0
  50. package/dist/templates/sdk/stdio/index.js +6 -0
  51. package/dist/templates/sdk/stdio/readme.js +64 -11
  52. package/dist/templates/sdk/stdio/templates.test.js +11 -13
  53. package/package.json +2 -2
@@ -0,0 +1,261 @@
1
+ # The Five Principles, In Depth
2
+
3
+ The five principles for designing tools an agent can actually use, with a worked schema shape for each. The shapes here are deliberately **framework-neutral** — a tool is described by four things regardless of your stack:
4
+
5
+ ```
6
+ name → the identifier the agent selects by
7
+ description → prose the agent reads to decide what/when/how
8
+ parameters → the inputs, each with type, description, constraints
9
+ returns → the shape and content the agent gets back
10
+ ```
11
+
12
+ Map these onto whatever you use: an MCP tool (`name` / `description` / `parameters` / `execute`), a LangChain/LangGraph tool (`name` / `description` / `schema` / `func`), an OpenAI or Anthropic function definition (`name` / `description` / `input_schema`), or a plain function exposed to a model. The design decisions are identical; only the syntax changes. Running example throughout: an expense-retrieval tool for a personal-finance agent (`get_expenses`).
13
+
14
+ ## Table of Contents
15
+
16
+ 1. [Strategic selection](#1-strategic-selection)
17
+ 2. [Clear naming and namespacing](#2-clear-naming-and-namespacing)
18
+ 3. [Meaningful context return](#3-meaningful-context-return)
19
+ 4. [Token efficiency](#4-token-efficiency)
20
+ 5. [Descriptions are prompts](#5-descriptions-are-prompts)
21
+
22
+ ---
23
+
24
+ ## 1. Strategic selection
25
+
26
+ **Build tools around user workflows, not database schemas or API endpoints.**
27
+
28
+ The instinct carried over from API design is to expose one operation per endpoint. For an agent this backfires: near-duplicate tools force the agent to choose among them on every turn, and each one costs prompt budget to document.
29
+
30
+ **Anti-pattern — fragmented:**
31
+
32
+ ```
33
+ name: get_expense_by_id parameters: { id }
34
+ name: list_all_expenses parameters: { }
35
+ name: filter_expenses_by_category parameters: { category }
36
+ name: search_expenses parameters: { query }
37
+ ```
38
+
39
+ The agent has to know which of four tools answers "what did I spend on groceries last month?" — and often guesses wrong.
40
+
41
+ **Better — one workflow tool:**
42
+
43
+ ```
44
+ name: get_expenses
45
+ parameters:
46
+ start_date (required) — date, ISO YYYY-MM-DD
47
+ end_date (required) — date, ISO YYYY-MM-DD
48
+ category (optional) — enum filter
49
+ limit (optional) — default 50
50
+ offset (optional) — default 0
51
+ ```
52
+
53
+ One tool handles search, filter, and pagination — the operations that co-occur in the real workflow.
54
+
55
+ **Decide with these questions:**
56
+ - Does this tool map to how a user thinks about the task, or to how the data is stored?
57
+ - Would combining it with a sibling reduce the number of decisions the agent must make?
58
+ - Are these operations frequently used together? If so, they may want to be one tool.
59
+
60
+ Consolidate where it clarifies — but don't overload a single tool with unrelated modes. The test is whether the combined tool still maps to *one* thing the user wants.
61
+
62
+ ### When *not* to consolidate
63
+
64
+ The principle has a real limit, and it's easy to overshoot. Shared data is not shared workflow.
65
+
66
+ Consider two sibling read tools over the same transactions table:
67
+
68
+ ```
69
+ name: query_transactions → bounded row listing "show me my Dining transactions in June"
70
+ name: run_sql → aggregates "how much did I spend on Dining last quarter?"
71
+ ```
72
+
73
+ They look like prime merge candidates — same table, adjacent phrasing, both read-only. But they return different shapes (rows plus truncation metadata vs. a scalar), and they need different safety envelopes (arbitrary SQL runs `READ ONLY`; a filtered listing needs no such guard). A merged tool with a mode flag doesn't remove the agent's decision — it hides it inside a parameter, where the description can no longer state plainly what the tool returns.
74
+
75
+ Keeping them separate also lets each description **route away from the other** — `query_transactions` telling the agent "for a total or a ranking across ALL matches, use `run_sql` instead" is a boundary you can only draw between two tools.
76
+
77
+ > **The test:** consolidate operations that share a **workflow**, not operations that merely touch the same **data**.
78
+
79
+ ---
80
+
81
+ ## 2. Clear naming and namespacing
82
+
83
+ **Names and descriptions are the primary signal the agent uses to select a tool.**
84
+
85
+ ### Names
86
+
87
+ Descriptive and action-oriented. Bare verbs are the enemy — they're ambiguous and they collide.
88
+
89
+ ```
90
+ ✅ get_expenses, calculate_budget_variance, send_notification
91
+ ❌ search (of what?), fetch (what?), process (process what?)
92
+ ```
93
+
94
+ ### Namespacing
95
+
96
+ When the agent has tools from multiple sources, two tools named `search` are indistinguishable in the moment of selection. Prefix consistently — by service or by resource:
97
+
98
+ ```
99
+ slack_search, notion_search (by service)
100
+ expenses_get, expenses_summarize (by resource)
101
+ ```
102
+
103
+ > **Know whether your surface prefixes for you.** Many MCP clients and adapters automatically prepend the server name to every tool (a server registered as `agentailor` turns `search` into `agentailor_search`). Some make it optional; some don't do it at all. If the surface already prefixes, don't hardcode the prefix too — a tool named `agentailor_search` on the `agentailor` server surfaces as `agentailor_agentailor_search`. That's not broken (the agent can still call it), just redundant and noisy. So: on an auto-prefixing surface, name the tool `search_articles` and let the server make it `agentailor_search_articles`; on a surface that doesn't prefix, add the namespace yourself. Either way the *goal* is the same — no two selectable tools share a name.
104
+
105
+ ### Descriptions answer what / when / how
106
+
107
+ ```
108
+ name: get_expenses
109
+ description: |
110
+ Retrieves user expenses within a date range, with optional category filtering.
111
+
112
+ When to use:
113
+ - "What did I spend on groceries last month?"
114
+ - "Show me expenses from January to March"
115
+ - "How much am I spending on dining out?"
116
+
117
+ Supports pagination and configurable verbosity. Returns human-readable
118
+ descriptions and category, not just IDs.
119
+ ```
120
+
121
+ ### Every parameter is documented
122
+
123
+ Format, an example, and constraints — never a bare type.
124
+
125
+ ```
126
+ parameters:
127
+ start_date:
128
+ type: string
129
+ description: "Start date, ISO format (YYYY-MM-DD). Required. Example: '2025-01-01'"
130
+ category:
131
+ type: string (enum)
132
+ description: "Optional. One of: groceries, dining, transport, utilities, healthcare, other. Omit for all categories."
133
+ response_format:
134
+ type: string (enum: concise | detailed)
135
+ description: "Optional. 'concise' = essential fields only; 'detailed' = full metadata. Default 'concise' for token efficiency."
136
+ ```
137
+
138
+ ---
139
+
140
+ ## 3. Meaningful context return
141
+
142
+ **Return information the agent can reason about, not identifiers it must resolve with another call.**
143
+
144
+ **Anti-pattern — IDs only:**
145
+
146
+ ```
147
+ returns:
148
+ expenses:
149
+ - { id: "uuid-1234", amount: 42.50 }
150
+ - { id: "uuid-5678", amount: 15.00 }
151
+ ```
152
+
153
+ To do anything useful the agent needs a second tool call per row to learn what each expense *was*. That's extra latency and wasted tokens.
154
+
155
+ **Better — semantic context plus metadata:**
156
+
157
+ ```
158
+ returns:
159
+ query: { date_range: {start, end}, category: "all", filters_applied: [] }
160
+ summary: { total_expenses: 2, total_amount: 57.50, currency: "USD" }
161
+ expenses:
162
+ - { date: "2025-01-14", amount: 42.50, category: "groceries", description: "Whole Foods" }
163
+ - { date: "2025-01-15", amount: 15.00, category: "dining", description: "Corner Café" }
164
+ ```
165
+
166
+ The agent can answer immediately, and the `query`/`summary` metadata tells it exactly what it's holding (which range, which filters, totals).
167
+
168
+ ### Configurable verbosity
169
+
170
+ Let the agent trade detail against tokens per task:
171
+
172
+ ```
173
+ concise → date, amount, category, description
174
+ detailed → + merchant, payment_method, tags, notes, recurring
175
+ ```
176
+
177
+ ### Return what the next call needs
178
+
179
+ When a tool's output feeds another tool, hand back the exact value that next call takes — a canonical URL or id — so the agent can chain without a lookup. (A search tool returning each result's readable identifier, so a read tool can consume it directly, is the canonical case; see [examples.md](examples.md).)
180
+
181
+ ---
182
+
183
+ ## 4. Token efficiency
184
+
185
+ **Every token in a tool response is a token unavailable for reasoning or further tool calls.**
186
+
187
+ ### Sensible defaults
188
+
189
+ ```
190
+ parameters:
191
+ limit: { type: number, default: 50, description: "Max items to return. Default 50. Lower = fewer tokens." }
192
+ offset: { type: number, default: 0, description: "Items to skip, for pagination." }
193
+ ```
194
+
195
+ ### Filter parameters
196
+
197
+ Give the agent ways to narrow *before* data comes back — `category`, `min_amount`, `search_term`. Every filter is a chance to avoid spending tokens on rows the agent didn't need.
198
+
199
+ ### Truncate loudly, and guide the next query
200
+
201
+ Never silently drop rows. Say what happened and how to get the rest:
202
+
203
+ ```
204
+ returns (when results exceed limit):
205
+ notice: "Found 847 expenses; returning the first 50 to preserve tokens."
206
+ guidance: "Narrow the date range or add a category filter. Use offset=50 to continue."
207
+ summary: { total_found: 847, returned: 50 }
208
+ expenses: [ ...50 items... ]
209
+ ```
210
+
211
+ ### Guard inputs that would blow up the response
212
+
213
+ Validate *before* running the query:
214
+
215
+ ```
216
+ if (days_between(start_date, end_date) > 365):
217
+ return error:
218
+ message: "Date range too large (>365 days). Large ranges consume excessive tokens and may hit context limits."
219
+ suggestion: "Use a smaller range (e.g. monthly) or add a category filter."
220
+ ```
221
+
222
+ ---
223
+
224
+ ## 5. Descriptions are prompts
225
+
226
+ **The name, description, and parameter docs are prompt engineering — treat them as such.**
227
+
228
+ Everything the agent knows about a tool before calling it comes from this text. Vague wording here is the single most common cause of mis-selection and malformed calls.
229
+
230
+ - Be explicit about **when** to use the tool (and when *not* to — "prefer `expenses_summarize` for totals").
231
+ - State **required vs optional** clearly, and what each optional defaults to.
232
+ - Describe the **output shape** so the agent knows what it's getting before it calls.
233
+ - **Iterate against real behavior.** Run realistic requests, watch where the agent stumbles, and sharpen the wording. Description quality is not a one-shot — it's refined the way you'd refine any prompt.
234
+
235
+ ### Helpful errors are part of the prompt too
236
+
237
+ An error message is the tool teaching the agent how to succeed on the retry. Cryptic codes teach nothing:
238
+
239
+ ```
240
+ ❌ { error: "ERR_INVALID_DATE" }
241
+
242
+ ✅ {
243
+ error: "Invalid date format. Use YYYY-MM-DD. Example: '2025-01-15'.",
244
+ received: { start_date: "01/15/2025" }
245
+ }
246
+ ```
247
+
248
+ For failures the agent can't fix by reformatting (auth, rate limit, upstream down), say which it is and what to do:
249
+
250
+ ```
251
+ ✅ {
252
+ error: "Upstream request failed: HTTP 429.",
253
+ meaning: "Rate limited. Wait and retry, or reduce request frequency."
254
+ }
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Putting it together
260
+
261
+ A single tool that honors all five: a **strategically-chosen** workflow tool, with a **clearly named** and **well-described** interface, that returns **meaningful context** with configurable verbosity, stays **token-efficient** through limits and guards, and whose descriptions and errors are written as **prompts** that steer the agent. See [examples.md](examples.md) for this realized in TypeScript and Python, as a standalone tool, and as a real MCP-server tool.
@@ -0,0 +1,195 @@
1
+ # Testing Tools: The Contract and the Behavior
2
+
3
+ A tool description is a **contract with a non-deterministic caller.** The rest of this skill is about writing that contract well. This file is about verifying that the implementation honors it — and that the agent actually acts on it.
4
+
5
+ Those are two different questions, and they split on whether a model is in the loop:
6
+
7
+ | | **Layer 1 — Deterministic tests** | **Layer 2 — Evals** |
8
+ | --- | --- | --- |
9
+ | Answers | Does the payload match what the description promised? | Does the agent select and interpret the tool correctly? |
10
+ | Needs | No model. I/O stubbed or real, as the tool warrants | A model in the loop |
11
+ | Cost | Fast and repeatable — same input, same verdict | Slow, non-deterministic, costs tokens |
12
+ | Catches | Broken contract | Mis-selection, mis-interpretation |
13
+ | Run | Always, on every change | Before shipping, on behavior-sensitive changes |
14
+
15
+ Layer 1 is a *category*, not a single test kind — unit, integration, contract, whatever the tool's logic warrants. The line that matters is the one in the table: no model, stable verdict.
16
+
17
+ Neither layer subsumes the other. A tool can pass every test in layer 1 and still be used wrongly; an agent can behave correctly in an eval run and regress the moment the payload shape changes underneath it.
18
+
19
+ **The floor: every tool gets a contract test, and an eval too where the budget allows.** Everything below is detail on what to assert and why. If you take one thing from this file, take that sentence.
20
+
21
+ > The worked example below comes from [Cameron](https://github.com/agentailor/cameron), a public personal-finance agent, and is reproduced as-is from shipped code. It's TypeScript with `vitest` because that's what that project uses — **you are expected to adapt it, not copy it.** Nothing about the runner, the mocking API, or the assertion syntax is part of the guidance; see [What transfers, what doesn't](#what-transfers-what-doesnt).
22
+
23
+ ## Table of Contents
24
+
25
+ 1. [Layer 1 — Deterministic tests](#layer-1--deterministic-tests)
26
+ 2. [Worked example: truncation that lies](#worked-example-truncation-that-lies)
27
+ 3. [Layer 2 — Evals](#layer-2--evals)
28
+ 4. [Where each layer lives](#where-each-layer-lives)
29
+
30
+ ---
31
+
32
+ ## Layer 1 — Deterministic tests
33
+
34
+ Whatever runs without a model and gives a stable answer. **Unit tests are the floor** — every tool gets them. Add integration tests when correctness depends on real I/O: a multi-step write, a transaction boundary, an external API's actual behavior. Cameron's tools are thin wrappers over repositories, so unit tests sufficed; a tool that moves money or spans tables won't be so lucky.
35
+
36
+ Whichever kinds you write, the target is the same. Most of this skill's [Validation Checklist](../SKILL.md#validation-checklist) is **mechanically testable.** The checklist tells you what a good tool does; these are the assertions that prove it still does:
37
+
38
+ | Checklist item | What the test asserts |
39
+ | --- | --- |
40
+ | **Efficient** | Truncation is *signalled*, not merely applied — and the payload says how to continue. |
41
+ | **Helpful on failure** | Errors come back as structured, actionable objects rather than throwing or returning a bare code. |
42
+ | **Contextual** | The payload actually contains the fields the description promised. |
43
+ | **Parameterized** | Defaults apply as documented; optional-vs-required behaves as documented; filters reach the data layer. |
44
+
45
+ Plus one that isn't on the checklist but belongs here: **a "no results" payload must mean what the agent will read it to mean.** An unknown category and a real category with zero rows both produce an empty list. If the payload doesn't distinguish them, the agent reports "you have no transactions" when the truth is "you typoed the category name."
46
+
47
+ ### Assert on the returned payload
48
+
49
+ Assert against the **tool's returned payload** — parse the JSON, assert on fields — rather than on internal function calls or the data layer.
50
+
51
+ That is the same surface an eval grades against later, so the assertions survive the move instead of being rewritten. It's also the surface the *agent* sees, which is the thing you actually care about: an internal function can be perfectly correct while the payload the agent reads is misleading.
52
+
53
+ **For the unit-test tier, isolate the tool from I/O.** Those tests should need no database, no network, and no API key — that's what makes them cheap enough to run on every change. *How* you isolate is your ecosystem's business: a mocking library, a hand-written fake, an injected interface, a trait implementation. The requirement is the isolation, not the technique. (Integration tests deliberately give this up in exchange for exercising the real thing — run them too, just not on every keystroke.)
54
+
55
+ ### What transfers, what doesn't
56
+
57
+ The worked example that follows is one project's code in one language. Read it for the **assertions**, not the syntax:
58
+
59
+ | Transfers to every stack | Doesn't transfer |
60
+ | --- | --- |
61
+ | *Which* properties of the payload you assert on | The test runner and its `describe`/`it` shape |
62
+ | Asserting on the parsed payload, not internals | The mocking API (`vi.mocked`, `patch`, a hand-rolled fake, an injected interface) |
63
+ | Pairing a positive case with its inverse | The assertion syntax (`expect(...).toBe`, `assert ==`, `require.Equal`) |
64
+ | Isolating the tool from I/O | The file naming and directory convention |
65
+
66
+ So: take the *list of things worth asserting*, and express it however your language and framework do it. A Python project writing these with `pytest` and a Go project writing them with table-driven tests are both following this skill correctly. If your stack has no mocking library at all, hand-write a fake — the point is that the test runs in milliseconds without touching a database.
67
+
68
+ ---
69
+
70
+ ## Worked example: truncation that lies
71
+
72
+ Cameron's `query_transactions` promised the agent a bounded list of transactions. The implementation returned:
73
+
74
+ ```ts
75
+ return JSON.stringify({ count: items.length, transactions: items });
76
+ ```
77
+
78
+ …while the repository silently capped rows (default 50, max 200). So a filter matching **262** transactions came back as `count: 50`, with nothing indicating anything was missing.
79
+
80
+ The agent cannot distinguish that from a complete result — and it had been told to reason over those rows. In a finance agent, that is a confidently-stated wrong total.
81
+
82
+ This is exactly [Principle 4](principles.md#4-token-efficiency)'s failure mode — *when you truncate, say so and say how to continue* — present in the checklist, absent from anything that could **detect** it.
83
+
84
+ ### The fix: make truncation visible
85
+
86
+ ```ts
87
+ const truncated = total > items.length;
88
+ return JSON.stringify({
89
+ returned: items.length,
90
+ matched: total,
91
+ truncated,
92
+ transactions: items,
93
+ ...(truncated
94
+ ? {
95
+ hint:
96
+ `Showing the ${items.length} most recent of ${total} matching transactions. ` +
97
+ "Narrow the date range, add a category/account filter, or raise `limit` (max 200). " +
98
+ "For a total or a ranking across ALL matches, use run_sql instead — do not add up " +
99
+ "these rows.",
100
+ }
101
+ : {}),
102
+ });
103
+ ```
104
+
105
+ `returned` vs `matched` is the whole repair: the agent can now see that it's holding 50 of 262. The `hint` does the Principle 5 work — it names the next move *and* routes the agent away from the mistake it would otherwise make (summing a partial page).
106
+
107
+ ### The test that catches it
108
+
109
+ Stub a full page against a larger total and assert the signal is present:
110
+
111
+ ```ts
112
+ it("tells the agent when results were truncated, and how to narrow them", async () => {
113
+ vi.mocked(transactionRepo.list).mockResolvedValue({
114
+ rows: makeTransactions(200),
115
+ total: 847,
116
+ });
117
+
118
+ const result = await callTool(queryTransactions, { from: "2026-01-01" });
119
+
120
+ expect(result.returned).toBe(200);
121
+ expect(result.matched).toBe(847);
122
+ expect(result.truncated).toBe(true);
123
+ // "truncated" alone isn't enough — the hint must give the next move.
124
+ expect(result.hint).toEqual(expect.stringContaining("847"));
125
+ expect(result.hint).toEqual(expect.stringMatching(/narrow|filter|run_sql/i));
126
+ });
127
+ ```
128
+
129
+ Milliseconds, no model, no database. Note the last two assertions: they test the *guidance*, not just the flag. A `truncated: true` with no usable hint satisfies the letter of Principle 4 and none of its intent.
130
+
131
+ Stripped of the language, that test is four steps — this is the part to carry into your own stack:
132
+
133
+ 1. **Arrange** — make the data layer report a page smaller than the true total (200 rows, 847 matched).
134
+ 2. **Act** — call the tool and parse its returned payload.
135
+ 3. **Assert the signal** — `returned`, `matched`, and the truncation flag all say the result is partial.
136
+ 4. **Assert the guidance** — the hint names the real total and points at a next move (narrow, filter, or switch tools).
137
+
138
+ Write those four steps in whatever your project already uses. The value is in step 4 especially: it's the assertion most test suites omit, and it's the one that encodes Principle 4's intent rather than its letter.
139
+
140
+ Pair it with the inverse, or the flag is meaningless:
141
+
142
+ ```ts
143
+ it("does not claim truncation when the result is complete", async () => {
144
+ vi.mocked(transactionRepo.list).mockResolvedValue({ rows: makeTransactions(12), total: 12 });
145
+
146
+ const result = await callTool(queryTransactions, {});
147
+
148
+ expect(result).toMatchObject({ returned: 12, matched: 12, truncated: false });
149
+ expect(result.hint).toBeUndefined();
150
+ });
151
+ ```
152
+
153
+ The same shape covers the ambiguous-empty case — assert that an unknown category comes back *named as unknown*, with a pointer to the tool that lists valid ones, and that the data layer was never queried at all.
154
+
155
+ ---
156
+
157
+ ## Layer 2 — Evals
158
+
159
+ Layer 1 verifies the payload. No amount of it — unit, integration, or otherwise — can verify two things:
160
+
161
+ - **Mis-selection between plausible siblings.** Nothing in a unit test decides whether the agent reached for `query_transactions` or `run_sql`. That choice is made by the model, from the descriptions — so only a model can test it.
162
+ - **Mis-interpretation.** A unit test proves `truncated: true` is *present*. Only an eval proves the agent **noticed** it and didn't report a capped page's sum as the year's total.
163
+
164
+ An eval runs the real agent against a seeded fixture and grades the transcript — typically on *which tools were called* and *what the agent finally said*. The specifics of the harness don't matter here and this skill deliberately doesn't prescribe one; what matters is that the layer exists and that you know what it's for.
165
+
166
+ ### Live evidence that the layer is necessary
167
+
168
+ Driving Cameron's real agent against a seeded database — 262 Dining transactions, true total **$2,752.25**:
169
+
170
+ | Prompt | What happened | |
171
+ | --- | --- | --- |
172
+ | "Show me my Dining transactions" | Payload `{"returned":50,"matched":262,"truncated":true}`; the agent reported **262** and flagged the partial view. | ✅ |
173
+ | "How much did I spend on Dining?" | Routed to SQL `SUM()` → **$2,752.25**. | ✅ |
174
+ | "List my Dining transactions **and then add them up** for me" | Pulled raw rows and summed them **in prose**: **$2,812.25** — off by $60. | ❌ |
175
+
176
+ The third case is the point. **The payload was correct and every layer-1 test passed.** The agent simply interpreted it badly — and it was non-deterministic: a re-run used `SUM()` and got the right answer.
177
+
178
+ No test in layer 1 can catch that, however many you write. It needs a model in the loop.
179
+
180
+ ### Deferring evals is a resource decision
181
+
182
+ It is not evidence the risk is absent. Cameron's truncation bug was found by *reading the code*, not by a failing signal — nothing in the project was watching for it, because there were no tests at all.
183
+
184
+ If you defer this layer, defer it knowingly: write down which behaviors are unverified, and treat "we've never seen it misbehave" as the absence of evidence it is.
185
+
186
+ ---
187
+
188
+ ## Where each layer lives
189
+
190
+ The two layers have opposite locality, and it's worth being deliberate about it:
191
+
192
+ - **Unit tests belong beside the tool** — `finance.test.ts` next to `finance.ts`. The tool and its contract tests then lift into any project as one unit. This skill is framework- and layout-agnostic and doesn't imply a directory structure; "beside" is about keeping the pair together, whatever your conventions call it.
193
+ - **Evals are cross-cutting and centralized** — they exercise the agent, not a tool, and a single case routinely spans several tools. They belong in their own top-level location, not scattered next to individual tools.
194
+
195
+ Don't assume both layers live in the same place. They answer different questions at different granularities.
package/dist/cli.d.ts CHANGED
@@ -8,6 +8,7 @@ export interface CLIOptions {
8
8
  template: TemplateType;
9
9
  oauth: boolean;
10
10
  git: boolean;
11
+ skills: boolean;
11
12
  }
12
13
  export interface ParseResult {
13
14
  mode: 'interactive' | 'cli';
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Command, Option, InvalidArgumentError } from 'commander';
2
2
  const NAME_REGEX = /^[a-z0-9-_]+$/i;
3
- const VERSION = '0.7.1';
3
+ const VERSION = '0.8.0';
4
4
  function validateName(value) {
5
5
  if (!NAME_REGEX.test(value)) {
6
6
  throw new InvalidArgumentError('Project name can only contain letters, numbers, hyphens, and underscores');
@@ -25,7 +25,8 @@ export function parseArguments() {
25
25
  .default('stateless'))
26
26
  .option('--stdio', 'Use stdio transport instead of HTTP', false)
27
27
  .option('--oauth', 'Enable OAuth authentication (sdk HTTP only)', false)
28
- .option('--no-git', 'Skip git repository initialization');
28
+ .option('--no-git', 'Skip git repository initialization')
29
+ .option('--no-skills', 'Skip adding the tool-design skill');
29
30
  program.parse();
30
31
  const opts = program.opts();
31
32
  // Detect mode based on whether any option was explicitly provided
@@ -66,6 +67,7 @@ export function parseArguments() {
66
67
  template: opts.template,
67
68
  oauth: opts.oauth,
68
69
  git: opts.git, // Commander handles --no-git -> git: false
70
+ skills: opts.skills, // Commander handles --no-skills -> skills: false
69
71
  },
70
72
  };
71
73
  }
package/dist/cli.test.js CHANGED
@@ -57,6 +57,7 @@ describe('CLI argument parsing', () => {
57
57
  template: 'stateful',
58
58
  oauth: false,
59
59
  git: false,
60
+ skills: true,
60
61
  });
61
62
  });
62
63
  it('parses short flags correctly', async () => {
@@ -211,4 +212,22 @@ describe('CLI argument parsing', () => {
211
212
  expect(consoleError).toHaveBeenCalledWith(expect.stringContaining('--template=stateful is not applicable with --stdio'));
212
213
  consoleError.mockRestore();
213
214
  });
215
+ it('installs the tool-design skill by default', async () => {
216
+ process.argv = ['node', 'create-mcp-server', '--name=test'];
217
+ const { parseArguments } = await import('./cli.js');
218
+ expect(parseArguments().options?.skills).toBe(true);
219
+ });
220
+ it('skips the skill install with --no-skills', async () => {
221
+ process.argv = ['node', 'create-mcp-server', '--name=test', '--no-skills'];
222
+ const { parseArguments } = await import('./cli.js');
223
+ expect(parseArguments().options?.skills).toBe(false);
224
+ });
225
+ // They are independent: git can be installed and still not wanted here.
226
+ it('treats --no-git and --no-skills as orthogonal', async () => {
227
+ process.argv = ['node', 'create-mcp-server', '--name=test', '--no-git'];
228
+ const { parseArguments } = await import('./cli.js');
229
+ const options = parseArguments().options;
230
+ expect(options?.git).toBe(false);
231
+ expect(options?.skills).toBe(true);
232
+ });
214
233
  });
package/dist/index.js CHANGED
@@ -17,6 +17,7 @@ async function main() {
17
17
  templateType: options.template,
18
18
  withOAuth: options.oauth,
19
19
  withGitInit: options.git,
20
+ withSkills: options.skills,
20
21
  });
21
22
  }
22
23
  }
@@ -121,6 +121,13 @@ export async function runInteractiveMode() {
121
121
  initial: true,
122
122
  }, { onCancel });
123
123
  const withGitInit = gitInitResponse.withGitInit ?? false;
124
+ const skillsResponse = await prompts({
125
+ type: 'confirm',
126
+ name: 'withSkills',
127
+ message: 'Include the tool-design skill for AI agents?',
128
+ initial: true,
129
+ }, { onCancel });
130
+ const withSkills = skillsResponse.withSkills ?? false;
124
131
  await generateProject({
125
132
  projectName,
126
133
  packageManager,
@@ -129,5 +136,6 @@ export async function runInteractiveMode() {
129
136
  templateType,
130
137
  withOAuth,
131
138
  withGitInit,
139
+ withSkills,
132
140
  });
133
141
  }
@@ -12,5 +12,6 @@ export interface ProjectConfig {
12
12
  templateType: TemplateType;
13
13
  withOAuth: boolean;
14
14
  withGitInit: boolean;
15
+ withSkills: boolean;
15
16
  }
16
17
  export declare function generateProject(config: ProjectConfig): Promise<void>;
@@ -5,13 +5,15 @@ import { getPackageJsonTemplate } from './templates/common/package.json.js';
5
5
  import { getTsconfigTemplate } from './templates/common/tsconfig.json.js';
6
6
  import { getGitignoreTemplate } from './templates/common/gitignore.js';
7
7
  import { getEnvExampleTemplate } from './templates/common/env.example.js';
8
- import { getServerTemplate as getSdkStatelessServerTemplate, getIndexTemplate as getSdkStatelessIndexTemplate, getReadmeTemplate as getSdkStatelessReadmeTemplate, } from './templates/sdk/stateless/index.js';
8
+ import { getAgentsMdTemplate } from './templates/common/agents.md.js';
9
+ import { copySkill, SKILLS_UPDATE_COMMAND, SKILLS_INSTALL_HINT, SKILLS_DIR } from './skills.js';
10
+ import { getServerTemplate as getSdkStatelessServerTemplate, getIndexTemplate as getSdkStatelessIndexTemplate, getReadmeTemplate as getSdkStatelessReadmeTemplate, getStoreTemplate as getSdkStoreTemplate, getToolsTemplate as getSdkToolsTemplate, getPromptsTemplate as getSdkPromptsTemplate, getResourcesTemplate as getSdkResourcesTemplate, getStoreTestTemplate as getSdkStoreTestTemplate, getServerTestTemplate as getSdkServerTestTemplate, } from './templates/sdk/stateless/index.js';
9
11
  import { getAuthTemplate as getSdkAuthTemplate } from './templates/sdk/stateful/index.js';
10
12
  import { getServerTemplate as getFastMCPServerTemplate, getIndexTemplate as getFastMCPIndexTemplate, getReadmeTemplate as getFastMCPReadmeTemplate, } from './templates/fastmcp/index.js';
11
13
  import { getServerTemplate as getSdkStdioServerTemplate, getIndexTemplate as getSdkStdioIndexTemplate, getReadmeTemplate as getSdkStdioReadmeTemplate, } from './templates/sdk/stdio/index.js';
12
14
  import { getDockerfileTemplate, getDockerignoreTemplate } from './templates/deployment/index.js';
13
15
  // Auth is keyed off `withOAuth`, never off the template type - see
14
- // "Why stateless and stateful are identical" in CLAUDE.md.
16
+ // "Why stateless and stateful are identical" in AGENTS.md.
15
17
  const sdkHttpTemplateFunctions = {
16
18
  getServerTemplate: getSdkStatelessServerTemplate,
17
19
  getIndexTemplate: getSdkStatelessIndexTemplate,
@@ -29,7 +31,7 @@ export const packageManagerCommands = {
29
31
  yarn: { install: 'yarn', dev: 'yarn dev' },
30
32
  };
31
33
  export async function generateProject(config) {
32
- const { projectName, packageManager, framework, transport, templateType, withOAuth, withGitInit, } = config;
34
+ const { projectName, packageManager, framework, transport, templateType, withOAuth, withGitInit, withSkills, } = config;
33
35
  const templateOptions = {
34
36
  withOAuth: transport === 'http' ? withOAuth : false,
35
37
  packageManager,
@@ -58,8 +60,14 @@ export async function generateProject(config) {
58
60
  filesToWrite.push(writeFile(join(srcPath, 'auth.ts'), templates.getAuthTemplate()));
59
61
  }
60
62
  }
63
+ // server.ts only composes these; they are identical on both SDK transports.
64
+ if (framework === 'sdk') {
65
+ filesToWrite.push(writeFile(join(srcPath, 'tools.ts'), getSdkToolsTemplate()), writeFile(join(srcPath, 'prompts.ts'), getSdkPromptsTemplate()), writeFile(join(srcPath, 'resources.ts'), getSdkResourcesTemplate()), writeFile(join(srcPath, 'notes-store.ts'), getSdkStoreTemplate()),
66
+ // Two layers: the store in isolation, and the payload an agent reads.
67
+ writeFile(join(srcPath, 'notes-store.test.ts'), getSdkStoreTestTemplate()), writeFile(join(srcPath, 'server.test.ts'), getSdkServerTestTemplate()));
68
+ }
61
69
  // Common files for all templates
62
- filesToWrite.push(writeFile(join(projectPath, 'package.json'), getPackageJsonTemplate(projectName, templateOptions)), writeFile(join(projectPath, 'tsconfig.json'), getTsconfigTemplate()), writeFile(join(projectPath, '.gitignore'), getGitignoreTemplate()), writeFile(join(projectPath, '.env.example'), getEnvExampleTemplate(templateOptions)));
70
+ filesToWrite.push(writeFile(join(projectPath, 'package.json'), getPackageJsonTemplate(projectName, templateOptions)), writeFile(join(projectPath, 'tsconfig.json'), getTsconfigTemplate({ withTests: framework === 'sdk' })), writeFile(join(projectPath, '.gitignore'), getGitignoreTemplate()), writeFile(join(projectPath, '.env.example'), getEnvExampleTemplate(templateOptions)), writeFile(join(projectPath, 'AGENTS.md'), getAgentsMdTemplate(projectName, templateOptions)));
63
71
  // Deployment files for HTTP transport only (stdio servers are not HTTP services)
64
72
  if (transport === 'http') {
65
73
  filesToWrite.push(writeFile(join(projectPath, 'Dockerfile'), getDockerfileTemplate(templateOptions)), writeFile(join(projectPath, '.dockerignore'), getDockerignoreTemplate()));
@@ -75,6 +83,17 @@ export async function generateProject(config) {
75
83
  console.log('\n Could not initialize git repository (is git installed?)');
76
84
  }
77
85
  }
86
+ // The skill is vendored, so this is a file copy. It never fails the scaffold:
87
+ // the project is complete without it.
88
+ let skillCopied = false;
89
+ if (withSkills) {
90
+ const result = await copySkill(projectPath);
91
+ skillCopied = result.copied;
92
+ if (!result.copied) {
93
+ console.log(`\n Could not add the tool-design skill (${result.reason}).`);
94
+ console.log(` To add it by hand: ${SKILLS_INSTALL_HINT}`);
95
+ }
96
+ }
78
97
  const commands = packageManagerCommands[packageManager];
79
98
  const frameworkName = framework === 'fastmcp' ? 'FastMCP' : 'MCP SDK';
80
99
  console.log(`\nCreated ${projectName} with ${frameworkName} (${transport}) at ${projectPath}`);
@@ -82,5 +101,9 @@ export async function generateProject(config) {
82
101
  console.log(` cd ${projectName}`);
83
102
  console.log(` ${commands.install}`);
84
103
  console.log(` ${commands.dev}`);
104
+ if (skillCopied) {
105
+ console.log(`\nThe tool-design skill is in ${SKILLS_DIR}/skills/. Check for a newer version with:`);
106
+ console.log(` ${SKILLS_UPDATE_COMMAND}`);
107
+ }
85
108
  console.log(`\n`);
86
109
  }