Skip to content

Commit 76a139b

Browse files
committed
Add CodeQL background server manager and LSP tools
Implements CodeQLServerManager for config-aware lifecycle management of CodeQL's three background servers (language-server, query-server2, cli-server) with session-isolated cache directories and automatic restart on configuration changes. Adds four LSP-based MCP tools: - codeql_lsp_diagnostics (renamed from codeql_language_server_eval) - codeql_lsp_completion - codeql_lsp_definition - codeql_lsp_references Resolves #17 (server manager with config hashing, session isolation, graceful shutdown) and #1 (LSP completion/definition/references tools).
1 parent ca58e85 commit 76a139b

File tree

63 files changed

+7111
-2134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+7111
-2134
lines changed

client/integration-tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Monitoring-based integration tests enable testing of MCP tools that previously c
127127
## Example: Tool with Both File-Based and Monitoring Tests
128128

129129
```text
130-
client/integration-tests/primitives/tools/codeql_language_server_eval/
130+
client/integration-tests/primitives/tools/codeql_lsp_diagnostics/
131131
└── semantic_validation/
132132
├── before/
133133
│ ├── semantic_query.ql # File-based test input
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"sessions": [
3+
{
4+
"id": "integration_test_session",
5+
"calls": [
6+
{
7+
"tool": "codeql_lsp_completion",
8+
"timestamp": "2026-02-08T00:00:00.000Z",
9+
"status": "success"
10+
}
11+
]
12+
}
13+
]
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"sessions": [],
3+
"parameters": {
4+
"file_path": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
5+
"line": 12,
6+
"character": 7
7+
}
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `codeql_lsp_completion/from_clause_completion`
2+
3+
## PURPOSE
4+
5+
Tests that `codeql_lsp_completion` returns completion items when the cursor is
6+
positioned inside a `from` clause after an `import` statement.
7+
8+
## INPUTS
9+
10+
- **file_path**: `server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql`
11+
- **line**: 11 (inside the `from` clause)
12+
- **character**: 5 (after keyword prefix)
13+
14+
## EXPECTED OUTPUTS
15+
16+
- A non-empty list of completion items with labels, documentation, and kind.
17+
- Monitoring state updated to record a successful `codeql_lsp_completion` call.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"sessions": [
3+
{
4+
"id": "integration_test_session",
5+
"calls": [
6+
{
7+
"tool": "codeql_lsp_completion",
8+
"timestamp": "2026-02-08T00:00:00.000Z",
9+
"status": "success"
10+
}
11+
]
12+
}
13+
]
14+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"sessions": [],
3+
"parameters": {
4+
"file_path": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
5+
"line": 11,
6+
"character": 5,
7+
"workspace_uri": "server/ql/javascript/examples"
8+
}
9+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"sessions": [
3+
{
4+
"id": "integration_test_session",
5+
"calls": [
6+
{
7+
"tool": "codeql_lsp_definition",
8+
"timestamp": "2026-02-08T00:00:00.000Z",
9+
"status": "success"
10+
}
11+
]
12+
}
13+
]
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"sessions": [],
3+
"parameters": {
4+
"file_path": "server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql",
5+
"line": 13,
6+
"character": 6
7+
}
8+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# `codeql_lsp_definition/class_definition`
2+
3+
## PURPOSE
4+
5+
Tests that `codeql_lsp_definition` returns definition locations when the cursor
6+
is on a class name used in a `from` clause.
7+
8+
## INPUTS
9+
10+
- **file_path**: `server/ql/javascript/examples/src/ExampleQuery1/ExampleQuery1.ql`
11+
- **line**: 12 (on the class name in the `from` clause)
12+
- **character**: 5 (cursor on the class name)
13+
14+
## EXPECTED OUTPUTS
15+
16+
- One or more definition locations with URIs pointing to `.qll` library files.
17+
- Monitoring state updated to record a successful `codeql_lsp_definition` call.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"sessions": [
3+
{
4+
"id": "integration_test_session",
5+
"calls": [
6+
{
7+
"tool": "codeql_lsp_definition",
8+
"timestamp": "2026-02-08T00:00:00.000Z",
9+
"status": "success"
10+
}
11+
]
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)