| applyTo | server/src/**/*.ts |
|---|---|
| description | Instructions for MCP server TypeScript source code files. |
This file contains instructions for working with TypeScript source code files in the server/src/ directory of the codeql-development-mcp-server repository.
- ALWAYS use modern TypeScript syntax and features.
- ALWAYS follow best practices for implementing secure MCP server primitives via TypeScript.
- ALWAYS order imports, definitions, static lists, and similar constructs alphabetically.
- ALWAYS follow a test-driven development (TDD) approach by writing tests for new features or bug fixes, storing unit tests for
server/src/<lib-example>/<file-example>.tsinserver/test/src/<lib-example>/<file-example>.test.ts. - ALWAYS run
npm run build-and-testfrom the repo root directory and ensure it passes completely before committing any changes. This is MANDATORY and must be verified before every commit. - ALWAYS fix lint errors by running
npm run lint:fixfrom the repo root directory before committing changes. - ALWAYS run the
npm testcommand from theserver/directory and ensure that all tests pass before committing changes.
- PREFER the import of functionality from
@modelcontextprotocol/sdkover direct implementation, unless absolutely necessary. - PREFER to implement each MCP server primitive in its own file named after the primitive, e.g.,
server/src/<lib-example>/<primitive-example>.ts. - PREFER many simple MCP server primitives that each do one thing well over fewer complex MCP server primitives that do many things.
- NEVER leave any trailing whitespace on any line.
- NEVER guess at what a
codeqlCLI subcommand does; ALWAYS verify against the officialcodeql <subcommand> -h -vvdocumentation. - NEVER use stat/lstat followed by a separate read/open on the same path — this is a TOCTOU (Time-of-Check-Time-of-Use) race condition (CWE-367). Instead, attempt the operation directly (e.g.,
readFileSync) within a try/catch block. If you need to know the file size before reading, read first and then check the buffer size — do NOT stat then read. For directory traversal,lstatSyncis acceptable since it is the operation itself (checking entry type), not a precursor to a separate operation.