Skip to content

Commit 32bfd06

Browse files
committed
Address review feedback for PR #260
1 parent 770a476 commit 32bfd06

File tree

13 files changed

+118
-41
lines changed

13 files changed

+118
-41
lines changed

.github/actions/setup-codeql-environment/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ inputs:
2929
go-version:
3030
description: 'Go version to install'
3131
required: false
32-
default: '1.25'
32+
default: '1.25.0'
3333
dotnet-version:
3434
description: '.NET version to install'
3535
required: false

client/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ test-coverage:
5151
go tool cover -html=coverage.out -o coverage.html
5252

5353
## lint: Run linters
54-
lint:
54+
lint: tidy
5555
@if command -v golangci-lint > /dev/null 2>&1; then \
5656
golangci-lint run ./...; \
5757
else \

client/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ gh ql-mcp-client <command> [flags]
3131

3232
### Global Flags
3333

34-
| Flag | Default | Description |
35-
| ---------- | ----------- | ------------------------------------- |
36-
| `--mode` | `stdio` | MCP server transport (`stdio`/`http`) |
37-
| `--host` | `localhost` | MCP server host (http mode) |
38-
| `--port` | `3000` | MCP server port (http mode) |
39-
| `--format` | `text` | Output format (`text`/`json`) |
34+
| Flag | Default | Description |
35+
| ---------- | ----------- | ---------------------------------------- |
36+
| `--mode` | `stdio` | MCP server transport (`stdio`/`http`) |
37+
| `--host` | `localhost` | MCP server host (http mode) |
38+
| `--port` | `3000` | MCP server port (http mode) |
39+
| `--format` | `text` | Output format (`text`/`json`/`markdown`) |
4040

4141
Transport is configured via CLI flags. The CLI does not currently read `MCP_MODE`.
4242

client/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/advanced-security/codeql-development-mcp-server/client
22

3-
go 1.25.6
3+
go 1.25.0
44

55
require (
66
github.com/cli/go-gh/v2 v2.13.0

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

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188630,13 +188630,13 @@ init_logger();
188630188630
// src/lib/log-directory-manager.ts
188631188631
init_temp_dir();
188632188632
import { mkdirSync as mkdirSync3, existsSync as existsSync5 } from "fs";
188633-
import { join as join7, resolve as resolve3, sep, relative } from "path";
188633+
import { join as join7, resolve as resolve3, sep, relative, isAbsolute as isAbsolute3 } from "path";
188634188634
import { randomBytes } from "crypto";
188635188635
function ensurePathWithinBase(baseDir, targetPath) {
188636188636
const absBase = resolve3(baseDir);
188637188637
const absTarget = resolve3(targetPath);
188638188638
const rel = relative(absBase, absTarget);
188639-
if (rel === ".." || rel.startsWith(".." + sep)) {
188639+
if (rel === ".." || rel.startsWith(".." + sep) || isAbsolute3(rel)) {
188640188640
throw new Error(`Provided log directory is outside the allowed base directory: ${absBase}`);
188641188641
}
188642188642
return absTarget;
@@ -188772,7 +188772,7 @@ import { createHash as createHash2 } from "crypto";
188772188772
init_cli_executor();
188773188773
init_logger();
188774188774
import { closeSync, fstatSync, mkdirSync as mkdirSync4, openSync, readFileSync as readFileSync5, writeFileSync } from "fs";
188775-
import { dirname as dirname3, isAbsolute as isAbsolute3 } from "path";
188775+
import { dirname as dirname3, isAbsolute as isAbsolute4 } from "path";
188776188776
var BUILT_IN_EVALUATORS = {
188777188777
"json-decode": "JSON format decoder for query results",
188778188778
"csv-decode": "CSV format decoder for query results",
@@ -189025,7 +189025,7 @@ async function evaluateQueryResults(bqrsPath, queryPath, evaluationFunction, out
189025189025
case "mermaid-graph":
189026189026
return await evaluateWithMermaidGraph(bqrsPath, queryPath, outputPath);
189027189027
default:
189028-
if (isAbsolute3(evalFunc)) {
189028+
if (isAbsolute4(evalFunc)) {
189029189029
return await evaluateWithCustomScript(bqrsPath, queryPath, evalFunc, outputPath);
189030189030
} else {
189031189031
return {
@@ -191104,7 +191104,7 @@ function cacheDatabaseAnalyzeResults(params, logger2) {
191104191104
// src/lib/cli-tool-registry.ts
191105191105
init_package_paths();
191106191106
import { existsSync as existsSync6, mkdirSync as mkdirSync8, realpathSync, rmSync, writeFileSync as writeFileSync4 } from "fs";
191107-
import { basename as basename5, delimiter as delimiter5, dirname as dirname5, isAbsolute as isAbsolute4, join as join10, resolve as resolve4 } from "path";
191107+
import { basename as basename5, delimiter as delimiter5, dirname as dirname5, isAbsolute as isAbsolute5, join as join10, resolve as resolve4 } from "path";
191108191108

191109191109
// ../node_modules/js-yaml/dist/js-yaml.mjs
191110191110
function isNothing(subject) {
@@ -193883,12 +193883,12 @@ function registerCLITool(server, definition) {
193883193883
if (tests && Array.isArray(tests)) {
193884193884
const userDir = getUserWorkspaceDir();
193885193885
positionalArgs = [...positionalArgs, ...tests.map(
193886-
(t) => isAbsolute4(t) ? t : resolve4(userDir, t)
193886+
(t) => isAbsolute5(t) ? t : resolve4(userDir, t)
193887193887
)];
193888193888
}
193889193889
break;
193890193890
case "codeql_query_run": {
193891-
if (options.database && typeof options.database === "string" && !isAbsolute4(options.database)) {
193891+
if (options.database && typeof options.database === "string" && !isAbsolute5(options.database)) {
193892193892
options.database = resolve4(getUserWorkspaceDir(), options.database);
193893193893
logger.info(`Resolved database path to: ${options.database}`);
193894193894
}
@@ -194120,7 +194120,7 @@ function registerCLITool(server, definition) {
194120194120
let cwd;
194121194121
if ((name === "codeql_pack_install" || name === "codeql_pack_ls") && (dir || packDir)) {
194122194122
const rawCwd = dir || packDir;
194123-
cwd = isAbsolute4(rawCwd) ? rawCwd : resolve4(getUserWorkspaceDir(), rawCwd);
194123+
cwd = isAbsolute5(rawCwd) ? rawCwd : resolve4(getUserWorkspaceDir(), rawCwd);
194124194124
}
194125194125
const defaultExamplesPath = resolve4(packageRootDir, "ql", "javascript", "examples");
194126194126
const additionalPacksPath = process.env.CODEQL_ADDITIONAL_PACKS || (existsSync6(defaultExamplesPath) ? defaultExamplesPath : void 0);
@@ -194196,11 +194196,21 @@ function registerCLITool(server, definition) {
194196194196
dilFilePath = void 0;
194197194197
}
194198194198
}
194199-
let processedResult = resultProcessor(result, params);
194199+
let processedResult;
194200194200
if (dilFilePath) {
194201+
const stdoutBytes = Buffer.byteLength(result.stdout ?? "", "utf8");
194202+
processedResult = `Compiled successfully. DIL output written to file (${stdoutBytes} bytes).`;
194203+
if (result.stderr) {
194204+
processedResult += `
194205+
194206+
Warnings/Info:
194207+
${result.stderr}`;
194208+
}
194201194209
processedResult += `
194202194210

194203194211
DIL file: ${dilFilePath}`;
194212+
} else {
194213+
processedResult = resultProcessor(result, params);
194204194214
}
194205194215
return {
194206194216
content: [{
@@ -197774,7 +197784,7 @@ import { pathToFileURL as pathToFileURL3 } from "url";
197774197784
// src/tools/lsp/lsp-server-helper.ts
197775197785
init_server_manager();
197776197786
init_logger();
197777-
import { isAbsolute as isAbsolute5, resolve as resolve11 } from "path";
197787+
import { isAbsolute as isAbsolute6, resolve as resolve11 } from "path";
197778197788
import { pathToFileURL as pathToFileURL2 } from "url";
197779197789
async function getInitializedLanguageServer(opts = {}) {
197780197790
const { packageRootDir: pkgRoot, getUserWorkspaceDir: getUserWorkspaceDir2 } = await Promise.resolve().then(() => (init_package_paths(), package_paths_exports));
@@ -197790,7 +197800,7 @@ async function getInitializedLanguageServer(opts = {}) {
197790197800
const server = await manager.getLanguageServer(config2);
197791197801
let effectiveUri = opts.workspaceUri;
197792197802
if (effectiveUri && !effectiveUri.startsWith("file://")) {
197793-
const absWorkspace = isAbsolute5(effectiveUri) ? effectiveUri : resolve11(getUserWorkspaceDir2(), effectiveUri);
197803+
const absWorkspace = isAbsolute6(effectiveUri) ? effectiveUri : resolve11(getUserWorkspaceDir2(), effectiveUri);
197794197804
effectiveUri = pathToFileURL2(absWorkspace).href;
197795197805
}
197796197806
effectiveUri = effectiveUri ?? pathToFileURL2(resolve11(pkgRoot, "ql")).href;
@@ -197955,7 +197965,7 @@ function registerLspDiagnosticsTool(server) {
197955197965
init_logger();
197956197966
init_package_paths();
197957197967
import { readFile as readFile3 } from "fs/promises";
197958-
import { isAbsolute as isAbsolute6, resolve as resolve12 } from "path";
197968+
import { isAbsolute as isAbsolute7, resolve as resolve12 } from "path";
197959197969
import { pathToFileURL as pathToFileURL4 } from "url";
197960197970
async function getInitializedServer(params) {
197961197971
return getInitializedLanguageServer({
@@ -197964,7 +197974,7 @@ async function getInitializedServer(params) {
197964197974
});
197965197975
}
197966197976
function prepareDocumentPosition(params) {
197967-
const absPath = isAbsolute6(params.filePath) ? params.filePath : resolve12(getUserWorkspaceDir(), params.filePath);
197977+
const absPath = isAbsolute7(params.filePath) ? params.filePath : resolve12(getUserWorkspaceDir(), params.filePath);
197968197978
const docUri = pathToFileURL4(absPath).href;
197969197979
return { absPath, docUri };
197970197980
}
@@ -198394,7 +198404,7 @@ function registerLanguageResources(server) {
198394198404

198395198405
// src/prompts/workflow-prompts.ts
198396198406
import { access as access2 } from "fs/promises";
198397-
import { basename as basename10, isAbsolute as isAbsolute7, normalize, relative as relative3, resolve as resolve13, sep as sep4 } from "path";
198407+
import { basename as basename10, isAbsolute as isAbsolute8, normalize, relative as relative3, resolve as resolve13, sep as sep4 } from "path";
198398198408
import { fileURLToPath as fileURLToPath3 } from "url";
198399198409

198400198410
// src/prompts/constants.ts
@@ -198826,11 +198836,11 @@ async function resolvePromptFilePath(filePath, workspaceRoot) {
198826198836
}
198827198837
const effectiveRoot = workspaceRoot ?? getUserWorkspaceDir();
198828198838
const normalizedPath = normalize(effectivePath);
198829-
const inputWasAbsolute = isAbsolute7(normalizedPath);
198839+
const inputWasAbsolute = isAbsolute8(normalizedPath);
198830198840
const absolutePath = inputWasAbsolute ? normalizedPath : resolve13(effectiveRoot, normalizedPath);
198831198841
if (!inputWasAbsolute) {
198832198842
const rel = relative3(effectiveRoot, absolutePath);
198833-
if (rel === ".." || rel.startsWith(`..${sep4}`) || isAbsolute7(rel)) {
198843+
if (rel === ".." || rel.startsWith(`..${sep4}`) || isAbsolute8(rel)) {
198834198844
return {
198835198845
blocked: true,
198836198846
resolvedPath: "",

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

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module languages/go/tools/test/CallGraphFrom
22

3-
go 1.21.13
3+
go 1.21
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module languages/go/tools/test/CallGraphFromTo
22

3-
go 1.21.13
3+
go 1.21
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module languages/go/tools/test/CallGraphTo
22

3-
go 1.21.13
3+
go 1.21

server/src/lib/cli-tool-registry.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,11 +763,21 @@ export function registerCLITool(server: McpServer, definition: CLIToolDefinition
763763
}
764764

765765
// Process the result
766-
let processedResult = resultProcessor(result, params);
767-
768-
// Append DIL file path to the response for codeql_query_compile
766+
let processedResult: string;
769767
if (dilFilePath) {
768+
// DIL output was successfully persisted to a file. Don't echo the
769+
// full DIL back through stdout — it can be very large and would
770+
// exceed MCP response size budgets / degrade LLM performance.
771+
// Surface only a short summary plus the file path; preserve any
772+
// stderr (warnings/info) the CLI emitted for diagnostic value.
773+
const stdoutBytes = Buffer.byteLength(result.stdout ?? '', 'utf8');
774+
processedResult = `Compiled successfully. DIL output written to file (${stdoutBytes} bytes).`;
775+
if (result.stderr) {
776+
processedResult += `\n\nWarnings/Info:\n${result.stderr}`;
777+
}
770778
processedResult += `\n\nDIL file: ${dilFilePath}`;
779+
} else {
780+
processedResult = resultProcessor(result, params);
771781
}
772782

773783
return {

0 commit comments

Comments
 (0)