|
| 1 | +--- |
| 2 | +applyTo: 'server/src/resources/**/*.md' |
| 3 | +description: 'Instructions for MCP server resource markdown files served to LLMs.' |
| 4 | +--- |
| 5 | + |
| 6 | +# Copilot Instructions for `server/src/resources/**/*.md` resource files |
| 7 | + |
| 8 | +## PURPOSE |
| 9 | + |
| 10 | +This file contains instructions for working with markdown resource files in the `server/src/resources/` directory. These files are imported at build time (via esbuild's `.md: 'text'` loader) and served to LLMs through MCP resource endpoints (e.g., `codeql://server/overview`, `codeql://languages/go/ast`). Because LLMs consume these files as authoritative reference material, correctness and consistency are critical. |
| 11 | + |
| 12 | +## REQUIREMENTS |
| 13 | + |
| 14 | +- ALWAYS name resource files to match their MCP endpoint path. For example, a resource served at `codeql://server/overview` must be named `server-overview.md`, and a resource at `codeql://languages/go/ast` must be `languages/go_ast.md`. |
| 15 | +- ALWAYS start each resource file with a `#`-level (H1) heading that identifies the resource topic and scope. |
| 16 | +- ALWAYS use the v2 module-based DataFlow/TaintTracking API (`module MyConfig implements DataFlow::ConfigSig` with `TaintTracking::Global<MyConfig>`) in all CodeQL code examples. NEVER use the deprecated v1 class-based API (`class MyConfig extends TaintTracking::Configuration` with `override predicate`). |
| 17 | +- ALWAYS use `codeql-pack.yml` (not `qlpack.yml`) as the pack configuration filename in all code examples and references. |
| 18 | +- ALWAYS ensure any new resource file has a corresponding import and registration in `server/src/types/language-types.ts` (for language-specific resources) or `server/src/lib/resources.ts` (for general resources), and that the test expectations in `server/test/src/resources/` are updated accordingly. |
| 19 | +- ALWAYS verify ASCII art diagrams have consistent box corners and formatting. |
| 20 | +- ALWAYS ensure code examples are syntactically correct — class names, constructor names, and predicate names must all match (e.g., a class named `FooAsSink` must have a constructor named `FooAsSink()`). |
| 21 | +- **ALWAYS run `npm run build-and-test` from the repo root directory and ensure it passes completely before committing any changes.** |
| 22 | + |
| 23 | +## PREFERENCES |
| 24 | + |
| 25 | +- PREFER actionable, tool-oriented content that tells an LLM exactly which MCP tools and prompts to invoke and in what order, over abstract descriptions. |
| 26 | +- PREFER concrete code examples over prose explanations for CodeQL patterns and idioms. |
| 27 | +- PREFER a single authoritative location for each piece of documentation — if content exists in a resource file, repo-level docs should reference it rather than restate it. |
| 28 | + |
| 29 | +## DOCUMENTATION RELATIONSHIP: `server/src/resources/` ↔ `docs/ql-mcp/` |
| 30 | + |
| 31 | +The `server/src/resources/server-*.md` files are the **authoritative source** for MCP server tools, prompts, and queries documentation. The `docs/ql-mcp/*.md` files are **thin wrappers** that link to these authoritative sources. |
| 32 | + |
| 33 | +### When to update which file |
| 34 | + |
| 35 | +| Change type | Update `server/src/resources/server-*.md` | Update `docs/ql-mcp/*.md` | |
| 36 | +| -------------------------------------------- | ----------------------------------------- | -------------------------------------- | |
| 37 | +| Add, remove, or modify an MCP tool | YES — `server-tools.md` | Only if monitoring tools table changes | |
| 38 | +| Add, remove, or modify an MCP prompt | YES — `server-prompts.md` | NO — wrapper links to resource file | |
| 39 | +| Add or remove a language resource | YES — registration in source code | YES — update language table | |
| 40 | +| Add or remove a static resource | YES — resource file + registration | YES — update static resources table | |
| 41 | +| Change a resource URI or endpoint path | YES — rename file to match new path | YES — update URI references | |
| 42 | +| Fix a typo or improve wording in tool/prompt | YES — resource file only | NO — wrapper inherits the fix | |
| 43 | + |
| 44 | +### Rules |
| 45 | + |
| 46 | +- ALWAYS update the authoritative `server/src/resources/server-*.md` file first, then verify the `docs/ql-mcp/*.md` wrapper still links correctly. |
| 47 | +- ALWAYS keep `docs/ql-mcp/*.md` as thin wrappers — they should contain only a brief overview, a link to the authoritative resource file, and any content that is NOT served via MCP (e.g., the optional monitoring tools table in `docs/ql-mcp/tools.md`). |
| 48 | +- NEVER duplicate detailed tool, prompt, or resource descriptions in both `server/src/resources/` and `docs/ql-mcp/`. The `docs/ql-mcp/` file must defer to the resource file for all MCP-served content. |
| 49 | + |
| 50 | +## CONSTRAINTS |
| 51 | + |
| 52 | +- NEVER leave any trailing whitespace on any line. |
| 53 | +- NEVER include placeholder or TODO content in resource files — if a resource is not ready, exclude it from registration until the content is complete. |
| 54 | +- NEVER reference deprecated or removed MCP tools in resource files. When a tool is deprecated, remove all mentions from resource files. |
| 55 | +- NEVER mix deprecated and current API patterns in code examples within the same file or across files in this directory. |
0 commit comments