Skip to content

Conversation

thoo
Copy link
Contributor

@thoo thoo commented Jul 5, 2025

Summary

Add MCP prompt support to enable user-controlled agent instruction generation. This enhancement allows MCP servers to provide prompts that can be used to dynamically generate agent instructions, enabling more flexible and user-controlled agent behavior.

Key changes:

  • Added abstract list_prompts() and get_prompt() methods to base MCPServer class
  • Implemented prompt support in MCPServerStdio and MCPServerStreamableHttp classes
  • Added comprehensive test suite for prompt functionality
  • Created example MCP prompt server with working demonstration
  • Updated documentation with prompt usage examples

Note: This PR implements MCP prompt support only. Resource support is not included in this implementation.

Test plan

  • Unit tests: Added 11 comprehensive tests in tests/mcp/test_prompt_server.py covering:
    • Prompt listing and retrieval
    • Argument formatting and validation
    • Agent integration with prompt-generated instructions
    • Streaming and non-streaming scenarios
    • Error handling for missing prompts
  • Integration tests: Updated existing MCP test suite to handle new abstract methods
  • Example verification: Created working example with MCP prompt server and client
  • All tests pass: 450/450 tests passing after adding optional dependencies

Issue number

Partially addresses #544 (prompts only, resources not implemented)

Checks

  • I've added new tests (if relevant)
  • I've added/updated the relevant documentation
  • I've run make lint and make format
  • I've made sure tests pass

@seratch seratch added enhancement New feature or request feature:mcp labels Jul 8, 2025
@seratch
Copy link
Member

seratch commented Jul 8, 2025

Sorry, I should have checked this PR before #1013 but you both are trying to add the same feature; I don't have further time to check details today but if necessary, sharing your knowledge with each other would be appreciated.

@rm-openai rm-openai merged commit d1d2ecc into openai:main Jul 8, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature:mcp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants