Move Prompt object instantiation from server to prompt manager#687
Closed
ramjibc wants to merge 0 commit intomodelcontextprotocol:mainfrom
Closed
Move Prompt object instantiation from server to prompt manager#687ramjibc wants to merge 0 commit intomodelcontextprotocol:mainfrom
Prompt object instantiation from server to prompt manager#687ramjibc wants to merge 0 commit intomodelcontextprotocol:mainfrom
Conversation
ihrpr
requested changes
May 23, 2025
Contributor
ihrpr
left a comment
There was a problem hiding this comment.
Thank you for working on this!
There are a few concerns:
- API Change for Direct Usage: The add_prompt() method signature changes from accepting a Prompt to accepting a function. This breaks backwards compatibility.
- Less Flexibility: With the old design, users could create custom Prompt objects with specific configurations before
adding them. Now they're forced to use the manager's instantiation logic. - Inconsistent Manager APIs: While this makes server decorators consistent, it makes the manager APIs inconsistent:
- ToolManager.add_tool() accepts both functions and Tool objects
- PromptManager.add_prompt() now only accepts functions
Author
|
Thank you for the review @ihrpr . I have addressed your comments, but primarily from the backward compatibility perspective. Also, I don't see this in code
I see In any case, I have made changes such that the code doesn't break for existing users but moves it a bit closer to achieving clear separation of concerns. Let me know your comments. |
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.
The
Prompt()decorator inserver.pyis instantiating a Prompt object before adding it to the list of prompts. This is inconsistent with how theTool()decorator works; it delegates tool instantiation to the tool manager.Motivation and Context
To make the decorators consistent and create clear separation of concerns: I have moved prompt object instantiation from
server.pytoprompts/manager.py.How Has This Been Tested?
I updated and ran all unit tests.
Breaking Changes
No. Users will not be impacted as the
prompt()decorator's signature remains unchanged.Types of changes
Checklist
Additional context
Separation of concerns: instantiation and managements of prompt objects should be done by the prompt manager, not the server.