examples/mcp/prompt_server/README.md
This example uses a local MCP prompt server in server.py.
Run the example via:
uv run python examples/mcp/prompt_server/main.py
The example uses the MCPServerStreamableHttp class from agents.mcp. The script auto-selects an open localhost port (or honors STREAMABLE_HTTP_PORT) and runs the server at http://<host>:<port>/mcp, providing user-controlled prompts that generate agent instructions.
If you need a specific address, set STREAMABLE_HTTP_PORT and STREAMABLE_HTTP_HOST.
The server exposes prompts like generate_code_review_instructions that take parameters such as focus area and programming language. The agent calls these prompts to dynamically generate its system instructions based on user-provided parameters.
The example demonstrates two key functions:
show_available_prompts - Lists all available prompts on the MCP server, showing users what prompts they can select from. This demonstrates the discovery aspect of MCP prompts.
demo_code_review - Shows the complete user-controlled prompt workflow:
generate_code_review_instructions with specific parameters (focus: "security vulnerabilities", language: "python")os.system)This pattern allows users to dynamically configure agent behavior through MCP prompts rather than hardcoded instructions.