docs: add prompt client/server example to address #498#2465
Open
cubaseuser123 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Open
docs: add prompt client/server example to address #498#2465cubaseuser123 wants to merge 1 commit intomodelcontextprotocol:mainfrom
cubaseuser123 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
13c7b44 to
3bd7df8
Compare
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.
Added a runnable client/server snippet pair demonstrating the end-to-end flow for MCP prompts.
Motivation and Context
Following up on #498, it seemed like a good idea to add a full end-to-end example for prompts. I put together a minimal client/server pair that shows exactly how a client discovers
@mcp.prompt()definitions and retrieves their messages.This PR adds a minimal, runnable pair to clarify the flow:
examples/snippets/servers/prompt_server.py— defines two prompts covering both return styles: a plainstrand alist[Message]multi-turn thread. Registered in the snippets server dispatcher so it runs viauv run server prompt_server.examples/snippets/clients/prompt_client.py— connects via stdio, callslist_prompts()to discover what's available (with arguments), then callsget_prompt()for each and prints the resultingTextContent. Registered asuv run prompt-client.How Has This Been Tested?
uv run prompt-clientlocally to verify the full flow works end-to-end against the server.TextContentmessage boundaries.uv run ruff checkanduv run pyrighton the new files (0 errors).pytest tests/server/mcpserver/test_server.py), all 89 tests pass cleanly.Breaking Changes
None
Types of changes
Checklist
Additional context
Let me know if there's a preferred location for this, or if the docs site needs a dedicated Markdown page walking through the prompt flow as well. Happy to add that. Fixes #498.