python-sdk icon indicating copy to clipboard operation
python-sdk copied to clipboard

Adding description field to the FastMCP get_prompt method

Open megandsouza03 opened this issue 9 months ago • 0 comments

Issue: https://github.com/modelcontextprotocol/python-sdk/issues/602

The GetPromptResult class has the field description, however it is not getting returned when using the FastMCP server.

Example

INFO     Processing request of type GetPromptRequest                                                     server.py:534
meta=None description=None messages=[PromptMessage(role='user', content=TextContent(type='text', text='ABCABCABCB', annotations=None))]

Expected behavior

INFO     Processing request of type GetPromptRequest                                                     server.py:534
meta=None description="This prompt summarizes the brave search data" messages=[PromptMessage(role='user', content=TextContent(type='text', text='ABCABCABCB', annotations=None))]

Motivation and Context

Currently, retrieving both the description and messages for a prompt requires two separate calls: one to list_prompts to get the prompt names, and then individual get_prompt calls for each prompt to fetch the full details. This adds unnecessary complexity and overhead, as we then have to manually map the results together to create a complete prompt object with both description and messages.

Proposed Change

Update theget_prompt to return the prompt details (including description and messages) directly, reducing complexity.

How Has This Been Tested?

  • Tested locally
  • Added a new test test_get_prompt_with_description

Breaking Changes

No breaking changes

Types of changes

  • [X] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] Documentation update

Checklist

  • [x] I have read the MCP Documentation
  • [x] My code follows the repository's style guidelines
  • [x] New and existing tests pass locally
  • [x] I have added appropriate error handling
  • [ ] I have added or updated documentation as needed

Additional context

megandsouza03 avatar May 02 '25 03:05 megandsouza03