Skip to content

Conversation

jlhood
Copy link
Contributor

@jlhood jlhood commented Sep 21, 2025

Issue #, if available: #2789

Description of changes:

This PR improves the MCP prompts feature, focusing on better user experience and discoverability:

New Features

  • Details command: Added /prompts details to show comprehensive prompt information including metadata and argument details
  • Enhanced list view: Improved /prompts list with three-column layout showing descriptions and better formatting
  • Content preview: Display fetched prompt content before AI processing to eliminate user confusion

Improvements

  • Better error handling: Replace raw JSON MCP server errors with user-friendly, actionable messages
  • Usage guidance: Generate helpful usage examples from PromptBundle data for invalid parameter errors
  • Visual formatting: Consistent terminal styling and proper content display for all prompt message types

Here are screenshots to see key differences before and after these changes:

/prompts list before fix:
Screenshot 2025-09-21 at 16 05 40

/prompts list after fix:
Screenshot 2025-09-21 at 16 05 49

New /prompts details command:
Screenshot 2025-09-21 at 16 07 23

Invoking a prompt now displays the prompt before sending to the model:
Screenshot 2025-09-21 at 16 28 46

Better error messaging (no longer just raw MCP server responses):

Before fix:
Screenshot 2025-09-21 at 16 31 25

After fix:
Screenshot 2025-09-21 at 16 31 34

🤖 Assisted by Amazon Q Developer

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

- Add description display in three-column layout (Prompt | Description | Arguments)
- Implement description truncation at 40 characters with ellipsis
- Handle missing descriptions with '(no description)' placeholder
- Support multi-line descriptions by showing first line only
- Fix existing bug in longest_name calculation for proper alignment
- Add comprehensive tests for description formatting functions

🤖 Assisted by Amazon Q Developer
Add new Details subcommand to show comprehensive prompt information
including full metadata and argument details. This addresses the
discoverability issue where users couldn't easily understand prompt
capabilities and requirements.

- Add Details variant to PromptsSubcommand enum
- Implement prompt resolution with server/prompt disambiguation
- Add detailed formatting for prompt metadata and arguments
- Include usage examples in details display
- Maintain consistent error handling with existing patterns
- Add comprehensive unit tests for new functionality

🤖 Assisted by Amazon Q Developer
Replace raw JSON MCP server errors with helpful, actionable error messages:
- Handle -32602 (Invalid params) with usage hints and argument descriptions
- Handle -32603 (Internal error) with user-friendly retry message
- Parse MCP error JSON to identify specific subcases
- Generate usage examples from PromptBundle data
- Preserve existing good error handling for PromptNotFound and AmbiguousPrompt

Addresses GitHub issue aws#2789 UX improvement for MCP prompt error handling.

🤖 Assisted by Amazon Q Developer
Display retrieved MCP prompt content immediately after fetching from server
to eliminate user confusion about what happens during 'Thinking' phase.
Users now see exactly what prompt was retrieved before AI processing begins.

- Add display_prompt_content helper function with proper terminal formatting
- Handle all PromptMessageContent variants (Text, Image, Resource, ResourceLink)
- Preserve existing error handling and AI processing flow
- Use consistent crossterm styling with existing prompt commands

🤖 Assisted by Amazon Q Developer
@mr-lee mr-lee requested review from brandonskiser, dingfeli and mr-lee and removed request for brandonskiser September 22, 2025 16:56
Successfully merged upstream file-based prompt system with existing MCP
prompt details and error handling features:

- Integrated upstream's file-based local/global prompt system
- Preserved MCP prompt details command with server disambiguation
- Maintained enhanced MCP error handling with user-friendly messages
- Combined both file-based and MCP prompt listing in unified display
- Resolved all merge conflicts and duplicate code

🤖 Assisted by Amazon Q Developer
- Add conflict warning when file-based prompt shadows MCP prompt with same name
- Fix missing usage details for fully qualified MCP prompt names (@server/prompt)
- Remove redundant 'Fetched prompt:' header from both MCP and file-based prompts
- Extract actual prompt name from qualified names for proper error handling
- Add comprehensive tests for new functionality

🤖 Assisted by Amazon Q Developer
When both file-based and MCP prompts exist with the same name, the
/prompts details command now shows a warning and guidance on how to
access the MCP prompt using the fully qualified server/prompt syntax.

This provides consistent behavior with prompt execution (@prompt-name).

🤖 Assisted by Amazon Q Developer
@jlhood
Copy link
Contributor Author

jlhood commented Sep 26, 2025

Addressed merge conflicts and aligned file-based prompts with my changes. Here's some examples of how the features interact more seamlessly now.

Screenshot 2025-09-25 at 20 57 50 Screenshot 2025-09-25 at 20 58 01

Copy link
Contributor

@mr-lee mr-lee left a comment

Choose a reason for hiding this comment

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

Re-approving - new changes look good.

Things we need to fix, but aren't introduced by this PR:

  1. We desperately need a UX library for console/terminal print commands, these are getting to be unmaintainable.
  2. There's a bunch of magic numbers for the UX formatting to work right. We should move those into the aforementioned UX framework.
  3. We do a lot of error message parsing from MCP server errors, if only because I don't believe there is a well-defined error communication format for us to consume. Ideally we can abstract this and make it a bit cleaner going forward.

@mr-lee mr-lee merged commit a3cf79b into aws:main Sep 26, 2025
1 check passed
@jlhood jlhood deleted the prompts branch September 26, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants