Skip to content

Conversation

@rli
Copy link
Contributor

@rli rli commented Jul 11, 2025

Problem

On server startup, tool initialization failure can crash the entire LSP process

Solution

try/catch everything

2025-07-10 23:25:47,335 [1540490] INFO - software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLanguageClientImpl - [2025-07-11T06:25:47.287Z] MCP: registered tool load_test_report (original: load_test_report) 2025-07-10 23:25:47,335 [1540490] WARN - software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLanguageClientImpl - Failed to register tool load_test (original: load_test): SyntaxError: Invalid regular expression: /^arn\:/: Invalid escape at new RegExp (<anonymous>) at defaultRegExp (/Users/richali/idetools/language-server-runtimes/node_modules/ajv/dist/core.js:23:39) at usePattern (/Users/richali/idetools/language-server-runtimes/node_modules/ajv/dist/vocabularies/code.js:73:16) at Object.code (/Users/richali/idetools/language-server-runtimes/node_modules/ajv/dist/vocabularies/validation/pattern.js:19:109) at keywordCode (/Users/richali/idetools/language-server-runtimes/node_modules/ajv/dist/compile/validate/index.js:464:13) at /Users/richali/idetools/language-server-runtimes/node_modules/ajv/dist/compile/validate/index.js:222:17 at CodeGen.code (/Users/richali/idetools/language-server-runtimes/node_modules/ajv/dist/compile/codegen/index.js:439:13) at CodeGen.block (/Users/richali/idetools/language-server-runtimes/node_modules/ajv/dist/compile/codegen/index.js:568:18) at iterateKeywords (/Users/richali/idetools/language-server-runtimes/node_modules/ajv/dist/compile/validate/index.js:219:9) at groupKeywords (/Users/richali/idetools/language-server-runtimes/node_modules/ajv/dist/compile/validate/index.js:200:13) 2025-07-10 23:25:47,335 [1540490] INFO - software.aws.toolkits.jetbrains.services.amazonq.lsp.AmazonQLanguageClientImpl - [2025-07-11T06:25:47.297Z] MCP: registered tool graphql_introspect_schema (original: graphql_introspect_schema) 

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

logging.info(`MCP: registered tool ${namespaced} (original: ${def.toolName})`)
const loggedToolName = `${namespaced} (original: ${def.toolName})`
try {
agent.addTool(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure if we should ignore the tool or treat it as a tool validation error if the tool input schema is invalid

see runtimes:
https://github.com/aws/language-server-runtimes/blob/29920f37edf8117d40559d9bea5554d26b730e34/runtimes/runtimes/agent.ts#L34-L39

@rli rli marked this pull request as ready for review July 11, 2025 18:34
@rli rli requested a review from a team as a code owner July 11, 2025 18:34
@rli rli merged commit afdd6a4 into aws:main Jul 11, 2025
7 checks passed
@rli rli deleted the rli/mcp-catch branch July 11, 2025 21:14
laileni-aws added a commit that referenced this pull request Jul 14, 2025
* fix(amazonq): allow taking .jpg file as image context, add image cont… (#1814) * fix(amazonq): allow taking .jpg file as image context, add image context used to transparency list * fix(amazonq): fix comments * feat(flags): change flag name to enablewebformtransform(#1804) * feat(netTransform): rename EnableWebFormsToBlazorTransform to EnableWebFormsTransform * Revert "feat(netTransform): rename EnableWebFormsToBlazorTransform to EnableWebFormsTransform" This reverts commit 80b4c97. * Reapply "feat(netTransform): rename EnableWebFormsToBlazorTransform to EnableWebFormsTransform" This reverts commit e274513. * feat: produce agentic chat bundle from repo (#1827) * chore: configure .gitattributes to store files under app/aws-lsp-codewhisperer-runtimes/_bundle-assets with LFS * chore: add ripgrep assets to repo for bundling * chore: add qserver assets to repo for bundling * feat: produce agentic chat bundle * fix: imagecontext image name bug, mutliple images in pinned context (#1834) On windows, when we add an image using the options @image or @image: options, full file name is shown, we should only show file name. I was able to add only one image when I used @image context menu option, when I add another image, it does not show up in pinned context. This PR fixes these issues. * fix(amazonq): fix typo in image context list (#1836) * fix: adding files on VSC windows properly triggers reindexing (#1820) * fix: image context drag and drop fix on windows (#1837) * feat(amazonq): add transformation preferences functionality to input gen (#1792) * fix(amazonq): change the image filter used in open file dialog (#1838) * feat: passing partialResultToken to onInlineCompletionHandler result for EDITS (#1840) * fix: remove redundent thinking... for file operations (#1839) * feat(chat-client): add stringOverrides to createChat config (#1847) * refactor(amazonq): captilize constant variables, incremental code quality PR (#1843) * chore: create GitHub releases for agentic chat alpha, feature, and rc builds (#1832) * chore: set up lsp-codewhisperer-runtimes so that version can be queried * chore: create GitHub releases for agentic chat alpha, feature, and rc builds * fix: use correct commit, and support release candidate branches * feat: adding streakLength back for UserTriggerDecisionEvent (#1841) * fix: adding agenticcoding field to amazonqaddMessage metric(#1849) * refactor(amazonq): futher constant handling and creation of a helper (#1850) * chore: upgrade mynah-ui to 4.35.8 (#1853) * fix(amazonq): use config to render the overlay (#1851) * fix(amazonq): use config to render the overlay * fix(amazonq): fix typo * chore(release): release packages from branch main (#1823) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore: bump runtime version (#1856) * revert: create GitHub releases for agentic chat alpha, feature, and rc This reverts commit 10e04ba. * revert: produce agentic chat bundle from repo (#1827) (#1858) This reverts commit 0f71dd3. * revert: adding files on VSC windows properly triggers reindexing (#1820)" (#1860) This reverts commit 0c2d8eb. * revert: revert: adding files on VSC windows properly triggers reindexing (#18…" (#1862) This reverts commit 423cdbc. * chore: bump runtimes to 0.2.105 (#1863) * chore: add unit tests for codeWhispererServer.ts with editsEnabled (#1864) * fix(amazonq): add files created by fsWrite tool to @Files list (#1784) * fix(amazonq): remove the deep copy logic in updateRequestInputWithToolResults (#1870) * fix(amazonq): use structuredClone for deep copy of requestInput * fix(amazonq): remove the deep copy logic * Revert "fix(amazonq): remove the deep copy logic" This reverts commit 19c2993. * fix: use absolute file path for shell (#1871) * chore(release): release packages from branch main (#1861) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(amazonq): added full system information to the logs (#1875) * revert: adding streakLength back for UserTriggerDecisionEvent (#1877) This reverts commit 7052132. * feat: update UserTriggerDecisionEventStreakLengthInteger min value (#1878) * fix(amazonq): catch mcp initialization errors (#1873) On server startup, tool initialization failure can crash the entire LSP process * fix(amazonq): additional checks for binary and credential files (#1866) * fix: validate Create Prompt & Create Rule prompts input onChange (#1854) * fix: Forward slash shown in rules list in multi-root workspaces on windows (#1855) * fix: forward slash shown in rules list windows muti root workspace * fix: switch map to some * test: add unit tests * fix: send "thinking" in assistant response for pinned context * feat(amazonq): Adding QCodeReview tool to amazonQ (#1882) * feat: add QCodeReviewTool and QCodeAnalysisServer * feat: update QCodeReviewTool to support both file and folder level scans * fix: remove QFindingCritic references * feat: add support to scan code diff * feat: enhance code review tool with agentic scan capabilities - Remove codeSearch case from agenticChatController tool handling - Update QCodeReview to use AGENTIC_CODE_REVIEW upload intent - Change scan scope to AGENTIC for improved code review analysis - Add codeDiffMetadata support for code diff scanning * fix: replace timestamp-based scan names with UUID in code review tool - Use randomUUID() from crypto module instead of Date.now().toString() - Change scan name prefix from 'q-agentic-code-review-' to 'Standard-' - Improves uniqueness and follows standard naming conventions * fix: improve Q Code Review tool logging and schema handling - Update scan logging message for better clarity - Remove unused determineLanguageFromFolderContent method - Simplify zip file structure to use absolute paths - Add detailed logging for zip contents debugging - Make recommendation URL nullable in schema - Add optional findingContext field to finding schema * refactor(amazonq): extract utilities and improve Q Code Review organization - Extract git diff operations to QCodeReviewUtils for better reusability - Break down large prepareFilesForUpload method into focused smaller methods - Add centralized error handling with withErrorHandling wrapper - Improve code organization with proper imports and constants - Add zip utility methods for better maintainability - Add saveZipToDownloads functionality for debugging support - Enhance separation of concerns between main logic and utilities * feat: send message containing findings * feat(amazonq): add filePath to finding * feat: group findings by file * feat(amazonq): store constant for findings suffix * fix: refactor publish finding to code issues panel * fix: resolve absolute file path of llm findings when performing a folder scan * fix: add qCodeReview tool in standard tool list * fix: enhance Q Code Review tool with pagination and improved structure - Rename constants and schemas for better clarity and consistency - Add pagination support for findings retrieval using nextToken - Change response structure: jobId -> codeReviewId, findings -> findingsByFile - Improve error handling and logging throughout the tool - Enhance findings processing and aggregation logic - Add warning logs for unresolved file paths - Refactor type definitions and improve code organization * fix: show only code diff findings when customer asks for a code diff scan * fix: perform code review of code diff by default * fix: update code review tool implementation - Enhanced qCodeReview tool functionality - Updated toolServer configuration * fix: do not download zip artifact * fix: refactor qCodeAnalysis tool * fix: add scope-based reviews and improve architecture - Refactor monolithic execute() method into focused, testable functions - Add FULL_REVIEW vs PARTIAL_REVIEW scope detection based on user intent - Implement centralized error handling with consistent messaging - Add comprehensive telemetry for monitoring tool performance - Enhance tool description to position as primary code analysis tool - Improve timeout handling with configurable polling intervals - Add intelligent findings filtering based on review scope - Strengthen input validation and schema definitions This refactoring improves maintainability, adds intelligent scope detection, and provides better user experience through clearer tool positioning. * fix: increase range of prompts for q code review tool * fix: emit metrics * fix: remove unwanted changes * fix: restore missing formatting changes in test files * fix: remove unwanted changes * fix: remove unwanted changes * fix: add q code analysis server * fix: add q code analysis server as built in tool * fix: normalize finding and fileartifact path * Fix package failures * feat(amazonq): include rules in the file upload zip for QCodeReview * fix: add logs for custom guidelines and telemetry * fix: tool output prompt * fix: update tool output prompt to not show any summary * fix: increase scan timeout to 5 mins, remove unused variables and imports * feat: enhance Q Code Review tool with cancellation support and improved error handling - Add cancellation token support to allow users to cancel long-running code reviews - Implement structured InvokeOutput with success/failure indicators - Update schema to default to FULL_REVIEW for ambiguous scope requests - Improve error handling with consistent output formatting - Add cancellation checks at key processing points - Update controller to handle new output structure for findings display * fix: update chat with code review status * fix: update writer name * fix: update cancellation token handling * fix: update prompts to include limited findings, handle failures * fix: update qCodeReview tool description * fix: update qCodeReview tool description * fix: update qCodeReview tool description * fix: add logs for fetching findings * fix: revert changes * fix: update zip files and structure logging * fix: update qCodeReview supported extensions, do not need language in input * feat(amazonq): custom guidelines * fix(amazonq): do not use all context files, only the active rules in custom guidelines * fix(amazonq): ensuring the customer code base path is always the folder name * fix: update tool prompt * fix: update partial review to code diff review * fix: update tool prompt * fix: update scopeOfReview prompt * feat(amazonq): add agentic reviewer feature flag * fix: update uploaded file path to unix format always * fix: version update * fix: refactor tool, use file path in unix format always * fix: validate if there are files to scan other than rule artifacts * fix: add unit tests for qCodeReviewUtils, remove unused fields from qCodeReview tool initiation * fix: add qCodeReview tool test * fix: update qCodeReview tool enable flag to * fix(amazonq): refactor qcodereview tool with improved error handling and type safety - Add dedicated error classes (QCodeReviewError, QCodeReviewValidationError, QCodeReviewTimeoutError, QCodeReviewInternalError) - Create comprehensive type definitions in qCodeReviewTypes.ts for better type safety - Simplify error handling by using exceptions instead of error objects - Remove programmingLanguage field from file artifacts (now handled at tool level) - Improve result processing and aggregation logic - Add better path resolution with common suffix matching - Update tests to reflect new structure and error handling - Fix typo in schema description (abosolute -> absolute) - Enhance logging and error messages with more context - Streamline code review result structure and processing flow * fix: update block type when displaying tool updates * fix: fix unit tests for windows and mac * fix: fix unit tests for windows and mac --------- Co-authored-by: Nitish Kumar Singh <nkrsingh@amazon.com> Co-authored-by: Blake Lazarine <blakelaz@amazon.com> Co-authored-by: Nitish <149117626+singhAws@users.noreply.github.com> * feat(amazonq): allow opt-out for workspace context server (#1867) * feat(amazonq): allow opt-out for workspace context server * feat(amazonq): add overriding value for workspace context server opt-in * fix(amazonq): fix WCS behavior when administrator switch from opt-out to opt-in * fix(amazonq): fix WCS reSyncDependenciesToS3 method not working * chore(amazonq): add unit tests for WCS updateConfiguration * docs(amazonq): add comments for WCS remoteWorkspaceIdPromise variables * fix(amazonq): make WCS react correctly during close opt-in / opt-out flips --------- Co-authored-by: Jiatong Li <jiatonli@amazon.com> --------- Co-authored-by: yzhangok <87881916+yzhangok@users.noreply.github.com> Co-authored-by: Rajanna-Karthik <karsraja@amazon.com> Co-authored-by: Christopher Christou <39839589+awschristou@users.noreply.github.com> Co-authored-by: Lokesh <lodogga@amazon.com> Co-authored-by: chungjac <chungjac@amazon.com> Co-authored-by: jabouayash <57014884+jabouayash@users.noreply.github.com> Co-authored-by: atontb <104926752+atonaamz@users.noreply.github.com> Co-authored-by: Boyu <bywang@amazon.com> Co-authored-by: Avi Alpert <131792194+avi-alpert@users.noreply.github.com> Co-authored-by: abhraina-aws <abhraina@amazon.com> Co-authored-by: Laxman Reddy <141967714+laileni-aws@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Jason Guo <81202082+jguoamz@users.noreply.github.com> Co-authored-by: tsmithsz <84354541+tsmithsz@users.noreply.github.com> Co-authored-by: Richard Li <742829+rli@users.noreply.github.com> Co-authored-by: invictus <149003065+ashishrp-aws@users.noreply.github.com> Co-authored-by: Nitish Singh <nitish.rathore25@gmail.com> Co-authored-by: Nitish Kumar Singh <nkrsingh@amazon.com> Co-authored-by: Blake Lazarine <blakelaz@amazon.com> Co-authored-by: Nitish <149117626+singhAws@users.noreply.github.com> Co-authored-by: Jiatong Li <lijiatong1997@outlook.com> Co-authored-by: Jiatong Li <jiatonli@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants