Skip to content

Add MCP prompt SDK support for rich return types#212

Open
liliankasem wants to merge 2 commits intomainfrom
liliankasem/prompt-support-sdk
Open

Add MCP prompt SDK support for rich return types#212
liliankasem wants to merge 2 commits intomainfrom
liliankasem/prompt-support-sdk

Conversation

@liliankasem
Copy link
Copy Markdown
Member

@liliankasem liliankasem commented Mar 23, 2026

Issue describing the changes in this PR

resolves #issue_for_this_pr

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • I have added all required tests (Unit tests, E2E tests)

Additional information

Add FunctionsMcpPromptResultMiddleware to the Worker.Extensions.Mcp.Sdk
package, enabling prompt functions to return rich types (GetPromptResult,
PromptMessage, IList) instead of only plain strings.

The middleware follows the same pattern as FunctionsMcpToolResultMiddleware:

  • Intercepts prompt function results in the worker pipeline
  • Serializes them into McpPromptResult wrapper format
  • Host-side PromptReturnValueBinder deserializes and processes the wrapper

Supported return types:

  • GetPromptResult: serialized directly with description and messages
  • PromptMessage: wrapped in a single-element list
  • IList: serialized as message array
  • string/object: wrapped as text in a user PromptMessage (default)

@liliankasem liliankasem force-pushed the liliankasem/prompt-support-sdk branch from 32ee9b8 to 4be06f7 Compare April 7, 2026 16:00
@liliankasem liliankasem marked this pull request as ready for review April 7, 2026 16:01
@liliankasem liliankasem force-pushed the liliankasem/prompt-support-sdk branch from 4be06f7 to 08532d7 Compare April 7, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant