Skip to content

Commit 192c6b8

Browse files
committed
Add search_ql_code and codeql_resolve_files tools
Add search_ql_code and codeql_resolve_files tools in order to eliminate grep/CLI dependencies. - New tools: search_ql_code (QL text/regex search) and codeql_resolve_files (file discovery by extension/glob) so LLMs never need shell access - Rewrite profile_codeql_query_from_logs with two-tier design: compact inline JSON + line-indexed detail file for targeted read_file access; parser now captures RA operations and pipeline-stage tuple progressions - Fix codeql_resolve_database to probe child directories for databases - Remove all grep/CLI references from prompts and resources - Cross-platform: normalize \r\n line endings in parser and search tool
1 parent 5c38a91 commit 192c6b8

29 files changed

+2009
-548
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Integration Test: codeql_resolve_files/find_qll_files
2+
3+
## Purpose
4+
5+
Tests the `codeql_resolve_files` tool to ensure it can find QL library files by extension within a CodeQL pack directory.
6+
7+
## Test Scenario
8+
9+
This test validates that the `codeql_resolve_files` tool can:
10+
11+
1. Accept a directory path and file extension filter
12+
2. Use the `codeql resolve files` CLI command to find matching files
13+
3. Return a list of file paths matching the specified criteria
14+
15+
## Test Parameters
16+
17+
- `dir`: "server/ql/javascript/examples/src"
18+
- `include-extension`: [".ql"]
19+
20+
## Expected Behavior
21+
22+
The tool should:
23+
24+
1. Invoke `codeql resolve files` with the specified directory and extension filter
25+
2. Return file paths for all `.ql` files found in the directory tree
26+
3. Return a successful result with the file listing
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"toolName": "codeql_resolve_files",
3+
"parameters": {
4+
"dir": "server/ql/javascript/examples/src",
5+
"include-extension": [".ql"]
6+
},
7+
"success": true,
8+
"description": "Successfully resolved .ql files in JavaScript examples directory"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"toolName": "codeql_resolve_files",
3+
"parameters": {
4+
"dir": "server/ql/javascript/examples/src",
5+
"include-extension": [".ql"]
6+
},
7+
"expectedSuccess": true,
8+
"description": "Test codeql_resolve_files for finding .ql files in JavaScript examples"
9+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Integration Test: search_ql_code/search_predicate_name
2+
3+
## Purpose
4+
5+
Tests the `search_ql_code` tool to ensure it can search QL source files for a predicate name pattern and return structured results with file paths and line numbers.
6+
7+
## Test Scenario
8+
9+
This test validates that the `search_ql_code` tool can:
10+
11+
1. Accept a regex pattern for a predicate name
12+
2. Search `.ql` and `.qll` files in a given directory
13+
3. Return structured JSON results with file paths, line numbers, and matching lines
14+
4. Report the correct number of files searched and matches found
15+
16+
## Test Parameters
17+
18+
- `pattern`: "isSource"
19+
- `paths`: ["server/ql/javascript/examples/src"]
20+
- `contextLines`: 1
21+
22+
## Expected Behavior
23+
24+
The tool should:
25+
26+
1. Recursively search `.ql` and `.qll` files in the specified directory
27+
2. Return matches with file paths, line numbers, and context lines
28+
3. Report `filesSearched`, `totalMatches`, `returnedMatches`, and `truncated` fields
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"toolName": "search_ql_code",
3+
"parameters": {
4+
"pattern": "isSource",
5+
"paths": ["server/ql/javascript/examples/src"],
6+
"contextLines": 1
7+
},
8+
"success": true,
9+
"description": "Successfully searched QL files for predicate name pattern",
10+
"searchResult": {
11+
"totalMatches": 1,
12+
"returnedMatches": 1,
13+
"truncated": false,
14+
"filesSearched": 1,
15+
"results": [
16+
{
17+
"filePath": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
18+
"lineNumber": 1,
19+
"lineContent": "contains isSource match"
20+
}
21+
]
22+
}
23+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"toolName": "search_ql_code",
3+
"parameters": {
4+
"pattern": "isSource",
5+
"paths": ["server/ql/javascript/examples/src"],
6+
"contextLines": 1
7+
},
8+
"expectedSuccess": true,
9+
"description": "Test search_ql_code for predicate name search in JavaScript examples"
10+
}

extensions/vscode/test/suite/mcp-tool-e2e.integration.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ suite('MCP Server Tool Integration Tests', () => {
144144
assert.ok(toolNames.includes('list_codeql_databases'), 'Should include list_codeql_databases');
145145
assert.ok(toolNames.includes('list_query_run_results'), 'Should include list_query_run_results');
146146
assert.ok(toolNames.includes('list_mrva_run_results'), 'Should include list_mrva_run_results');
147+
assert.ok(toolNames.includes('search_ql_code'), 'Should include search_ql_code');
148+
assert.ok(toolNames.includes('codeql_resolve_files'), 'Should include codeql_resolve_files');
147149

148150
console.log(`[mcp-tool-e2e] Server provides ${response.tools.length} tools`);
149151
});

0 commit comments

Comments
 (0)