8. File & Component Creation Rules

New File Locations

What to CreateLocationExample
New toolsrc/tools/<name>.tssrc/tools/exchange.ts
Tool group re-exportsrc/tools/index.tsAdd export to existing file
New domain modulesrc/<domain>/src/exchange/
New scrapersrc/exchange/providers/<name>.tssrc/exchange/providers/daum.ts
Shared kit featuresrc/common/kit/<name>.tssrc/common/kit/validator.ts
Shared kit re-exportsrc/common/kit/index.tsAdd export to existing file
Shared typessrc/common/types.tsAdd types to existing file
Shared constantssrc/common/constants.tsAdd constants to existing file
Build scriptscripts/<name>.mjs|.tsscripts/readme-docs-plugin.ts
Test<name>.test.ts next to the file under testsrc/exchange/parse.test.ts

Checklist for Adding a New Tool

  1. src/tools/<name>.ts — define the tool with toolDef() (description, inputSchema, handler). Every inputSchema field must be .nullable() with a .describe() that states its default — see 04-coding-rules
  2. src/tools/index.ts — merge the new tool into the tools object
  3. src/tools/<name>.test.ts — unit test for the handler
  4. src/tools/openai-schema.test.ts — bump the tool count so the guard covers the new tool
  5. README.md — add the argument table, defaults, ranges, return shape and examples by hand
  6. skills/mcp-kit-cli/SKILL.md — add the same argument table by hand
  7. The exposed name field is part of MCP client compatibility — choose it carefully

Decision Guide for Modifying Existing Components

SituationAction
Add new toolCreate new file in src/tools/ OR add to existing file (if same domain)
Modify existing tool logicOnly modify the tool's handler (no need to split files)
Change shared behaviorModify src/common/kit/ + verify the server and the CLI
Change CLI output formatModify src/common/kit/cli.ts
Change README or SKILL.mdEdit the file directly — there is no generator

When to Extract Shared Logic

Extract to shared logic if any of these conditions apply:

  1. Same code used by both the MCP server and the CLI → Move to src/common/kit/
  2. Same code used in 2+ tools → Extract to a utility in the owning domain directory (e.g., src/exchange/parse.ts)
  3. Complex Zod schema reused → Extract to a shared Zod schema

Common Naming Rules

ItemRuleExample
Package name@julong/<name>@julong/mcp-kit
MCP server binary name<name>mcp-kit
CLI binary name<name>-climcp-kit-cli
Tool name (variable)camelCase + Tool suffixexchangeRateTool, exchangeRatesTool
Tool name (MCP exposed)snake_caseexchange_rate, exchange_rates
File namekebab-casereadme-docs-plugin.ts, case-convert.ts
InterfacePascalCaseToolDefShape, AnyToolDef
Type (utility)PascalCaseNullable<T>, Optional<T>
Async functionasync functionAll tool handlers
ConstantUPPER_SNAKE_CASEVERSION