Use dynamic package version and respect CODEQL_MCP_TMP_DIR env var#27
Merged
data-douser merged 2 commits intomainfrom Feb 8, 2026
Merged
Use dynamic package version and respect CODEQL_MCP_TMP_DIR env var#27data-douser merged 2 commits intomainfrom
CODEQL_MCP_TMP_DIR env var#27data-douser merged 2 commits intomainfrom
Conversation
Collaborator
data-douser
commented
Feb 8, 2026
- Replace hardcoded version in language-server.ts with dynamic getPackageVersion() that reads from package.json (cached)
- Add getUserWorkspaceDir() for user-relative path resolution that falls back to process.cwd() in npm-installed (non-monorepo) layouts
- Honor CODEQL_MCP_TMP_DIR env var in temp-dir.ts for read-only package root scenarios (e.g., npm global installs)
- Move session-data-manager default storage from packageRoot to getProjectTmpBase() so it respects CODEQL_MCP_TMP_DIR override
- Fix misleading test name: "should accept valid CODEQL_PATH" was actually testing rejection of non-existent paths
- Add skipIf(win32) guard on sh-dependent PATH prepend test
- Replace hardcoded version in language-server.ts with dynamic getPackageVersion() that reads from package.json (cached) - Add getUserWorkspaceDir() for user-relative path resolution that falls back to process.cwd() in npm-installed (non-monorepo) layouts - Honor CODEQL_MCP_TMP_DIR env var in temp-dir.ts for read-only package root scenarios (e.g., npm global installs) - Move session-data-manager default storage from packageRoot to getProjectTmpBase() so it respects CODEQL_MCP_TMP_DIR override - Fix misleading test name: "should accept valid CODEQL_PATH" was actually testing rejection of non-existent paths - Add skipIf(win32) guard on sh-dependent PATH prepend test
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves runtime portability of the server across monorepo vs npm-installed layouts by making versioning/path/temp-dir handling dynamic and configurable via environment variables.
Changes:
- Add
getPackageVersion()andgetUserWorkspaceDir()utilities and use them for LSP clientInfo.version and user-relative path resolution. - Respect
CODEQL_MCP_TMP_DIRfor project temp data, and move session tracking storage under the project tmp base. - Adjust/skip brittle tests (rename misleading test; skip sh-dependent PATH-prepend test on Windows) and update the bundled
server/distoutput.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| server/test/src/lib/cli-executor.test.ts | Fixes misleading test name; skips sh/shebang-dependent test on Windows. |
| server/src/utils/temp-dir.ts | Allows overriding project tmp base via CODEQL_MCP_TMP_DIR. |
| server/src/utils/package-paths.ts | Adds dynamic package version lookup + “user workspace” resolution helper. |
| server/src/lib/session-data-manager.ts | Moves default monitoring storage to project tmp base. |
| server/src/lib/language-server.ts | Uses dynamic package version for LSP clientInfo.version. |
| server/src/lib/cli-tool-registry.ts | Resolves user-supplied relative paths against getUserWorkspaceDir(). |
| server/dist/codeql-development-mcp-server.js | Updates bundled output to reflect source changes. |
Comments suppressed due to low confidence (3)
server/src/lib/cli-tool-registry.ts:397
- Pack command
cwdresolution now usesgetUserWorkspaceDir()for relativedir/packDir, but existing tests only pass absolute paths. Please add coverage with a relativedir/packDirand assert the computedcwdmatches the effective user workspace base.
if ((name === 'codeql_pack_install' || name === 'codeql_pack_ls') && (dir || packDir)) {
const rawCwd = (dir || packDir) as string;
// Resolve relative paths against the user's effective workspace
// directory rather than a potentially read-only package root.
cwd = isAbsolute(rawCwd) ? rawCwd : resolve(getUserWorkspaceDir(), rawCwd);
}
server/src/utils/temp-dir.ts:23
- The new
CODEQL_MCP_TMP_DIRoverride path isn’t covered by tests. Please add unit tests to verify that when the env var is set,getProjectTmpBase()(and helpers) use it and still create directories under that base.
const PROJECT_TMP_BASE = process.env.CODEQL_MCP_TMP_DIR || join(getPackageRootDir(), '.tmp');
server/src/lib/cli-tool-registry.ts:233
- Relative
options.databasevalues forcodeql_query_runare now resolved againstgetUserWorkspaceDir(), but unit tests only cover absolute database paths. Please add a test that passes a relative database path and asserts the resolved absolute path is based on the effective user workspace (includingCODEQL_MCP_WORKSPACE).
case 'codeql_query_run': {
// Resolve database path to absolute path if it's relative
if (options.database && typeof options.database === 'string' && !isAbsolute(options.database)) {
options.database = resolve(getUserWorkspaceDir(), options.database);
logger.info(`Resolved database path to: ${options.database}`);
Collaborator
Author
|
@copilot apply changes based on the comments in this thread |
59 tasks
Contributor
|
@data-douser I've opened a new pull request, #28, to work on those changes. Once the pull request is ready, I'll request review from you. |
…tions (#28) * Initial plan * Fix import ordering, restore dot prefix, normalize temp dir paths, add unit tests Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> * Remove weak test case and document limitation in comment Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.