hive-skills 0.1.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 (238) hide show
  1. package/LICENSE +28 -0
  2. package/README.md +235 -0
  3. package/assets/LICENSE +32 -0
  4. package/assets/THIRD_PARTY_NOTICES.md +72 -0
  5. package/assets/manifest.json +1290 -0
  6. package/assets/skills/authored/code-review/composable/BUNDLE.md +192 -0
  7. package/assets/skills/authored/code-review/composable/INDEX.md +13 -0
  8. package/assets/skills/authored/code-review/composable/VERSION +1 -0
  9. package/assets/skills/authored/code-review/composable/mini/01-review-method.md +34 -0
  10. package/assets/skills/authored/code-review/composable/mini/02-security-review.md +20 -0
  11. package/assets/skills/authored/code-review/composable/mini/03-correctness-bugs.md +19 -0
  12. package/assets/skills/authored/code-review/composable/mini/04-concurrency.md +16 -0
  13. package/assets/skills/authored/code-review/composable/mini/05-error-handling.md +12 -0
  14. package/assets/skills/authored/code-review/composable/mini/06-performance.md +11 -0
  15. package/assets/skills/authored/code-review/composable/mini/07-api-design.md +20 -0
  16. package/assets/skills/authored/code-review/composable/mini/08-missing-tests.md +25 -0
  17. package/assets/skills/authored/code-review/composable/mini/09-refactoring-and-communication.md +32 -0
  18. package/assets/skills/authored/data-analysis/composable/BUNDLE.md +186 -0
  19. package/assets/skills/authored/data-analysis/composable/INDEX.md +13 -0
  20. package/assets/skills/authored/data-analysis/composable/VERSION +1 -0
  21. package/assets/skills/authored/data-analysis/composable/mini/01-data-quality-profiling.md +26 -0
  22. package/assets/skills/authored/data-analysis/composable/mini/02-aggregation-pitfalls.md +21 -0
  23. package/assets/skills/authored/data-analysis/composable/mini/03-time-series.md +19 -0
  24. package/assets/skills/authored/data-analysis/composable/mini/04-segmentation.md +23 -0
  25. package/assets/skills/authored/data-analysis/composable/mini/05-discount-pricing.md +17 -0
  26. package/assets/skills/authored/data-analysis/composable/mini/06-insight-generation.md +25 -0
  27. package/assets/skills/authored/data-analysis/composable/mini/07-executive-writing.md +26 -0
  28. package/assets/skills/authored/data-analysis/composable/mini/08-recommendations.md +20 -0
  29. package/assets/skills/authored/data-analysis/composable/mini/09-reproducibility-assumptions.md +20 -0
  30. package/assets/skills/authored/financial-analysis/composable/BUNDLE.md +1293 -0
  31. package/assets/skills/authored/financial-analysis/composable/INDEX.md +17 -0
  32. package/assets/skills/authored/financial-analysis/composable/VERSION +1 -0
  33. package/assets/skills/authored/financial-analysis/composable/mini/00-core.md +69 -0
  34. package/assets/skills/authored/financial-analysis/composable/mini/01-profitability-efficiency-ratios.md +173 -0
  35. package/assets/skills/authored/financial-analysis/composable/mini/02-liquidity-leverage-ratios.md +120 -0
  36. package/assets/skills/authored/financial-analysis/composable/mini/03-valuation-ratios-interpretation.md +107 -0
  37. package/assets/skills/authored/financial-analysis/composable/mini/04-dcf-projection-wacc.md +122 -0
  38. package/assets/skills/authored/financial-analysis/composable/mini/05-dcf-terminal-value-sensitivity.md +75 -0
  39. package/assets/skills/authored/financial-analysis/composable/mini/06-comparables-precedents.md +78 -0
  40. package/assets/skills/authored/financial-analysis/composable/mini/07-budget-variance-analysis.md +47 -0
  41. package/assets/skills/authored/financial-analysis/composable/mini/08-driver-based-forecasting-scenarios.md +111 -0
  42. package/assets/skills/authored/financial-analysis/composable/mini/09-rolling-forecasts-accuracy.md +114 -0
  43. package/assets/skills/authored/financial-analysis/composable/mini/10-reporting-exec-summary.md +58 -0
  44. package/assets/skills/authored/financial-analysis/composable/mini/11-industry-adaptations.md +130 -0
  45. package/assets/skills/authored/financial-analysis/composable/mini/12-toolkit-scripts-io.md +102 -0
  46. package/assets/skills/authored/python-api/composable/BUNDLE.md +389 -0
  47. package/assets/skills/authored/python-api/composable/INDEX.md +13 -0
  48. package/assets/skills/authored/python-api/composable/VERSION +1 -0
  49. package/assets/skills/authored/python-api/composable/mini/01-project-structure.md +44 -0
  50. package/assets/skills/authored/python-api/composable/mini/02-routing-and-app.md +38 -0
  51. package/assets/skills/authored/python-api/composable/mini/03-pydantic-models.md +45 -0
  52. package/assets/skills/authored/python-api/composable/mini/04-validation-and-errors.md +59 -0
  53. package/assets/skills/authored/python-api/composable/mini/05-dependencies-and-auth.md +60 -0
  54. package/assets/skills/authored/python-api/composable/mini/06-pagination-filtering.md +44 -0
  55. package/assets/skills/authored/python-api/composable/mini/07-async-performance.md +30 -0
  56. package/assets/skills/authored/python-api/composable/mini/08-testing.md +45 -0
  57. package/assets/skills/authored/python-api/composable/mini/09-middleware-observability.md +29 -0
  58. package/assets/skills/authored/tech-writing/composable/BUNDLE.md +220 -0
  59. package/assets/skills/authored/tech-writing/composable/INDEX.md +12 -0
  60. package/assets/skills/authored/tech-writing/composable/VERSION +1 -0
  61. package/assets/skills/authored/tech-writing/composable/mini/01-audience-analysis.md +26 -0
  62. package/assets/skills/authored/tech-writing/composable/mini/02-document-types.md +27 -0
  63. package/assets/skills/authored/tech-writing/composable/mini/03-readme-quickstart-changelog.md +22 -0
  64. package/assets/skills/authored/tech-writing/composable/mini/04-information-architecture.md +21 -0
  65. package/assets/skills/authored/tech-writing/composable/mini/05-style-clarity.md +29 -0
  66. package/assets/skills/authored/tech-writing/composable/mini/06-breaking-changes-migrations.md +33 -0
  67. package/assets/skills/authored/tech-writing/composable/mini/07-troubleshooting-security.md +30 -0
  68. package/assets/skills/authored/tech-writing/composable/mini/08-faq-voice-tone.md +32 -0
  69. package/assets/skills/converted/claude-api/composable/BUNDLE.md +14996 -0
  70. package/assets/skills/converted/claude-api/composable/INDEX.md +98 -0
  71. package/assets/skills/converted/claude-api/composable/VERSION +1 -0
  72. package/assets/skills/converted/claude-api/composable/mini/00-core.md +235 -0
  73. package/assets/skills/converted/claude-api/composable/mini/01-model-api-quick-reference.md +258 -0
  74. package/assets/skills/converted/claude-api/composable/mini/02-common-pitfalls.md +42 -0
  75. package/assets/skills/converted/claude-api/composable/mini/10-models.md +135 -0
  76. package/assets/skills/converted/claude-api/composable/mini/11-platform-availability.md +96 -0
  77. package/assets/skills/converted/claude-api/composable/mini/12-claude-platform-on-aws.md +59 -0
  78. package/assets/skills/converted/claude-api/composable/mini/13-live-sources.md +143 -0
  79. package/assets/skills/converted/claude-api/composable/mini/14-error-codes.md +256 -0
  80. package/assets/skills/converted/claude-api/composable/mini/15-prompt-caching.md +223 -0
  81. package/assets/skills/converted/claude-api/composable/mini/16-token-counting.md +56 -0
  82. package/assets/skills/converted/claude-api/composable/mini/17-tool-use-concepts.md +444 -0
  83. package/assets/skills/converted/claude-api/composable/mini/18-agent-design.md +101 -0
  84. package/assets/skills/converted/claude-api/composable/mini/19-anthropic-cli.md +246 -0
  85. package/assets/skills/converted/claude-api/composable/mini/20-model-migration.md +1301 -0
  86. package/assets/skills/converted/claude-api/composable/mini/30-managed-agents-overview.md +71 -0
  87. package/assets/skills/converted/claude-api/composable/mini/31-managed-agents-core.md +278 -0
  88. package/assets/skills/converted/claude-api/composable/mini/32-managed-agents-environments.md +219 -0
  89. package/assets/skills/converted/claude-api/composable/mini/33-managed-agents-tools.md +366 -0
  90. package/assets/skills/converted/claude-api/composable/mini/34-managed-agents-events.md +252 -0
  91. package/assets/skills/converted/claude-api/composable/mini/35-managed-agents-outcomes.md +106 -0
  92. package/assets/skills/converted/claude-api/composable/mini/36-managed-agents-multiagent.md +101 -0
  93. package/assets/skills/converted/claude-api/composable/mini/37-managed-agents-webhooks.md +123 -0
  94. package/assets/skills/converted/claude-api/composable/mini/38-managed-agents-memory.md +197 -0
  95. package/assets/skills/converted/claude-api/composable/mini/39-managed-agents-scheduled-deployments.md +146 -0
  96. package/assets/skills/converted/claude-api/composable/mini/40-managed-agents-client-patterns.md +211 -0
  97. package/assets/skills/converted/claude-api/composable/mini/41-managed-agents-onboarding.md +82 -0
  98. package/assets/skills/converted/claude-api/composable/mini/42-managed-agents-api-reference.md +441 -0
  99. package/assets/skills/converted/claude-api/composable/mini/43-managed-agents-self-hosted-sandboxes.md +174 -0
  100. package/assets/skills/converted/claude-api/composable/mini/50-python-readme.md +564 -0
  101. package/assets/skills/converted/claude-api/composable/mini/51-python-tool-use.md +590 -0
  102. package/assets/skills/converted/claude-api/composable/mini/52-python-streaming-batches-files.md +549 -0
  103. package/assets/skills/converted/claude-api/composable/mini/53-python-managed-agents.md +335 -0
  104. package/assets/skills/converted/claude-api/composable/mini/55-typescript-readme.md +404 -0
  105. package/assets/skills/converted/claude-api/composable/mini/56-typescript-tool-use.md +548 -0
  106. package/assets/skills/converted/claude-api/composable/mini/57-typescript-streaming-batches-files.md +384 -0
  107. package/assets/skills/converted/claude-api/composable/mini/58-typescript-managed-agents.md +358 -0
  108. package/assets/skills/converted/claude-api/composable/mini/60-csharp-readme.md +361 -0
  109. package/assets/skills/converted/claude-api/composable/mini/61-csharp-tool-use.md +163 -0
  110. package/assets/skills/converted/claude-api/composable/mini/62-csharp-streaming-batches-files.md +64 -0
  111. package/assets/skills/converted/claude-api/composable/mini/65-go-readme.md +185 -0
  112. package/assets/skills/converted/claude-api/composable/mini/66-go-tool-use.md +219 -0
  113. package/assets/skills/converted/claude-api/composable/mini/67-go-streaming-files.md +63 -0
  114. package/assets/skills/converted/claude-api/composable/mini/68-go-managed-agents.md +564 -0
  115. package/assets/skills/converted/claude-api/composable/mini/70-java-readme.md +237 -0
  116. package/assets/skills/converted/claude-api/composable/mini/71-java-tool-use.md +227 -0
  117. package/assets/skills/converted/claude-api/composable/mini/72-java-streaming-files.md +49 -0
  118. package/assets/skills/converted/claude-api/composable/mini/73-java-managed-agents.md +443 -0
  119. package/assets/skills/converted/claude-api/composable/mini/75-php-readme.md +173 -0
  120. package/assets/skills/converted/claude-api/composable/mini/76-php-tool-use.md +252 -0
  121. package/assets/skills/converted/claude-api/composable/mini/77-php-streaming-batches-files.md +53 -0
  122. package/assets/skills/converted/claude-api/composable/mini/78-php-managed-agents.md +443 -0
  123. package/assets/skills/converted/claude-api/composable/mini/80-ruby-readme.md +133 -0
  124. package/assets/skills/converted/claude-api/composable/mini/81-ruby-tool-use-streaming.md +56 -0
  125. package/assets/skills/converted/claude-api/composable/mini/82-ruby-managed-agents.md +394 -0
  126. package/assets/skills/converted/claude-api/composable/mini/85-curl-examples.md +255 -0
  127. package/assets/skills/converted/claude-api/composable/mini/86-curl-managed-agents.md +340 -0
  128. package/assets/skills/converted/claude-api/composable/presets/csharp.md +1151 -0
  129. package/assets/skills/converted/claude-api/composable/presets/curl.md +1154 -0
  130. package/assets/skills/converted/claude-api/composable/presets/go.md +1598 -0
  131. package/assets/skills/converted/claude-api/composable/presets/java.md +1523 -0
  132. package/assets/skills/converted/claude-api/composable/presets/php.md +1488 -0
  133. package/assets/skills/converted/claude-api/composable/presets/python.md +2605 -0
  134. package/assets/skills/converted/claude-api/composable/presets/ruby.md +1146 -0
  135. package/assets/skills/converted/claude-api/composable/presets/shared.md +6478 -0
  136. package/assets/skills/converted/claude-api/composable/presets/typescript.md +2261 -0
  137. package/assets/skills/converted/docx/composable/BUNDLE.md +617 -0
  138. package/assets/skills/converted/docx/composable/INDEX.md +12 -0
  139. package/assets/skills/converted/docx/composable/VERSION +1 -0
  140. package/assets/skills/converted/docx/composable/mini/00-core.md +26 -0
  141. package/assets/skills/converted/docx/composable/mini/01-reading-converting.md +36 -0
  142. package/assets/skills/converted/docx/composable/mini/02-creating-setup-layout.md +85 -0
  143. package/assets/skills/converted/docx/composable/mini/03-creating-elements.md +257 -0
  144. package/assets/skills/converted/docx/composable/mini/04-editing-existing.md +57 -0
  145. package/assets/skills/converted/docx/composable/mini/05-xml-reference.md +128 -0
  146. package/assets/skills/converted/internal-comms/composable/BUNDLE.md +220 -0
  147. package/assets/skills/converted/internal-comms/composable/INDEX.md +11 -0
  148. package/assets/skills/converted/internal-comms/composable/VERSION +1 -0
  149. package/assets/skills/converted/internal-comms/composable/mini/00-core.md +30 -0
  150. package/assets/skills/converted/internal-comms/composable/mini/01-3p-updates.md +49 -0
  151. package/assets/skills/converted/internal-comms/composable/mini/02-company-newsletter.md +67 -0
  152. package/assets/skills/converted/internal-comms/composable/mini/03-faq-answers.md +32 -0
  153. package/assets/skills/converted/internal-comms/composable/mini/04-general-comms.md +18 -0
  154. package/assets/skills/converted/mcp-builder/composable/BUNDLE.md +2460 -0
  155. package/assets/skills/converted/mcp-builder/composable/INDEX.md +23 -0
  156. package/assets/skills/converted/mcp-builder/composable/VERSION +1 -0
  157. package/assets/skills/converted/mcp-builder/composable/mini/00-core.md +43 -0
  158. package/assets/skills/converted/mcp-builder/composable/mini/01-workflow-research-planning.md +54 -0
  159. package/assets/skills/converted/mcp-builder/composable/mini/02-implementation-process.md +78 -0
  160. package/assets/skills/converted/mcp-builder/composable/mini/03-naming-conventions.md +33 -0
  161. package/assets/skills/converted/mcp-builder/composable/mini/04-response-formats.md +21 -0
  162. package/assets/skills/converted/mcp-builder/composable/mini/05-pagination.md +24 -0
  163. package/assets/skills/converted/mcp-builder/composable/mini/06-transport.md +47 -0
  164. package/assets/skills/converted/mcp-builder/composable/mini/07-annotations.md +20 -0
  165. package/assets/skills/converted/mcp-builder/composable/mini/08-security.md +35 -0
  166. package/assets/skills/converted/mcp-builder/composable/mini/09-error-handling.md +32 -0
  167. package/assets/skills/converted/mcp-builder/composable/mini/10-testing-and-documentation.md +21 -0
  168. package/assets/skills/converted/mcp-builder/composable/mini/11-python-implementation.md +432 -0
  169. package/assets/skills/converted/mcp-builder/composable/mini/12-python-advanced-and-checklist.md +233 -0
  170. package/assets/skills/converted/mcp-builder/composable/mini/13-node-implementation.md +717 -0
  171. package/assets/skills/converted/mcp-builder/composable/mini/14-node-advanced-and-checklist.md +200 -0
  172. package/assets/skills/converted/mcp-builder/composable/mini/15-evaluation-design.md +200 -0
  173. package/assets/skills/converted/mcp-builder/composable/mini/16-evaluation-running.md +198 -0
  174. package/assets/skills/converted/mcp-builder/composable/presets/node-server.md +1381 -0
  175. package/assets/skills/converted/mcp-builder/composable/presets/python-server.md +1129 -0
  176. package/assets/skills/converted/pdf/composable/BUNDLE.md +1284 -0
  177. package/assets/skills/converted/pdf/composable/INDEX.md +14 -0
  178. package/assets/skills/converted/pdf/composable/VERSION +1 -0
  179. package/assets/skills/converted/pdf/composable/mini/00-core.md +46 -0
  180. package/assets/skills/converted/pdf/composable/mini/01-creation.md +176 -0
  181. package/assets/skills/converted/pdf/composable/mini/02-extraction.md +178 -0
  182. package/assets/skills/converted/pdf/composable/mini/03-merge-split-manipulate.md +240 -0
  183. package/assets/skills/converted/pdf/composable/mini/04-images-ocr.md +168 -0
  184. package/assets/skills/converted/pdf/composable/mini/05-encryption.md +51 -0
  185. package/assets/skills/converted/pdf/composable/mini/06-forms.md +300 -0
  186. package/assets/skills/converted/pdf/composable/mini/07-libraries-reference.md +89 -0
  187. package/assets/skills/converted/pptx/composable/BUNDLE.md +911 -0
  188. package/assets/skills/converted/pptx/composable/INDEX.md +12 -0
  189. package/assets/skills/converted/pptx/composable/VERSION +1 -0
  190. package/assets/skills/converted/pptx/composable/mini/00-core.md +37 -0
  191. package/assets/skills/converted/pptx/composable/mini/01-reading.md +37 -0
  192. package/assets/skills/converted/pptx/composable/mini/02-creating-from-scratch.md +422 -0
  193. package/assets/skills/converted/pptx/composable/mini/03-editing-templates.md +207 -0
  194. package/assets/skills/converted/pptx/composable/mini/04-design.md +89 -0
  195. package/assets/skills/converted/pptx/composable/mini/05-qa-and-rendering.md +91 -0
  196. package/assets/skills/converted/pptx/composable/presets/creating.md +659 -0
  197. package/assets/skills/converted/pptx/composable/presets/editing.md +485 -0
  198. package/assets/skills/converted/skill-creator/composable/BUNDLE.md +1681 -0
  199. package/assets/skills/converted/skill-creator/composable/INDEX.md +21 -0
  200. package/assets/skills/converted/skill-creator/composable/VERSION +1 -0
  201. package/assets/skills/converted/skill-creator/composable/mini/00-core.md +59 -0
  202. package/assets/skills/converted/skill-creator/composable/mini/01-creating-a-skill.md +27 -0
  203. package/assets/skills/converted/skill-creator/composable/mini/02-skill-writing-guide.md +71 -0
  204. package/assets/skills/converted/skill-creator/composable/mini/03-test-cases.md +21 -0
  205. package/assets/skills/converted/skill-creator/composable/mini/04-running-and-evaluating.md +128 -0
  206. package/assets/skills/converted/skill-creator/composable/mini/05-improving-the-skill.md +30 -0
  207. package/assets/skills/converted/skill-creator/composable/mini/06-blind-comparison.md +5 -0
  208. package/assets/skills/converted/skill-creator/composable/mini/07-description-optimization.md +74 -0
  209. package/assets/skills/converted/skill-creator/composable/mini/08-packaging.md +11 -0
  210. package/assets/skills/converted/skill-creator/composable/mini/09-environment-specific.md +38 -0
  211. package/assets/skills/converted/skill-creator/composable/mini/10-scripts-and-references.md +34 -0
  212. package/assets/skills/converted/skill-creator/composable/mini/11-json-schemas.md +414 -0
  213. package/assets/skills/converted/skill-creator/composable/mini/12-agent-grader.md +225 -0
  214. package/assets/skills/converted/skill-creator/composable/mini/13-agent-comparator.md +204 -0
  215. package/assets/skills/converted/skill-creator/composable/mini/14-agent-analyzer.md +276 -0
  216. package/assets/skills/converted/skill-creator/composable/presets/authoring.md +198 -0
  217. package/assets/skills/converted/skill-creator/composable/presets/evaluating.md +1334 -0
  218. package/assets/skills/converted/skill-creator/composable/presets/optimizing.md +160 -0
  219. package/assets/skills/converted/skill-creator/composable/presets.json +5 -0
  220. package/assets/skills/meta/ccs-skill-creator/composable/BUNDLE.md +465 -0
  221. package/assets/skills/meta/ccs-skill-creator/composable/INDEX.md +8 -0
  222. package/assets/skills/meta/ccs-skill-creator/composable/VERSION +1 -0
  223. package/assets/skills/meta/ccs-skill-creator/composable/mini/00-core.md +46 -0
  224. package/assets/skills/meta/ccs-skill-creator/composable/mini/01-create-new-skill.md +167 -0
  225. package/assets/skills/meta/ccs-skill-creator/composable/mini/02-convert-existing-skill.md +120 -0
  226. package/assets/skills/meta/ccs-skill-creator/composable/mini/03-review-and-maintain.md +112 -0
  227. package/assets/skills/sources/anthropic/PROVENANCE.md +3 -0
  228. package/assets/skills/sources/anthropic/claude-api/LICENSE.txt +202 -0
  229. package/assets/skills/sources/anthropic/docx/LICENSE.txt +30 -0
  230. package/assets/skills/sources/anthropic/internal-comms/LICENSE.txt +202 -0
  231. package/assets/skills/sources/anthropic/mcp-builder/LICENSE.txt +202 -0
  232. package/assets/skills/sources/anthropic/pdf/LICENSE.txt +30 -0
  233. package/assets/skills/sources/anthropic/pptx/LICENSE.txt +30 -0
  234. package/assets/skills/sources/anthropic/skill-creator/LICENSE.txt +202 -0
  235. package/assets/skills/sources/financial-analyst/PROVENANCE.md +1 -0
  236. package/assets/tools/hive.py +728 -0
  237. package/dist/cli.js +7494 -0
  238. package/package.json +40 -0
@@ -0,0 +1,1381 @@
1
+ <!-- GENERATED by tools/hive.py compile — do not hand-edit. -->
2
+ # mcp-builder — Compiled Skill Bundle — Preset: node-server (v1.0.0)
3
+
4
+ All composable mini-skills for `mcp-builder` concatenated in index order, frontmatter stripped. Regenerate with `tools/hive.py compile <skill-dir>` — do not edit by hand.
5
+
6
+ ---
7
+ <!-- module: 00-core.md -->
8
+
9
+ # Core: MCP Server Quality Mindset
10
+
11
+ Always-loaded foundation for building high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Load the focused minis (see INDEX) for the workflow, per-standard rules, language-specific code, and evaluations.
12
+
13
+ ## What "quality" means here
14
+
15
+ Create MCP servers that enable LLMs to interact with external services through well-designed tools. **The quality of an MCP server is measured by how well it enables LLMs to accomplish real-world tasks** — NOT by how well or comprehensively the server implements tools. Quality is about how the implementations (input/output schemas, docstrings/descriptions, functionality) enable an LLM, with no other context and access ONLY to the MCP server, to answer realistic and difficult questions and complete real tasks.
16
+
17
+ ## Agent-first tool design (design for the LLM that will call the tools)
18
+
19
+ - **API coverage vs. workflow tools:** Balance comprehensive API endpoint coverage with specialized workflow tools. Workflow tools can be more convenient for specific tasks; comprehensive coverage gives agents flexibility to compose operations. Performance varies by client — some clients benefit from code execution that combines basic tools, others work better with higher-level workflows. **When uncertain, prioritize comprehensive API coverage.**
20
+ - **Tool naming and discoverability:** Clear, descriptive tool names help agents find the right tools quickly. Use consistent prefixes (e.g., `github_create_issue`, `github_list_repos`) and action-oriented naming. (Full naming rules: see the naming mini.)
21
+ - **Tools should enable complete workflows, not just wrap API endpoints.** Tool names should reflect natural task subdivisions.
22
+ - **Keep tool operations focused and atomic.**
23
+
24
+ ## Token-consciousness (context is scarce)
25
+
26
+ - Agents benefit from **concise tool descriptions** and the ability to **filter/paginate** results. Design tools that return **focused, relevant data**.
27
+ - **Response formats should optimize for agent context efficiency.** Omit verbose metadata; return only what the task needs. Some clients support code execution which can help agents filter and process data efficiently.
28
+ - Prefer **human-readable identifiers** where appropriate (display names with IDs, human-readable datetimes) so the agent doesn't waste effort decoding opaque values.
29
+ - Tools that return large JSON objects or lists can overwhelm the LLM — reduce information returned, paginate, and truncate with clear messages.
30
+
31
+ ## Error-message discipline
32
+
33
+ - **Error messages must guide agents toward solutions** with specific suggestions and next steps — clear, actionable, and educational. An error should tell the agent what to do next (e.g., suggest a filter to reduce results, or the correct alternative tool).
34
+ - Descriptions must **precisely and unambiguously match actual functionality** — never over- or under-claim what a tool does.
35
+
36
+ ## Composability / DRY (applies to every implementation)
37
+
38
+ Your implementation MUST prioritize composability and code reuse:
39
+
40
+ 1. **Extract common functionality:** reusable helper functions for operations used across multiple tools; shared API clients for HTTP requests; centralized error-handling logic; business logic in dedicated composable functions; shared markdown/JSON field-selection & formatting.
41
+ 2. **Avoid duplication:** NEVER copy-paste similar code between tools. If you write similar logic twice, extract it into a function. Common operations (pagination, filtering, field selection, formatting) should be shared. Authentication/authorization logic should be centralized.
42
+
43
+ ## Strategic design checklist (cross-cutting — verify on every server)
44
+
45
+ - [ ] Tools enable complete workflows, not just API endpoint wrappers
46
+ - [ ] Tool names reflect natural task subdivisions
47
+ - [ ] Response formats optimize for agent context efficiency
48
+ - [ ] Human-readable identifiers used where appropriate
49
+ - [ ] Error messages guide agents toward correct usage
50
+
51
+ (Language-specific implementation and code-quality checklists live in the Python and Node minis.)
52
+
53
+ ---
54
+ <!-- module: 01-workflow-research-planning.md -->
55
+
56
+ # Workflow, Research & Planning (Phase 1)
57
+
58
+ Creating a high-quality MCP server involves **four main phases**: (1) Deep Research and Planning, (2) Implementation, (3) Review and Test, (4) Create Evaluations. This mini covers Phase 1 and how to navigate the reference documentation.
59
+
60
+ ## Phase 1: Deep Research and Planning
61
+
62
+ ### 1.1 Understand modern MCP design
63
+
64
+ The core design tensions (agent-first design, API coverage vs. workflow tools, naming/discoverability, context management, actionable errors) are covered in `00-core.md`. Internalize those before designing tools.
65
+
66
+ ### 1.2 Study MCP protocol documentation
67
+
68
+ Navigate the MCP specification:
69
+ - Start with the sitemap to find relevant pages: `https://modelcontextprotocol.io/sitemap.xml`
70
+ - Then fetch specific pages with a `.md` suffix for markdown format (e.g., `https://modelcontextprotocol.io/specification/draft.md`).
71
+
72
+ Key pages to review:
73
+ - Specification overview and architecture
74
+ - Transport mechanisms (streamable HTTP, stdio)
75
+ - Tool, resource, and prompt definitions
76
+
77
+ ### 1.3 Study framework documentation
78
+
79
+ **Recommended stack:**
80
+ - **Language: TypeScript** — high-quality SDK support and good compatibility in many execution environments (e.g. MCPB). AI models are good at generating TypeScript code, benefiting from its broad usage, static typing, and good linting tools.
81
+ - **Transport: Streamable HTTP** for remote servers, using **stateless JSON** (simpler to scale and maintain, as opposed to stateful sessions and streaming responses). **stdio** for local servers.
82
+
83
+ **Load framework documentation:**
84
+ - **MCP Best Practices** — core universal guidelines (see the naming, response-format, pagination, transport, security, annotations, error-handling, and testing minis).
85
+ - **For TypeScript (recommended):** Use WebFetch to load the TypeScript SDK README: `https://raw.githubusercontent.com/modelcontextprotocol/typescript-sdk/main/README.md`. Then use the Node/TypeScript implementation minis.
86
+ - **For Python:** Use WebFetch to load the Python SDK README: `https://raw.githubusercontent.com/modelcontextprotocol/python-sdk/main/README.md`. Then use the Python implementation minis.
87
+
88
+ ### 1.4 Plan your implementation
89
+
90
+ - **Understand the API:** Review the service's API documentation to identify key endpoints, authentication requirements, and data models. Use web search and WebFetch as needed.
91
+ - **Tool selection:** Prioritize comprehensive API coverage. List the endpoints to implement, starting with the most common operations.
92
+
93
+ ## Documentation library — what to load and when
94
+
95
+ **Core MCP documentation (load first):**
96
+ - MCP Protocol: start with the sitemap at `https://modelcontextprotocol.io/sitemap.xml`, then fetch specific pages with `.md` suffix.
97
+ - MCP Best Practices — universal guidelines including server/tool naming conventions, response format (JSON vs Markdown), pagination, transport selection (streamable HTTP vs stdio), security, and error handling.
98
+
99
+ **SDK documentation (load during Phase 1/2):**
100
+ - Python SDK: `https://raw.githubusercontent.com/modelcontextprotocol/python-sdk/main/README.md`
101
+ - TypeScript SDK: `https://raw.githubusercontent.com/modelcontextprotocol/typescript-sdk/main/README.md`
102
+
103
+ **Language-specific implementation guides (load during Phase 2):**
104
+ - Python (FastMCP): server initialization, Pydantic models, tool registration with `@mcp.tool`, complete working examples, quality checklist.
105
+ - TypeScript: project structure, Zod schema patterns, tool registration with `server.registerTool`, complete working examples, quality checklist.
106
+
107
+ **Evaluation guide (load during Phase 4):** question creation guidelines, answer verification strategies, XML format, example questions/answers, and running an evaluation with the provided scripts.
108
+
109
+ The remaining phases: Phase 2 (Implementation) and Phase 3 (Review and Test) — see `02-implementation-process.md`. Phase 4 (Create Evaluations) — see the evaluation minis.
110
+
111
+ ---
112
+ <!-- module: 02-implementation-process.md -->
113
+
114
+ # Implementation & Review Process (Phases 2–3)
115
+
116
+ Language-agnostic steps for building and then reviewing/testing the server. Use alongside the language-specific minis (Python or Node) for the actual code.
117
+
118
+ ## Phase 2: Implementation
119
+
120
+ ### 2.1 Set up project structure
121
+
122
+ See the language-specific minis for project setup:
123
+ - TypeScript: project structure, `package.json`, `tsconfig.json`.
124
+ - Python: module organization, dependencies.
125
+
126
+ ### 2.2 Implement core infrastructure
127
+
128
+ Create shared utilities:
129
+ - API client with authentication
130
+ - Error handling helpers
131
+ - Response formatting (JSON/Markdown)
132
+ - Pagination support
133
+
134
+ ### 2.3 Implement tools
135
+
136
+ For each tool:
137
+
138
+ **Input schema:**
139
+ - Use Zod (TypeScript) or Pydantic (Python)
140
+ - Include constraints and clear descriptions
141
+ - Add examples in field descriptions
142
+
143
+ **Output schema:**
144
+ - Define `outputSchema` where possible for structured data
145
+ - Use `structuredContent` in tool responses (TypeScript SDK feature)
146
+ - Helps clients understand and process tool outputs
147
+
148
+ **Tool description:**
149
+ - Concise summary of functionality
150
+ - Parameter descriptions
151
+ - Return type schema
152
+
153
+ **Implementation:**
154
+ - Async/await for I/O operations
155
+ - Proper error handling with actionable messages
156
+ - Support pagination where applicable
157
+ - Return both text content and structured data when using modern SDKs
158
+
159
+ **Annotations:**
160
+ - `readOnlyHint`: true/false
161
+ - `destructiveHint`: true/false
162
+ - `idempotentHint`: true/false
163
+ - `openWorldHint`: true/false
164
+
165
+ (Full annotation semantics: see the annotations mini.)
166
+
167
+ ## Phase 3: Review and Test
168
+
169
+ ### 3.1 Code quality
170
+
171
+ Review for:
172
+ - No duplicated code (DRY principle)
173
+ - Consistent error handling
174
+ - Full type coverage
175
+ - Clear tool descriptions
176
+
177
+ ### 3.2 Build and test
178
+
179
+ **TypeScript:**
180
+ - Run `npm run build` to verify compilation
181
+ - Test with MCP Inspector: `npx @modelcontextprotocol/inspector`
182
+
183
+ **Python:**
184
+ - Verify syntax: `python -m py_compile your_server.py`
185
+ - Test with MCP Inspector
186
+
187
+ See the language-specific minis for detailed testing approaches and quality checklists.
188
+
189
+ ## Phase 4: Create Evaluations
190
+
191
+ After implementing your MCP server, create comprehensive evaluations to test its effectiveness. Use evaluations to test whether LLMs can effectively use your MCP server to answer realistic, complex questions. The process (10 questions: tool inspection → content exploration → question generation → answer verification) and the harness for running them are covered in the evaluation minis.
192
+
193
+ ---
194
+ <!-- module: 03-naming-conventions.md -->
195
+
196
+ # Naming Conventions (Server & Tools)
197
+
198
+ ## Server naming
199
+
200
+ Follow these standardized naming patterns:
201
+
202
+ - **Python:** `{service}_mcp` (lowercase with underscores) — e.g., `slack_mcp`, `github_mcp`, `jira_mcp`, `stripe_mcp`.
203
+ - **Node/TypeScript:** `{service}-mcp-server` (lowercase with hyphens) — e.g., `slack-mcp-server`, `github-mcp-server`, `jira-mcp-server`, `stripe-mcp-server`.
204
+
205
+ The name should be:
206
+ - **General** — descriptive of the service being integrated, not tied to specific features.
207
+ - **Descriptive** of the service/API being integrated.
208
+ - **Easy to infer** from the task description.
209
+ - **Without version numbers** or dates.
210
+
211
+ ## Tool naming
212
+
213
+ 1. **Use snake_case:** `search_users`, `create_project`, `get_channel_info`.
214
+ 2. **Include service prefix** — anticipate that your MCP server may be used alongside other MCP servers, so include the service context to prevent overlaps:
215
+ - Use `slack_send_message` instead of just `send_message`
216
+ - Use `github_create_issue` instead of just `create_issue`
217
+ - Use `asana_list_tasks` instead of just `list_tasks`
218
+ 3. **Be action-oriented:** start with verbs (get, list, search, create, etc.).
219
+ 4. **Be specific:** avoid generic names that could conflict with other servers.
220
+
221
+ Format: `{service}_{action}_{resource}` — e.g., `slack_send_message`, `github_create_issue`.
222
+
223
+ ## Tool design
224
+
225
+ - Tool descriptions must **narrowly and unambiguously** describe functionality.
226
+ - Descriptions must **precisely match actual functionality**.
227
+ - Provide tool annotations (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`) — see the annotations mini.
228
+ - Keep tool operations **focused and atomic**.
229
+
230
+ ---
231
+ <!-- module: 04-response-formats.md -->
232
+
233
+ # Response Formats (JSON vs Markdown)
234
+
235
+ All tools that return data should support **multiple formats**, typically via a `response_format` parameter that defaults to markdown. JSON is for programmatic processing; Markdown is for human readability.
236
+
237
+ ## JSON format (`response_format="json"`)
238
+
239
+ - Machine-readable structured data
240
+ - Return complete, structured data suitable for programmatic processing
241
+ - Include all available fields and metadata
242
+ - Use consistent field names and types
243
+
244
+ ## Markdown format (`response_format="markdown"`, typically the default)
245
+
246
+ - Human-readable formatted text
247
+ - Use headers, lists, and formatting for clarity
248
+ - Convert timestamps to human-readable format (e.g., "2024-01-15 10:30:00 UTC" instead of epoch)
249
+ - Show display names with IDs in parentheses (e.g., "@john.doe (U123456)")
250
+ - Omit verbose metadata (e.g., show only one profile image URL, not all sizes)
251
+ - Group related information logically
252
+
253
+ (Language-specific code for implementing the `ResponseFormat` enum and formatting both branches lives in the Python and Node minis.)
254
+
255
+ ---
256
+ <!-- module: 05-pagination.md -->
257
+
258
+ # Pagination
259
+
260
+ For tools that list resources:
261
+
262
+ - **Always respect the `limit` parameter.**
263
+ - **Implement pagination:** use `offset` or cursor-based pagination.
264
+ - **Return pagination metadata:** include `has_more`, `next_offset`/`next_cursor`, and `total_count`.
265
+ - **Never load all results into memory** — especially important for large datasets.
266
+ - **Default to reasonable limits:** 20–50 items is typical.
267
+
268
+ Example pagination response:
269
+
270
+ ```json
271
+ {
272
+ "total": 150,
273
+ "count": 20,
274
+ "offset": 0,
275
+ "items": [...],
276
+ "has_more": true,
277
+ "next_offset": 20
278
+ }
279
+ ```
280
+
281
+ (Language-specific pagination code — computing `has_more` and `next_offset` from `total`, `offset`, and returned items — lives in the Python and Node minis.)
282
+
283
+ ---
284
+ <!-- module: 06-transport.md -->
285
+
286
+ # Transport Options
287
+
288
+ Two main transports: **Streamable HTTP** (remote) and **stdio** (local). **Avoid SSE — deprecated in favor of streamable HTTP.**
289
+
290
+ ## Streamable HTTP
291
+
292
+ **Best for:** remote servers, web services, multi-client scenarios.
293
+
294
+ **Characteristics:**
295
+ - Bidirectional communication over HTTP
296
+ - Supports multiple simultaneous clients
297
+ - Can be deployed as a web service
298
+ - Enables server-to-client notifications
299
+
300
+ **Use when:**
301
+ - Serving multiple clients simultaneously
302
+ - Deploying as a cloud service
303
+ - Integrating with web applications
304
+
305
+ For remote servers, prefer **stateless JSON** (simpler to scale and maintain than stateful sessions and streaming responses).
306
+
307
+ ## stdio
308
+
309
+ **Best for:** local integrations, command-line tools.
310
+
311
+ **Characteristics:**
312
+ - Standard input/output stream communication
313
+ - Simple setup, no network configuration needed
314
+ - Runs as a subprocess of the client
315
+
316
+ **Use when:**
317
+ - Building tools for local development environments
318
+ - Integrating with desktop applications
319
+ - Single-user, single-session scenarios
320
+
321
+ **Note:** stdio servers must NOT log to stdout — use stderr for logging.
322
+
323
+ ## Transport selection
324
+
325
+ | Criterion | stdio | Streamable HTTP |
326
+ |-----------|-------|-----------------|
327
+ | **Deployment** | Local | Remote |
328
+ | **Clients** | Single | Multiple |
329
+ | **Complexity** | Low | Medium |
330
+ | **Real-time** | No | Yes |
331
+
332
+ (Language-specific code for wiring up each transport lives in the Python and Node minis.)
333
+
334
+ ---
335
+ <!-- module: 07-annotations.md -->
336
+
337
+ # Tool Annotations
338
+
339
+ Provide annotations to help clients understand tool behavior. Set them on every tool.
340
+
341
+ | Annotation | Type | Default | Description |
342
+ |-----------|------|---------|-------------|
343
+ | `readOnlyHint` | boolean | false | Tool does not modify its environment |
344
+ | `destructiveHint` | boolean | true | Tool may perform destructive updates |
345
+ | `idempotentHint` | boolean | false | Repeated calls with same args have no additional effect |
346
+ | `openWorldHint` | boolean | true | Tool interacts with external entities |
347
+
348
+ **Important:** Annotations are **hints, not security guarantees**. Clients should not make security-critical decisions based solely on annotations.
349
+
350
+ Set each hint to accurately reflect the tool:
351
+ - `readOnlyHint`: true if the tool does not modify environment
352
+ - `destructiveHint`: false if the tool does not perform destructive operations
353
+ - `idempotentHint`: true if repeated calls have no additional effect
354
+ - `openWorldHint`: false if the tool does not interact with external entities
355
+
356
+ (Language-specific syntax — the `annotations={...}` dict in the `@mcp.tool` decorator for Python, and the `annotations` object in `registerTool` for Node — lives in the language minis.)
357
+
358
+ ---
359
+ <!-- module: 08-security.md -->
360
+
361
+ # Security Best Practices
362
+
363
+ ## Authentication and Authorization
364
+
365
+ **OAuth 2.1:**
366
+ - Use secure OAuth 2.1 with certificates from recognized authorities
367
+ - Validate access tokens before processing requests
368
+ - Only accept tokens specifically intended for your server
369
+
370
+ **API Keys:**
371
+ - Store API keys in environment variables, never in code
372
+ - Validate keys on server startup
373
+ - Provide clear error messages when authentication fails
374
+
375
+ ## Input Validation
376
+
377
+ - Sanitize file paths to prevent directory traversal
378
+ - Validate URLs and external identifiers
379
+ - Check parameter sizes and ranges
380
+ - Prevent command injection in system calls
381
+ - Use schema validation (Pydantic/Zod) for all inputs
382
+
383
+ ## Error Handling (security angle)
384
+
385
+ - Don't expose internal errors to clients
386
+ - Log security-relevant errors server-side
387
+ - Provide helpful but not revealing error messages
388
+ - Clean up resources after errors
389
+
390
+ ## DNS Rebinding Protection
391
+
392
+ For streamable HTTP servers running locally:
393
+ - Enable DNS rebinding protection
394
+ - Validate the `Origin` header on all incoming connections
395
+ - Bind to `127.0.0.1` rather than `0.0.0.0`
396
+
397
+ ---
398
+ <!-- module: 09-error-handling.md -->
399
+
400
+ # Error Handling Standards
401
+
402
+ General, cross-language error-handling standards. Language-specific error formatting (`_handle_api_error` in Python, `handleApiError` in Node, mapping 404/403/429/timeout to messages) lives in the language minis.
403
+
404
+ ## Principles
405
+
406
+ - Use standard **JSON-RPC error codes**.
407
+ - **Report tool errors within result objects** (not protocol-level errors).
408
+ - Provide **helpful, specific error messages with suggested next steps**.
409
+ - **Don't expose internal implementation details.**
410
+ - **Clean up resources properly on errors.**
411
+
412
+ Error messages should be clear, actionable, and educational — guiding the agent toward a solution with specific suggestions and next steps.
413
+
414
+ ## Example (TypeScript pattern)
415
+
416
+ ```typescript
417
+ try {
418
+ const result = performOperation();
419
+ return { content: [{ type: "text", text: result }] };
420
+ } catch (error) {
421
+ return {
422
+ isError: true,
423
+ content: [{
424
+ type: "text",
425
+ text: `Error: ${error.message}. Try using filter='active_only' to reduce results.`
426
+ }]
427
+ };
428
+ }
429
+ ```
430
+
431
+ Note how the message not only reports the failure but suggests a concrete next step (`filter='active_only'`) that helps the agent recover.
432
+
433
+ ---
434
+ <!-- module: 10-testing-and-documentation.md -->
435
+
436
+ # Testing & Documentation Requirements
437
+
438
+ General (language-agnostic) requirements. Language-specific build/test commands and quality checklists live in the Python and Node minis; the evaluation harness is covered in the evaluation minis.
439
+
440
+ ## Testing Requirements
441
+
442
+ Comprehensive testing should cover:
443
+
444
+ - **Functional testing:** verify correct execution with valid/invalid inputs.
445
+ - **Integration testing:** test interaction with external systems.
446
+ - **Security testing:** validate auth, input sanitization, rate limiting.
447
+ - **Performance testing:** check behavior under load, timeouts.
448
+ - **Error handling:** ensure proper error reporting and cleanup.
449
+
450
+ ## Documentation Requirements
451
+
452
+ - Provide clear documentation of all tools and capabilities.
453
+ - Include working examples (**at least 3 per major feature**).
454
+ - Document security considerations.
455
+ - Specify required permissions and access levels.
456
+ - Document rate limits and performance characteristics.
457
+
458
+ ---
459
+ <!-- module: 13-node-implementation.md -->
460
+
461
+ # Node/TypeScript — Implementation Patterns
462
+
463
+ Node/TypeScript-specific best practices and code for implementing MCP servers with the MCP TypeScript SDK: project structure, server setup, tool registration, input validation with Zod, error handling, and a complete working example. Server naming (`{service}-mcp-server`) and tool naming are in the naming mini; this mini is the how-in-TypeScript.
464
+
465
+ ## MCP TypeScript SDK
466
+
467
+ The official MCP TypeScript SDK provides:
468
+ - `McpServer` class for server initialization
469
+ - `registerTool` method for tool registration
470
+ - Zod schema integration for runtime input validation
471
+ - Type-safe tool handler implementations
472
+
473
+ **IMPORTANT — Use Modern APIs Only:**
474
+ - **DO use:** `server.registerTool()`, `server.registerResource()`, `server.registerPrompt()`
475
+ - **DO NOT use:** old deprecated APIs such as `server.tool()`, `server.setRequestHandler(ListToolsRequestSchema, ...)`, or manual handler registration.
476
+ - The `register*` methods provide better type safety, automatic schema handling, and are the recommended approach.
477
+
478
+ For complete SDK details use WebFetch: `https://raw.githubusercontent.com/modelcontextprotocol/typescript-sdk/main/README.md`
479
+
480
+ ## Quick Reference
481
+
482
+ ### Key imports
483
+ ```typescript
484
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
485
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
486
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
487
+ import express from "express";
488
+ import { z } from "zod";
489
+ ```
490
+
491
+ ### Server initialization
492
+ ```typescript
493
+ const server = new McpServer({
494
+ name: "service-mcp-server",
495
+ version: "1.0.0"
496
+ });
497
+ ```
498
+
499
+ ### Tool registration pattern
500
+ ```typescript
501
+ server.registerTool(
502
+ "tool_name",
503
+ {
504
+ title: "Tool Display Name",
505
+ description: "What the tool does",
506
+ inputSchema: { param: z.string() },
507
+ outputSchema: { result: z.string() }
508
+ },
509
+ async ({ param }) => {
510
+ const output = { result: `Processed: ${param}` };
511
+ return {
512
+ content: [{ type: "text", text: JSON.stringify(output) }],
513
+ structuredContent: output // Modern pattern for structured data
514
+ };
515
+ }
516
+ );
517
+ ```
518
+
519
+ ## Project Structure
520
+
521
+ ```
522
+ {service}-mcp-server/
523
+ ├── package.json
524
+ ├── tsconfig.json
525
+ ├── README.md
526
+ ├── src/
527
+ │ ├── index.ts # Main entry point with McpServer initialization
528
+ │ ├── types.ts # TypeScript type definitions and interfaces
529
+ │ ├── tools/ # Tool implementations (one file per domain)
530
+ │ ├── services/ # API clients and shared utilities
531
+ │ ├── schemas/ # Zod validation schemas
532
+ │ └── constants.ts # Shared constants (API_URL, CHARACTER_LIMIT, etc.)
533
+ └── dist/ # Built JavaScript files (entry point: dist/index.js)
534
+ ```
535
+
536
+ ## Tool Structure
537
+
538
+ Use snake_case, action-oriented tool names with a service prefix (e.g., `slack_send_message`, `github_create_issue`, `asana_list_tasks`). Tools are registered using `registerTool`:
539
+ - Use Zod schemas for runtime input validation and type safety.
540
+ - The `description` field must be explicitly provided — JSDoc comments are NOT automatically extracted.
541
+ - Explicitly provide `title`, `description`, `inputSchema`, and `annotations`.
542
+ - The `inputSchema` must be a Zod schema object (not a JSON schema).
543
+ - Type all parameters and return values explicitly.
544
+
545
+ ```typescript
546
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
547
+ import { z } from "zod";
548
+
549
+ const server = new McpServer({
550
+ name: "example-mcp",
551
+ version: "1.0.0"
552
+ });
553
+
554
+ // Zod schema for input validation
555
+ const UserSearchInputSchema = z.object({
556
+ query: z.string()
557
+ .min(2, "Query must be at least 2 characters")
558
+ .max(200, "Query must not exceed 200 characters")
559
+ .describe("Search string to match against names/emails"),
560
+ limit: z.number()
561
+ .int()
562
+ .min(1)
563
+ .max(100)
564
+ .default(20)
565
+ .describe("Maximum results to return"),
566
+ offset: z.number()
567
+ .int()
568
+ .min(0)
569
+ .default(0)
570
+ .describe("Number of results to skip for pagination"),
571
+ response_format: z.nativeEnum(ResponseFormat)
572
+ .default(ResponseFormat.MARKDOWN)
573
+ .describe("Output format: 'markdown' for human-readable or 'json' for machine-readable")
574
+ }).strict();
575
+
576
+ // Type definition from Zod schema
577
+ type UserSearchInput = z.infer<typeof UserSearchInputSchema>;
578
+
579
+ server.registerTool(
580
+ "example_search_users",
581
+ {
582
+ title: "Search Example Users",
583
+ description: `Search for users in the Example system by name, email, or team.
584
+
585
+ This tool searches across all user profiles in the Example platform, supporting partial matches and various search filters. It does NOT create or modify users, only searches existing ones.
586
+
587
+ Args:
588
+ - query (string): Search string to match against names/emails
589
+ - limit (number): Maximum results to return, between 1-100 (default: 20)
590
+ - offset (number): Number of results to skip for pagination (default: 0)
591
+ - response_format ('markdown' | 'json'): Output format (default: 'markdown')
592
+
593
+ Returns:
594
+ For JSON format: Structured data with schema:
595
+ {
596
+ "total": number, // Total number of matches found
597
+ "count": number, // Number of results in this response
598
+ "offset": number, // Current pagination offset
599
+ "users": [
600
+ {
601
+ "id": string, // User ID (e.g., "U123456789")
602
+ "name": string, // Full name (e.g., "John Doe")
603
+ "email": string, // Email address
604
+ "team": string, // Team name (optional)
605
+ "active": boolean // Whether user is active
606
+ }
607
+ ],
608
+ "has_more": boolean, // Whether more results are available
609
+ "next_offset": number // Offset for next page (if has_more is true)
610
+ }
611
+
612
+ Examples:
613
+ - Use when: "Find all marketing team members" -> params with query="team:marketing"
614
+ - Use when: "Search for John's account" -> params with query="john"
615
+ - Don't use when: You need to create a user (use example_create_user instead)
616
+
617
+ Error Handling:
618
+ - Returns "Error: Rate limit exceeded" if too many requests (429 status)
619
+ - Returns "No users found matching '<query>'" if search returns empty`,
620
+ inputSchema: UserSearchInputSchema,
621
+ annotations: {
622
+ readOnlyHint: true,
623
+ destructiveHint: false,
624
+ idempotentHint: true,
625
+ openWorldHint: true
626
+ }
627
+ },
628
+ async (params: UserSearchInput) => {
629
+ try {
630
+ // Input validation is handled by Zod schema
631
+ // Make API request using validated parameters
632
+ const data = await makeApiRequest<any>(
633
+ "users/search",
634
+ "GET",
635
+ undefined,
636
+ {
637
+ q: params.query,
638
+ limit: params.limit,
639
+ offset: params.offset
640
+ }
641
+ );
642
+
643
+ const users = data.users || [];
644
+ const total = data.total || 0;
645
+
646
+ if (!users.length) {
647
+ return {
648
+ content: [{
649
+ type: "text",
650
+ text: `No users found matching '${params.query}'`
651
+ }]
652
+ };
653
+ }
654
+
655
+ // Prepare structured output
656
+ const output = {
657
+ total,
658
+ count: users.length,
659
+ offset: params.offset,
660
+ users: users.map((user: any) => ({
661
+ id: user.id,
662
+ name: user.name,
663
+ email: user.email,
664
+ ...(user.team ? { team: user.team } : {}),
665
+ active: user.active ?? true
666
+ })),
667
+ has_more: total > params.offset + users.length,
668
+ ...(total > params.offset + users.length ? {
669
+ next_offset: params.offset + users.length
670
+ } : {})
671
+ };
672
+
673
+ // Format text representation based on requested format
674
+ let textContent: string;
675
+ if (params.response_format === ResponseFormat.MARKDOWN) {
676
+ const lines = [`# User Search Results: '${params.query}'`, "",
677
+ `Found ${total} users (showing ${users.length})`, ""];
678
+ for (const user of users) {
679
+ lines.push(`## ${user.name} (${user.id})`);
680
+ lines.push(`- **Email**: ${user.email}`);
681
+ if (user.team) lines.push(`- **Team**: ${user.team}`);
682
+ lines.push("");
683
+ }
684
+ textContent = lines.join("\n");
685
+ } else {
686
+ textContent = JSON.stringify(output, null, 2);
687
+ }
688
+
689
+ return {
690
+ content: [{ type: "text", text: textContent }],
691
+ structuredContent: output // Modern pattern for structured data
692
+ };
693
+ } catch (error) {
694
+ return {
695
+ content: [{
696
+ type: "text",
697
+ text: handleApiError(error)
698
+ }]
699
+ };
700
+ }
701
+ }
702
+ );
703
+ ```
704
+
705
+ ## Zod Schemas for Input Validation
706
+
707
+ Zod provides runtime type validation:
708
+
709
+ ```typescript
710
+ import { z } from "zod";
711
+
712
+ // Basic schema with validation
713
+ const CreateUserSchema = z.object({
714
+ name: z.string()
715
+ .min(1, "Name is required")
716
+ .max(100, "Name must not exceed 100 characters"),
717
+ email: z.string()
718
+ .email("Invalid email format"),
719
+ age: z.number()
720
+ .int("Age must be a whole number")
721
+ .min(0, "Age cannot be negative")
722
+ .max(150, "Age cannot be greater than 150")
723
+ }).strict(); // Use .strict() to forbid extra fields
724
+
725
+ // Enums
726
+ enum ResponseFormat {
727
+ MARKDOWN = "markdown",
728
+ JSON = "json"
729
+ }
730
+
731
+ const SearchSchema = z.object({
732
+ response_format: z.nativeEnum(ResponseFormat)
733
+ .default(ResponseFormat.MARKDOWN)
734
+ .describe("Output format")
735
+ });
736
+
737
+ // Optional fields with defaults
738
+ const PaginationSchema = z.object({
739
+ limit: z.number()
740
+ .int()
741
+ .min(1)
742
+ .max(100)
743
+ .default(20)
744
+ .describe("Maximum results to return"),
745
+ offset: z.number()
746
+ .int()
747
+ .min(0)
748
+ .default(0)
749
+ .describe("Number of results to skip")
750
+ });
751
+ ```
752
+
753
+ ## Response Format Options
754
+
755
+ Support multiple output formats for flexibility (concept in the response-formats mini):
756
+
757
+ ```typescript
758
+ enum ResponseFormat {
759
+ MARKDOWN = "markdown",
760
+ JSON = "json"
761
+ }
762
+
763
+ const inputSchema = z.object({
764
+ query: z.string(),
765
+ response_format: z.nativeEnum(ResponseFormat)
766
+ .default(ResponseFormat.MARKDOWN)
767
+ .describe("Output format: 'markdown' for human-readable or 'json' for machine-readable")
768
+ });
769
+ ```
770
+
771
+ **Markdown format:** use headers, lists, and formatting for clarity; convert timestamps to human-readable format; show display names with IDs in parentheses; omit verbose metadata; group related information logically.
772
+
773
+ **JSON format:** return complete, structured data suitable for programmatic processing; include all available fields and metadata; use consistent field names and types.
774
+
775
+ ## Pagination Implementation
776
+
777
+ ```typescript
778
+ const ListSchema = z.object({
779
+ limit: z.number().int().min(1).max(100).default(20),
780
+ offset: z.number().int().min(0).default(0)
781
+ });
782
+
783
+ async function listItems(params: z.infer<typeof ListSchema>) {
784
+ const data = await apiRequest(params.limit, params.offset);
785
+
786
+ const response = {
787
+ total: data.total,
788
+ count: data.items.length,
789
+ offset: params.offset,
790
+ items: data.items,
791
+ has_more: data.total > params.offset + data.items.length,
792
+ next_offset: data.total > params.offset + data.items.length
793
+ ? params.offset + data.items.length
794
+ : undefined
795
+ };
796
+
797
+ return JSON.stringify(response, null, 2);
798
+ }
799
+ ```
800
+
801
+ ## Character Limits and Truncation
802
+
803
+ Add a CHARACTER_LIMIT constant to prevent overwhelming responses:
804
+
805
+ ```typescript
806
+ // At module level in constants.ts
807
+ export const CHARACTER_LIMIT = 25000; // Maximum response size in characters
808
+
809
+ async function searchTool(params: SearchInput) {
810
+ let result = generateResponse(data);
811
+
812
+ // Check character limit and truncate if needed
813
+ if (result.length > CHARACTER_LIMIT) {
814
+ const truncatedData = data.slice(0, Math.max(1, data.length / 2));
815
+ response.data = truncatedData;
816
+ response.truncated = true;
817
+ response.truncation_message =
818
+ `Response truncated from ${data.length} to ${truncatedData.length} items. ` +
819
+ `Use 'offset' parameter or add filters to see more results.`;
820
+ result = JSON.stringify(response, null, 2);
821
+ }
822
+
823
+ return result;
824
+ }
825
+ ```
826
+
827
+ ## Error Handling
828
+
829
+ Provide clear, actionable error messages:
830
+
831
+ ```typescript
832
+ import axios, { AxiosError } from "axios";
833
+
834
+ function handleApiError(error: unknown): string {
835
+ if (error instanceof AxiosError) {
836
+ if (error.response) {
837
+ switch (error.response.status) {
838
+ case 404:
839
+ return "Error: Resource not found. Please check the ID is correct.";
840
+ case 403:
841
+ return "Error: Permission denied. You don't have access to this resource.";
842
+ case 429:
843
+ return "Error: Rate limit exceeded. Please wait before making more requests.";
844
+ default:
845
+ return `Error: API request failed with status ${error.response.status}`;
846
+ }
847
+ } else if (error.code === "ECONNABORTED") {
848
+ return "Error: Request timed out. Please try again.";
849
+ }
850
+ }
851
+ return `Error: Unexpected error occurred: ${error instanceof Error ? error.message : String(error)}`;
852
+ }
853
+ ```
854
+
855
+ ## Shared Utilities
856
+
857
+ Extract common functionality into reusable functions:
858
+
859
+ ```typescript
860
+ // Shared API request function
861
+ async function makeApiRequest<T>(
862
+ endpoint: string,
863
+ method: "GET" | "POST" | "PUT" | "DELETE" = "GET",
864
+ data?: any,
865
+ params?: any
866
+ ): Promise<T> {
867
+ try {
868
+ const response = await axios({
869
+ method,
870
+ url: `${API_BASE_URL}/${endpoint}`,
871
+ data,
872
+ params,
873
+ timeout: 30000,
874
+ headers: {
875
+ "Content-Type": "application/json",
876
+ "Accept": "application/json"
877
+ }
878
+ });
879
+ return response.data;
880
+ } catch (error) {
881
+ throw error;
882
+ }
883
+ }
884
+ ```
885
+
886
+ ## Async/Await Best Practices
887
+
888
+ Always use async/await for network requests and I/O operations:
889
+
890
+ ```typescript
891
+ // Good: Async network request
892
+ async function fetchData(resourceId: string): Promise<ResourceData> {
893
+ const response = await axios.get(`${API_URL}/resource/${resourceId}`);
894
+ return response.data;
895
+ }
896
+
897
+ // Bad: Promise chains
898
+ function fetchData(resourceId: string): Promise<ResourceData> {
899
+ return axios.get(`${API_URL}/resource/${resourceId}`)
900
+ .then(response => response.data); // Harder to read and maintain
901
+ }
902
+ ```
903
+
904
+ ## TypeScript Best Practices
905
+
906
+ 1. **Use Strict TypeScript:** enable strict mode in tsconfig.json.
907
+ 2. **Define Interfaces:** create clear interface definitions for all data structures.
908
+ 3. **Avoid `any`:** use proper types or `unknown` instead of `any`.
909
+ 4. **Zod for Runtime Validation:** use Zod schemas to validate external data.
910
+ 5. **Type Guards:** create type guard functions for complex type checking.
911
+ 6. **Error Handling:** always use try-catch with proper error type checking.
912
+ 7. **Null Safety:** use optional chaining (`?.`) and nullish coalescing (`??`).
913
+
914
+ ```typescript
915
+ // Good: Type-safe with Zod and interfaces
916
+ interface UserResponse {
917
+ id: string;
918
+ name: string;
919
+ email: string;
920
+ team?: string;
921
+ active: boolean;
922
+ }
923
+
924
+ const UserSchema = z.object({
925
+ id: z.string(),
926
+ name: z.string(),
927
+ email: z.string().email(),
928
+ team: z.string().optional(),
929
+ active: z.boolean()
930
+ });
931
+
932
+ type User = z.infer<typeof UserSchema>;
933
+
934
+ async function getUser(id: string): Promise<User> {
935
+ const data = await apiCall(`/users/${id}`);
936
+ return UserSchema.parse(data); // Runtime validation
937
+ }
938
+
939
+ // Bad: Using any
940
+ async function getUser(id: string): Promise<any> {
941
+ return await apiCall(`/users/${id}`); // No type safety
942
+ }
943
+ ```
944
+
945
+ ## Package Configuration
946
+
947
+ ### package.json
948
+
949
+ ```json
950
+ {
951
+ "name": "{service}-mcp-server",
952
+ "version": "1.0.0",
953
+ "description": "MCP server for {Service} API integration",
954
+ "type": "module",
955
+ "main": "dist/index.js",
956
+ "scripts": {
957
+ "start": "node dist/index.js",
958
+ "dev": "tsx watch src/index.ts",
959
+ "build": "tsc",
960
+ "clean": "rm -rf dist"
961
+ },
962
+ "engines": {
963
+ "node": ">=18"
964
+ },
965
+ "dependencies": {
966
+ "@modelcontextprotocol/sdk": "^1.6.1",
967
+ "axios": "^1.7.9",
968
+ "zod": "^3.23.8"
969
+ },
970
+ "devDependencies": {
971
+ "@types/node": "^22.10.0",
972
+ "tsx": "^4.19.2",
973
+ "typescript": "^5.7.2"
974
+ }
975
+ }
976
+ ```
977
+
978
+ ### tsconfig.json
979
+
980
+ ```json
981
+ {
982
+ "compilerOptions": {
983
+ "target": "ES2022",
984
+ "module": "Node16",
985
+ "moduleResolution": "Node16",
986
+ "lib": ["ES2022"],
987
+ "outDir": "./dist",
988
+ "rootDir": "./src",
989
+ "strict": true,
990
+ "esModuleInterop": true,
991
+ "skipLibCheck": true,
992
+ "forceConsistentCasingInFileNames": true,
993
+ "declaration": true,
994
+ "declarationMap": true,
995
+ "sourceMap": true,
996
+ "allowSyntheticDefaultImports": true
997
+ },
998
+ "include": ["src/**/*"],
999
+ "exclude": ["node_modules", "dist"]
1000
+ }
1001
+ ```
1002
+
1003
+ ## Complete Example
1004
+
1005
+ ```typescript
1006
+ #!/usr/bin/env node
1007
+ /**
1008
+ * MCP Server for Example Service.
1009
+ *
1010
+ * This server provides tools to interact with Example API, including user search,
1011
+ * project management, and data export capabilities.
1012
+ */
1013
+
1014
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
1015
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
1016
+ import { z } from "zod";
1017
+ import axios, { AxiosError } from "axios";
1018
+
1019
+ // Constants
1020
+ const API_BASE_URL = "https://api.example.com/v1";
1021
+ const CHARACTER_LIMIT = 25000;
1022
+
1023
+ // Enums
1024
+ enum ResponseFormat {
1025
+ MARKDOWN = "markdown",
1026
+ JSON = "json"
1027
+ }
1028
+
1029
+ // Zod schemas
1030
+ const UserSearchInputSchema = z.object({
1031
+ query: z.string()
1032
+ .min(2, "Query must be at least 2 characters")
1033
+ .max(200, "Query must not exceed 200 characters")
1034
+ .describe("Search string to match against names/emails"),
1035
+ limit: z.number()
1036
+ .int()
1037
+ .min(1)
1038
+ .max(100)
1039
+ .default(20)
1040
+ .describe("Maximum results to return"),
1041
+ offset: z.number()
1042
+ .int()
1043
+ .min(0)
1044
+ .default(0)
1045
+ .describe("Number of results to skip for pagination"),
1046
+ response_format: z.nativeEnum(ResponseFormat)
1047
+ .default(ResponseFormat.MARKDOWN)
1048
+ .describe("Output format: 'markdown' for human-readable or 'json' for machine-readable")
1049
+ }).strict();
1050
+
1051
+ type UserSearchInput = z.infer<typeof UserSearchInputSchema>;
1052
+
1053
+ // Shared utility functions
1054
+ async function makeApiRequest<T>(
1055
+ endpoint: string,
1056
+ method: "GET" | "POST" | "PUT" | "DELETE" = "GET",
1057
+ data?: any,
1058
+ params?: any
1059
+ ): Promise<T> {
1060
+ try {
1061
+ const response = await axios({
1062
+ method,
1063
+ url: `${API_BASE_URL}/${endpoint}`,
1064
+ data,
1065
+ params,
1066
+ timeout: 30000,
1067
+ headers: {
1068
+ "Content-Type": "application/json",
1069
+ "Accept": "application/json"
1070
+ }
1071
+ });
1072
+ return response.data;
1073
+ } catch (error) {
1074
+ throw error;
1075
+ }
1076
+ }
1077
+
1078
+ function handleApiError(error: unknown): string {
1079
+ if (error instanceof AxiosError) {
1080
+ if (error.response) {
1081
+ switch (error.response.status) {
1082
+ case 404:
1083
+ return "Error: Resource not found. Please check the ID is correct.";
1084
+ case 403:
1085
+ return "Error: Permission denied. You don't have access to this resource.";
1086
+ case 429:
1087
+ return "Error: Rate limit exceeded. Please wait before making more requests.";
1088
+ default:
1089
+ return `Error: API request failed with status ${error.response.status}`;
1090
+ }
1091
+ } else if (error.code === "ECONNABORTED") {
1092
+ return "Error: Request timed out. Please try again.";
1093
+ }
1094
+ }
1095
+ return `Error: Unexpected error occurred: ${error instanceof Error ? error.message : String(error)}`;
1096
+ }
1097
+
1098
+ // Create MCP server instance
1099
+ const server = new McpServer({
1100
+ name: "example-mcp",
1101
+ version: "1.0.0"
1102
+ });
1103
+
1104
+ // Register tools
1105
+ server.registerTool(
1106
+ "example_search_users",
1107
+ {
1108
+ title: "Search Example Users",
1109
+ description: `[Full description as shown above]`,
1110
+ inputSchema: UserSearchInputSchema,
1111
+ annotations: {
1112
+ readOnlyHint: true,
1113
+ destructiveHint: false,
1114
+ idempotentHint: true,
1115
+ openWorldHint: true
1116
+ }
1117
+ },
1118
+ async (params: UserSearchInput) => {
1119
+ // Implementation as shown above
1120
+ }
1121
+ );
1122
+
1123
+ // Main function
1124
+ // For stdio (local):
1125
+ async function runStdio() {
1126
+ if (!process.env.EXAMPLE_API_KEY) {
1127
+ console.error("ERROR: EXAMPLE_API_KEY environment variable is required");
1128
+ process.exit(1);
1129
+ }
1130
+
1131
+ const transport = new StdioServerTransport();
1132
+ await server.connect(transport);
1133
+ console.error("MCP server running via stdio");
1134
+ }
1135
+
1136
+ // For streamable HTTP (remote):
1137
+ async function runHTTP() {
1138
+ if (!process.env.EXAMPLE_API_KEY) {
1139
+ console.error("ERROR: EXAMPLE_API_KEY environment variable is required");
1140
+ process.exit(1);
1141
+ }
1142
+
1143
+ const app = express();
1144
+ app.use(express.json());
1145
+
1146
+ app.post('/mcp', async (req, res) => {
1147
+ const transport = new StreamableHTTPServerTransport({
1148
+ sessionIdGenerator: undefined,
1149
+ enableJsonResponse: true
1150
+ });
1151
+ res.on('close', () => transport.close());
1152
+ await server.connect(transport);
1153
+ await transport.handleRequest(req, res, req.body);
1154
+ });
1155
+
1156
+ const port = parseInt(process.env.PORT || '3000');
1157
+ app.listen(port, () => {
1158
+ console.error(`MCP server running on http://localhost:${port}/mcp`);
1159
+ });
1160
+ }
1161
+
1162
+ // Choose transport based on environment
1163
+ const transport = process.env.TRANSPORT || 'stdio';
1164
+ if (transport === 'http') {
1165
+ runHTTP().catch(error => {
1166
+ console.error("Server error:", error);
1167
+ process.exit(1);
1168
+ });
1169
+ } else {
1170
+ runStdio().catch(error => {
1171
+ console.error("Server error:", error);
1172
+ process.exit(1);
1173
+ });
1174
+ }
1175
+ ```
1176
+
1177
+ Advanced MCP features (resources, transport, notifications), build/run commands, and the quality checklist are in `14-node-advanced-and-checklist.md`.
1178
+
1179
+ ---
1180
+ <!-- module: 14-node-advanced-and-checklist.md -->
1181
+
1182
+ # Node/TypeScript — Advanced Features, Build & Quality Checklist
1183
+
1184
+ Continues `13-node-implementation.md`. Advanced MCP features, building/running, and the finalization checklist.
1185
+
1186
+ ## Advanced MCP Features
1187
+
1188
+ ### Resource Registration
1189
+
1190
+ Expose data as resources for efficient, URI-based access:
1191
+
1192
+ ```typescript
1193
+ import { ResourceTemplate } from "@modelcontextprotocol/sdk/types.js";
1194
+
1195
+ // Register a resource with URI template
1196
+ server.registerResource(
1197
+ {
1198
+ uri: "file://documents/{name}",
1199
+ name: "Document Resource",
1200
+ description: "Access documents by name",
1201
+ mimeType: "text/plain"
1202
+ },
1203
+ async (uri: string) => {
1204
+ // Extract parameter from URI
1205
+ const match = uri.match(/^file:\/\/documents\/(.+)$/);
1206
+ if (!match) {
1207
+ throw new Error("Invalid URI format");
1208
+ }
1209
+
1210
+ const documentName = match[1];
1211
+ const content = await loadDocument(documentName);
1212
+
1213
+ return {
1214
+ contents: [{
1215
+ uri,
1216
+ mimeType: "text/plain",
1217
+ text: content
1218
+ }]
1219
+ };
1220
+ }
1221
+ );
1222
+
1223
+ // List available resources dynamically
1224
+ server.registerResourceList(async () => {
1225
+ const documents = await getAvailableDocuments();
1226
+ return {
1227
+ resources: documents.map(doc => ({
1228
+ uri: `file://documents/${doc.name}`,
1229
+ name: doc.name,
1230
+ mimeType: "text/plain",
1231
+ description: doc.description
1232
+ }))
1233
+ };
1234
+ });
1235
+ ```
1236
+
1237
+ **When to use Resources vs Tools:**
1238
+ - **Resources:** for data access with simple URI-based parameters
1239
+ - **Tools:** for complex operations requiring validation and business logic
1240
+ - **Resources:** when data is relatively static or template-based
1241
+ - **Tools:** when operations have side effects or complex workflows
1242
+
1243
+ ### Transport Options
1244
+
1245
+ The TypeScript SDK supports two main transport mechanisms:
1246
+
1247
+ #### Streamable HTTP (Recommended for Remote Servers)
1248
+
1249
+ ```typescript
1250
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
1251
+ import express from "express";
1252
+
1253
+ const app = express();
1254
+ app.use(express.json());
1255
+
1256
+ app.post('/mcp', async (req, res) => {
1257
+ // Create new transport for each request (stateless, prevents request ID collisions)
1258
+ const transport = new StreamableHTTPServerTransport({
1259
+ sessionIdGenerator: undefined,
1260
+ enableJsonResponse: true
1261
+ });
1262
+
1263
+ res.on('close', () => transport.close());
1264
+
1265
+ await server.connect(transport);
1266
+ await transport.handleRequest(req, res, req.body);
1267
+ });
1268
+
1269
+ app.listen(3000);
1270
+ ```
1271
+
1272
+ #### stdio (For Local Integrations)
1273
+
1274
+ ```typescript
1275
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
1276
+
1277
+ const transport = new StdioServerTransport();
1278
+ await server.connect(transport);
1279
+ ```
1280
+
1281
+ **Transport selection:**
1282
+ - **Streamable HTTP:** web services, remote access, multiple clients
1283
+ - **stdio:** command-line tools, local development, subprocess integration
1284
+
1285
+ ### Notification Support
1286
+
1287
+ Notify clients when server state changes:
1288
+
1289
+ ```typescript
1290
+ // Notify when tools list changes
1291
+ server.notification({
1292
+ method: "notifications/tools/list_changed"
1293
+ });
1294
+
1295
+ // Notify when resources change
1296
+ server.notification({
1297
+ method: "notifications/resources/list_changed"
1298
+ });
1299
+ ```
1300
+
1301
+ Use notifications sparingly — only when server capabilities genuinely change.
1302
+
1303
+ ## Code Best Practices
1304
+
1305
+ ### Code Composability and Reusability
1306
+
1307
+ Prioritize composability and code reuse (the general rule is in `00-core.md`): extract common functionality into reusable helper functions, shared API clients, centralized error handling, composable business logic, and shared markdown/JSON field-selection & formatting. NEVER copy-paste similar code between tools; if you write similar logic twice, extract it. Share pagination, filtering, field selection, and formatting; centralize authentication/authorization.
1308
+
1309
+ ## Building and Running
1310
+
1311
+ Always build your TypeScript code before running:
1312
+
1313
+ ```bash
1314
+ # Build the project
1315
+ npm run build
1316
+
1317
+ # Run the server
1318
+ npm start
1319
+
1320
+ # Development with auto-reload
1321
+ npm run dev
1322
+ ```
1323
+
1324
+ Always ensure `npm run build` completes successfully before considering the implementation complete.
1325
+
1326
+ ## Quality Checklist
1327
+
1328
+ Before finalizing your Node/TypeScript MCP server implementation, ensure:
1329
+
1330
+ ### Strategic Design
1331
+ - [ ] Tools enable complete workflows, not just API endpoint wrappers
1332
+ - [ ] Tool names reflect natural task subdivisions
1333
+ - [ ] Response formats optimize for agent context efficiency
1334
+ - [ ] Human-readable identifiers used where appropriate
1335
+ - [ ] Error messages guide agents toward correct usage
1336
+
1337
+ ### Implementation Quality
1338
+ - [ ] FOCUSED IMPLEMENTATION: Most important and valuable tools implemented
1339
+ - [ ] All tools registered using `registerTool` with complete configuration
1340
+ - [ ] All tools include `title`, `description`, `inputSchema`, and `annotations`
1341
+ - [ ] Annotations correctly set (readOnlyHint, destructiveHint, idempotentHint, openWorldHint)
1342
+ - [ ] All tools use Zod schemas for runtime input validation with `.strict()` enforcement
1343
+ - [ ] All Zod schemas have proper constraints and descriptive error messages
1344
+ - [ ] All tools have comprehensive descriptions with explicit input/output types
1345
+ - [ ] Descriptions include return value examples and complete schema documentation
1346
+ - [ ] Error messages are clear, actionable, and educational
1347
+
1348
+ ### TypeScript Quality
1349
+ - [ ] TypeScript interfaces are defined for all data structures
1350
+ - [ ] Strict TypeScript is enabled in tsconfig.json
1351
+ - [ ] No use of `any` type - use `unknown` or proper types instead
1352
+ - [ ] All async functions have explicit Promise<T> return types
1353
+ - [ ] Error handling uses proper type guards (e.g., `axios.isAxiosError`, `z.ZodError`)
1354
+
1355
+ ### Advanced Features (where applicable)
1356
+ - [ ] Resources registered for appropriate data endpoints
1357
+ - [ ] Appropriate transport configured (stdio or streamable HTTP)
1358
+ - [ ] Notifications implemented for dynamic server capabilities
1359
+ - [ ] Type-safe with SDK interfaces
1360
+
1361
+ ### Project Configuration
1362
+ - [ ] Package.json includes all necessary dependencies
1363
+ - [ ] Build script produces working JavaScript in dist/ directory
1364
+ - [ ] Main entry point is properly configured as dist/index.js
1365
+ - [ ] Server name follows format: `{service}-mcp-server`
1366
+ - [ ] tsconfig.json properly configured with strict mode
1367
+
1368
+ ### Code Quality
1369
+ - [ ] Pagination is properly implemented where applicable
1370
+ - [ ] Large responses check CHARACTER_LIMIT constant and truncate with clear messages
1371
+ - [ ] Filtering options are provided for potentially large result sets
1372
+ - [ ] All network operations handle timeouts and connection errors gracefully
1373
+ - [ ] Common functionality is extracted into reusable functions
1374
+ - [ ] Return types are consistent across similar operations
1375
+
1376
+ ### Testing and Build
1377
+ - [ ] `npm run build` completes successfully without errors
1378
+ - [ ] dist/index.js created and executable
1379
+ - [ ] Server runs: `node dist/index.js --help`
1380
+ - [ ] All imports resolve correctly
1381
+ - [ ] Sample tool calls work as expected