Skip to content

Commit b058878

Browse files
committed
Use hashtag tool refs in MCP server prompts
1 parent 58b98ea commit b058878

13 files changed

+162
-162
lines changed

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ See the [VS Code Extension guide](./vscode/extension.md) for details.
1818

1919
The `.vsix` can be downloaded from
2020
[GitHub Releases](https://github.com/advanced-security/codeql-development-mcp-server/releases)
21-
or built from source (`npm run package:vscode` at the repository root).
21+
or built from source (`npm run package:vsix` at the repository root).
2222

2323
### From npm
2424

docs/vscode/extension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Or in VS Code: **Extensions** sidebar → `⋯` menu → **Install from VSIX…*
3939
From the repository root:
4040

4141
```bash
42-
npm run package:vscode
42+
npm run package:vsix
4343
code --install-extension extensions/vscode/codeql-development-mcp-server.vsix
4444
```
4545

extensions/vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vscode-codeql-development-mcp-server",
33
"displayName": "CodeQL Development MCP Server",
4-
"description": "Automatically installs, configures, and manages the CodeQL Development MCP Server in VS Code.",
4+
"description": "LLM-assisted development of CodeQL queries, libraries, and tests via #ql-mcp prompts, resources, and tools.",
55
"version": "2.24.1",
66
"publisher": "advanced-security",
77
"license": "SEE LICENSE IN LICENSE",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"test:client": "npm run test:integration:default -w client",
4949
"test:server": "npm run test -w server",
5050
"test:vscode": "npm run test -w extensions/vscode",
51-
"package:vscode": "npm run clean:test-dbs &&npm run package -w extensions/vscode",
51+
"package:vsix": "npm run clean:test-dbs &&npm run package -w extensions/vscode",
5252
"tidy": "npm run lint:fix && npm run format",
5353
"tidy:check": "npm run lint && npm run format:check",
5454
"upgrade": "npm run upgrade:node",

server/dist/codeql-development-mcp-server.js

Lines changed: 7 additions & 7 deletions
Large diffs are not rendered by default.

server/dist/codeql-development-mcp-server.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/src/prompts/document-codeql-query.prompt.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Documentation files are **siblings** to the query file (same directory).
3232

3333
1. **No documentation exists**: Create new `QueryFileBaseName.md` file
3434
2. **`.md` file exists**: Update the existing markdown file
35-
3. **`.qhelp` file exists**: Use `codeql_generate_query-help` tool to convert to markdown, then update
35+
3. **`.qhelp` file exists**: Use #codeql_generate_query-help tool to convert to markdown, then update
3636

3737
## Workflow Checklist
3838

@@ -41,39 +41,39 @@ Use the following MCP server tools to gather context before creating documentati
4141
### Phase 1: Query Discovery
4242

4343
- [ ] **Step 1: Locate query files**
44-
- Tool: `find_codeql_query_files`
44+
- Tool: #find_codeql_query_files
4545
- Parameters: `queryPath` = provided query path
4646
- Gather: Query source file path, existing documentation files, test files
4747
- Check: Does `QueryFileBaseName.md` or `QueryFileBaseName.qhelp` exist?
4848

4949
- [ ] **Step 2: Read query metadata**
50-
- Tool: `codeql_resolve_metadata`
50+
- Tool: #codeql_resolve_metadata
5151
- Parameters: `query` = query file path
5252
- Gather: @name, @description, @kind, @id, @tags, @precision, @severity
5353

5454
### Phase 2: Convert Existing qhelp (if needed)
5555

5656
- [ ] **Step 3: Convert qhelp to markdown** (only if `.qhelp` exists)
57-
- Tool: `codeql_generate_query-help`
57+
- Tool: #codeql_generate_query-help
5858
- Parameters: `query` = query file path, `format` = "markdown"
5959
- Use output as starting point for updated documentation
6060

6161
### Phase 3: Gather Query Context
6262

6363
- [ ] **Step 4: Validate query structure**
64-
- Tool: `validate_codeql_query`
64+
- Tool: #validate_codeql_query
6565
- Parameters: `query` = query source code
6666
- Gather: Structural validation, suggestions
67-
- Note: This is a heuristic check only — for full validation, use `codeql_query_compile`
67+
- Note: This is a heuristic check only — for full validation, use #codeql_query_compile
6868

6969
- [ ] **Step 5: Explore query types** (if deeper understanding needed)
70-
- Tool: `codeql_lsp_definition` — navigate to class/predicate definitions
71-
- Tool: `codeql_lsp_completion` — explore member predicates on types used in the query
70+
- Tool: #codeql_lsp_definition — navigate to class/predicate definitions
71+
- Tool: #codeql_lsp_completion — explore member predicates on types used in the query
7272
- Parameters: `file_path`, `line` (0-based), `character` (0-based), `workspace_uri` (pack root)
73-
- Run `codeql_pack_install` first — LSP tools require resolved dependencies
73+
- Run #codeql_pack_install first — LSP tools require resolved dependencies
7474

7575
- [ ] **Step 6: Run tests** (if tests exist from Step 1)
76-
- Tool: `codeql_test_run`
76+
- Tool: #codeql_test_run
7777
- Parameters: `tests` = test directories
7878
- Gather: Pass/fail status, confirms query behavior
7979

server/src/prompts/explain-codeql-query.prompt.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,28 @@ You MUST use the following MCP server tools in sequence to gather context before
3434
### Phase 1: Query Discovery and Validation
3535

3636
- [ ] **Step 1: Locate query files**
37-
- Tool: `find_codeql_query_files`
37+
- Tool: #find_codeql_query_files
3838
- Parameters: `queryPath` = provided query path
3939
- Gather: Query source file, test files, expected results, metadata location
4040
- Note: If tests exist, record the test directory path for later steps
4141

4242
- [ ] **Step 2: Validate query structure**
43-
- Tool: `validate_codeql_query`
43+
- Tool: #validate_codeql_query
4444
- Parameters: `query` = contents of the query file
4545
- Gather: Structural validation results, heuristic warnings/suggestions
4646

4747
### Phase 2: Test Execution and Database Creation
4848

4949
- [ ] **Step 3: Run existing tests** (if tests exist from Step 1)
50-
- Tool: `codeql_test_run`
50+
- Tool: #codeql_test_run
5151
- Parameters: `tests` = array of test directories from Step 1
5252
- Purpose: Ensures test database is created and current with test code
5353
- Gather: Test pass/fail status, test database path (`.testproj` directory)
5454

5555
### Phase 3: Code Structure Analysis (if test database exists)
5656

5757
- [ ] **Step 4: Generate PrintAST output**
58-
- Tool: `codeql_query_run`
58+
- Tool: #codeql_query_run
5959
- Parameters:
6060
- `queryName`: `"PrintAST"`
6161
- `queryLanguage`: provided language
@@ -65,7 +65,7 @@ You MUST use the following MCP server tools in sequence to gather context before
6565
- Gather: AST hierarchy showing code structure representation
6666

6767
- [ ] **Step 5: Generate PrintCFG output** (for key functions)
68-
- Tool: `codeql_query_run`
68+
- Tool: #codeql_query_run
6969
- Parameters:
7070
- `queryName`: `"PrintCFG"`
7171
- `queryLanguage`: provided language
@@ -77,7 +77,7 @@ You MUST use the following MCP server tools in sequence to gather context before
7777
### Phase 4: Query Profiling and Evaluation Order
7878

7979
- [ ] **Step 6: Profile the query**
80-
- Tool: `profile_codeql_query`
80+
- Tool: #profile_codeql_query
8181
- Parameters:
8282
- `queryPath`: the query file path
8383
- `database`: If `databasePath` input was provided and valid, use it; otherwise use test database from Step 3
@@ -103,11 +103,11 @@ You MUST use the following MCP server tools in sequence to gather context before
103103
```
104104

105105
- [ ] **Step 8: Quick evaluate specific predicates** (as needed)
106-
- First, locate the predicate: Tool: `find_predicate_position` with `file` and `name`
107-
- Then evaluate: Tool: `quick_evaluate` with `file`, `db`, and `symbol`
106+
- First, locate the predicate: Tool: #find_predicate_position with `file` and `name`
107+
- Then evaluate: Tool: #quick_evaluate with `file`, `db`, and `symbol`
108108
- Use when: You need more context on how a specific predicate or class behaves
109-
- Note: `find_class_position` finds `class` definitions only, not `module` definitions
110-
- Note: `find_predicate_position` returns 1-based positions; LSP tools use 0-based
109+
- Note: #find_class_position finds `class` definitions only, not `module` definitions
110+
- Note: #find_predicate_position returns 1-based positions; LSP tools use 0-based
111111

112112
### Phase 5: Generate Explanation
113113

server/src/prompts/ql-lsp-iterative-development.prompt.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Thus, this prompt can be used in any environment where the query files are on di
2121
## Prerequisites
2222

2323
1. A CodeQL pack with `codeql-pack.yml` on disk
24-
2. Dependencies installed via `codeql_pack_install` (pointing at the pack directory)
24+
2. Dependencies installed via #codeql_pack_install (pointing at the pack directory)
2525
3. Query files saved to disk (LSP tools operate on files, not inline strings)
2626

2727
## Key Concept: Positions Are File Path + Line + Character
@@ -37,12 +37,12 @@ containing `codeql-pack.yml`) for import resolution to work. Without it, complet
3737
and definitions for imported libraries will be empty.
3838

3939
> **Critical**: LSP line/character positions are 0-based, but `read_file`,
40-
> `find_predicate_position`, and `find_class_position` return 1-based positions.
40+
> #find_predicate_position, and #find_class_position return 1-based positions.
4141
> Always subtract 1 when passing their output to LSP tools.
4242
4343
## Step 1: Discover Available Types with Completions
4444

45-
Use `codeql_lsp_completion` to explore what types and predicates are available at any
45+
Use #codeql_lsp_completion to explore what types and predicates are available at any
4646
position in a query file. This replaces manual documentation browsing.
4747

4848
**Example**: To see what classes are available in a `from` clause after `import javascript`:
@@ -68,7 +68,7 @@ each with full signature and documentation.
6868

6969
## Step 2: Navigate to Definitions
7070

71-
Use `codeql_lsp_definition` to find where a class, predicate, or module is defined.
71+
Use #codeql_lsp_definition to find where a class, predicate, or module is defined.
7272
This returns the file URI and line range of the definition — even into library pack
7373
files you haven't opened.
7474

@@ -95,7 +95,7 @@ the source.
9595

9696
## Step 3: Find All References
9797

98-
Use `codeql_lsp_references` to find how a symbol is used across the workspace.
98+
Use #codeql_lsp_references to find how a symbol is used across the workspace.
9999

100100
```text
101101
Tool: codeql_lsp_references
@@ -115,7 +115,7 @@ find real usage examples instead of guessing from documentation.
115115

116116
## Step 4: Locate Symbols with Position Finders
117117

118-
Use `find_predicate_position` and `find_class_position` to locate where a specific
118+
Use #find_predicate_position and #find_class_position to locate where a specific
119119
symbol is defined in a file. These return **1-based** line/column positions.
120120

121121
```text
@@ -126,18 +126,18 @@ Parameters:
126126
Returns: { start_line: 12, start_col: 13, end_line: 12, end_col: 20 }
127127
```
128128

129-
> **Note**: `find_class_position` finds `class` definitions only — it does not find
130-
> `module` definitions. Use `find_predicate_position` for predicates inside modules.
129+
> **Note**: #find_class_position finds `class` definitions only — it does not find
130+
> `module` definitions. Use #find_predicate_position for predicates inside modules.
131131
132132
**Combining with LSP tools**: To navigate to a predicate's definition in library code:
133133

134-
1. Use `find_predicate_position` to get its 1-based position
134+
1. Use #find_predicate_position to get its 1-based position
135135
2. Subtract 1 from line/col to convert to 0-based
136-
3. Pass to `codeql_lsp_definition` to jump to the underlying type
136+
3. Pass to #codeql_lsp_definition to jump to the underlying type
137137

138138
## Step 5: Quick-Evaluate Individual Predicates
139139

140-
Use `quick_evaluate` to evaluate a single predicate or class against a database
140+
Use #quick_evaluate to evaluate a single predicate or class against a database
141141
without running the full query. This is the fastest way to debug whether a predicate
142142
matches what you expect.
143143

@@ -151,27 +151,27 @@ Parameters:
151151
```
152152

153153
The tool evaluates just that symbol (predicate or class) and returns the result path.
154-
Use `codeql_bqrs_decode` on the output to inspect results in CSV or JSON format.
154+
Use #codeql_bqrs_decode on the output to inspect results in CSV or JSON format.
155155

156156
## Step 6: Validate at Multiple Levels
157157

158158
Use the right validation tool for each situation:
159159

160-
| Tool | Use When | Input | Resolves Imports? |
161-
| ------------------------ | --------------------------------------- | ------------------ | ------------------- |
162-
| `validate_codeql_query` | Quick structural check | Inline QL string | No (heuristic only) |
163-
| `codeql_lsp_diagnostics` | Syntax/semantic validation of fragments | Inline QL string | No |
164-
| `codeql_query_compile` | Full compilation check | On-disk `.ql` file | Yes |
165-
| `codeql_test_run` | End-to-end result validation | Test directory | Yes |
160+
| Tool | Use When | Input | Resolves Imports? |
161+
| ----------------------- | --------------------------------------- | ------------------ | ------------------- |
162+
| #validate_codeql_query | Quick structural check | Inline QL string | No (heuristic only) |
163+
| #codeql_lsp_diagnostics | Syntax/semantic validation of fragments | Inline QL string | No |
164+
| #codeql_query_compile | Full compilation check | On-disk `.ql` file | Yes |
165+
| #codeql_test_run | End-to-end result validation | Test directory | Yes |
166166

167-
**`codeql_lsp_diagnostics`** validates QL syntax and semantics for inline code snippets,
167+
**#codeql_lsp_diagnostics** validates QL syntax and semantics for inline code snippets,
168168
but **cannot resolve `import` statements** (like `import javascript`). Use it for:
169169

170170
- Checking predicate signatures and QL syntax
171171
- Verifying `from`/`where`/`select` clause structure
172172
- Catching type errors in import-free QL fragments
173173

174-
For queries with imports, always use `codeql_query_compile` on the saved file.
174+
For queries with imports, always use #codeql_query_compile on the saved file.
175175

176176
## Iterative Development Loop
177177

@@ -202,7 +202,7 @@ This example shows the tools in action for building a JavaScript XSS query.
202202
### 1. Create the query file and install dependencies
203203

204204
Write a `.ql` file with `import javascript` and a skeleton `from`/`where`/`select`.
205-
Run `codeql_pack_install` on the pack directory.
205+
Run #codeql_pack_install on the pack directory.
206206

207207
### 2. Explore sink types
208208

@@ -245,14 +245,14 @@ quick_evaluate(file=..., db=test.testproj, symbol="isSink") → inspect result
245245

246246
## Important Notes
247247

248-
- **All LSP tools use 0-based positions**. `find_class_position` and
249-
`find_predicate_position` return 1-based positions. Convert before combining.
248+
- **All LSP tools use 0-based positions**. #find_class_position and
249+
#find_predicate_position return 1-based positions. Convert before combining.
250250
- **`workspace_uri` must be the pack root** (the directory containing
251251
`codeql-pack.yml`). Without it, completions and definitions will be empty.
252-
- **Run `codeql_pack_install` first**. LSP tools require resolved dependencies.
253-
- **`codeql_lsp_diagnostics` cannot resolve imports**. For `import javascript`
254-
and similar, use `codeql_query_compile` on the on-disk file instead.
255-
- **`find_class_position` finds `class` only**, not `module` definitions.
256-
Use grep or `find_predicate_position` for predicates inside modules.
257-
- **`codeql_lsp_references` scope** depends on `workspace_uri`. Point it at
252+
- **Run #codeql_pack_install first**. LSP tools require resolved dependencies.
253+
- **#codeql_lsp_diagnostics cannot resolve imports**. For `import javascript`
254+
and similar, use #codeql_query_compile on the on-disk file instead.
255+
- **#find_class_position finds `class` only**, not `module` definitions.
256+
Use grep or #find_predicate_position for predicates inside modules.
257+
- **#codeql_lsp_references scope** depends on `workspace_uri`. Point it at
258258
a library pack root to find usages across library code.

0 commit comments

Comments
 (0)