[UPDATE PRIMITIVE] Add MCP prompt argument completions for VS Code slash command UX#230
Draft
[UPDATE PRIMITIVE] Add MCP prompt argument completions for VS Code slash command UX#230
Conversation
Add completable() wrappers to workflow prompt parameters so VS Code Copilot Chat shows auto-complete dropdowns for language, query paths, SARIF files, database paths, and pack roots. - Create prompt-completions.ts with completion providers for each parameter type (language enum, .ql/.qlref files, .sarif files, CodeQL databases, codeql-pack.yml directories) - Update all 14 workflow prompt registrations to use addCompletions() - Add comprehensive unit tests (35 tests covering all completers and the addCompletions utility) Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/e316ece4-06c5-45d7-8020-062e6ec67e39 Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
- cloneStringType now accepts both ZodString and ZodEnum (for prompts that use raw schema.shape without toPermissiveShape) - Add runtime type checks that throw clear errors for unexpected types - Add 2 unit tests for ZodEnum handling in addCompletions Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/e316ece4-06c5-45d7-8020-062e6ec67e39 Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/e316ece4-06c5-45d7-8020-062e6ec67e39 Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Improve UX for ql-mcp workflow prompts in VS Code
[UPDATE PRIMITIVE] Add MCP prompt argument completions for VS Code slash command UX
Apr 7, 2026
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
Addresses three UX issues with MCP prompt argument completions: 1. Database discovery: completeDatabasePath now scans $HOME/codeql/databases/ as a default search location, and recursively discovers directories containing codeql-database.yml (including .testproj dirs) in the workspace. 2. Language auto-derivation: For prompts where queryPath is provided, language is now optional and auto-derived from the nearest codeql-pack.yml's codeql/<lang>-all or codeql/<lang>-queries dependency. Schema field ordering now puts queryPath before language so VS Code prompts for the query first. Affected schemas: explainCodeqlQuerySchema, documentCodeqlQuerySchema, workshopCreationWorkflowSchema, qlLspIterativeDevelopmentSchema. 3. Query path completion filtering: completeQueryPath now skips .github, dist, coverage, and build directories in addition to node_modules, .git, and .tmp — preventing workshop examples and build artifacts from cluttering the VS Code dropdown. New tests: 19 unit tests covering all three fixes. Updated tests: 9 existing tests updated to reflect language being optional.
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.
📝 Update Information
Primitive Details
✅ ALLOWED FILES:
server/src/**/*.ts)server/test/**/*.ts)extensions/vscode/test/**/*.ts)extensions/vscode/esbuild.config.js)🚫 FORBIDDEN FILES:
🛑 MANDATORY PR VALIDATION CHECKLIST
completion/completeresponses are new)🎯 Changes Description
Current Behavior
Workflow prompts used as VS Code Copilot Chat slash commands show raw text input fields for all parameters. Users must manually type full file paths for CodeQL queries, databases, SARIF files, etc., with zero guidance.
Updated Behavior
Prompt parameters now provide auto-complete suggestions via the MCP SDK's
completable()function. VS Code shows a filtered dropdown as the user types:language— filtersSUPPORTED_LANGUAGESby prefixqueryPath— discovers.ql/.qlreffiles in workspacesarifPath/sarifPathA/sarifPathB— discovers.sarif/.sarif.jsonfilesdatabase/databasePath— lists CodeQL database directories fromCODEQL_DATABASES_BASE_DIRSand workspaceworkspaceUri/packRoot— finds directories containingcodeql-pack.ymlMotivation
The VS Code MCP integration supports
completion/completefor prompt arguments. The MCP SDK already shipscompletable()— we just weren't using it.🔄 Before vs. After Comparison
Functionality Changes
API Changes
No schema changes.
addCompletions()clones each targeted field to a freshz.string()withcompletable()metadata attached. Fields without registered completers pass through unchanged. Thecompletion/completeMCP capability is automatically advertised by the SDK when any completable field exists.Output Format Changes
New
completion/completeresponses:{ "completion": { "values": ["java", "javascript"], "hasMore": false, "total": 2 } }🧪 Testing & Validation
Test Coverage Updates
addCompletionsutilityworkflow-prompts.test.ts(309 tests) validates schema consistencyTest Results
mcp-completion-e2e.integration.test.ts📋 Implementation Details
Files Modified
server/src/prompts/prompt-completions.ts— completion providers +addCompletions()utilityserver/src/prompts/workflow-prompts.ts— 1 import + 14 lines: wrap eachserver.prompt()shapeserver/test/src/prompts/prompt-completions.test.ts— 37 unit testsextensions/vscode/test/suite/mcp-completion-e2e.integration.test.ts— 12 e2e testsextensions/vscode/esbuild.config.js— add new test entry pointCode Changes Summary
cloneStringTypevalidates input isZodStringorZodEnum, throws on unexpected typesaddCompletionsclones schemas before attachingcompletable()to avoid mutating shared schema constantsDependencies
@modelcontextprotocol/sdkv1.29 (completableexport)🔗 References
External References
completable()API🚀 Compatibility & Migration
Backward Compatibility
completion/completesimply never call it.API Evolution
👥 Review Guidelines
For Reviewers
addCompletions()is a pure wrapper — prompt behavior unchangedTesting Instructions
📊 Impact Assessment
Server Impact
addCompletionsruns once during registrationnode_modules/.gitAI Assistant Impact
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
update.code.visualstudio.com/opt/hostedtoolcache/node/24.13.0/x64/bin/node node scripts/download-vscode.js k/codeql-develop. gh ensi�� ST_VAR:-not_set} nt-mcp-server/node_modules/vitest/suppress-warnings.cjs cal/bin/echo echo ${MALICIOUSbash bash Query.ql nt-mcp-server/node_modules/vitest/dist/workers/forks.js test�� n/echo sh node_modules/.bin/bash(dns block)If you need me to access, download, or install something from one of these locations, you can either: