|
| 1 | +--- |
| 2 | +applyTo: "src/**/*.js,tests/**/*.js,package.json" |
| 3 | +--- |
| 4 | + |
| 5 | +# MCP server development rules (this repo) |
| 6 | + |
| 7 | +These rules apply to changes under `src/` and related MCP server tests. |
| 8 | + |
| 9 | +## Core standards |
| 10 | +- Prefer **minimal diffs** and incremental improvements. |
| 11 | +- Avoid breaking existing tool names/behaviors unless explicitly intended. |
| 12 | +- Every behavior change MUST include a verification step (test or curl reproduction). |
| 13 | + |
| 14 | +## Express / HTTP handling |
| 15 | +- Request bodies MUST be parsed safely: |
| 16 | + - use explicit JSON parsing middleware |
| 17 | + - set a reasonable size limit for JSON bodies |
| 18 | +- Validate content negotiation: |
| 19 | + - MCP endpoints should check `Accept` headers as appropriate for the endpoint behavior. |
| 20 | +- Error handling MUST be consistent: |
| 21 | + - do not expose internal stack traces to clients |
| 22 | + - return clear status codes and brief error messages |
| 23 | + |
| 24 | +## MCP tools |
| 25 | +- Every MCP tool MUST have: |
| 26 | + - stable tool name (choose and keep a consistent naming convention across tools) |
| 27 | + - title + description |
| 28 | + - zod input schema (even if empty) |
| 29 | + - deterministic output shape |
| 30 | +- Do not return raw secrets or dump large file contents by default. |
| 31 | + |
| 32 | +## Logging hygiene |
| 33 | +- Do not log raw request bodies. |
| 34 | +- If logging headers, redact authorization-like fields. |
| 35 | +- Prefer structured logs with `source` and request id (when available). |
| 36 | + |
| 37 | +## Testing |
| 38 | +- Add or update tests when: |
| 39 | + - endpoint behavior changes |
| 40 | + - new tools are added |
| 41 | + - error handling changes |
| 42 | +- Tests MUST be deterministic and fast. |
| 43 | + |
| 44 | +## Output requirements for Copilot edits |
| 45 | +When generating patches: |
| 46 | +- Output full file contents for modified files in fenced `md` blocks. |
| 47 | +- Include a short verification checklist (commands + expected results). |
0 commit comments