Summary
Prompt handlers that return string currently surface as JSON string literals in MCP prompt text.
Reproduction
app.Map("ops troubleshoot {symptom}", static (string symptom) =>
$"Investigate the checkout service for this symptom: '{symptom}'.")
.WithDescription("Generate troubleshooting instructions for an agent.")
.AsPrompt();
Call:
npx --yes @modelcontextprotocol/inspector --cli ./run-mcp.sh \
--method prompts/get \
--prompt-name ops_troubleshoot \
--prompt-args symptom="queue depth rising"
Observed prompt content:
{
"messages": [
{
"role": "user",
"content": {
"type": "text",
"text": "\"Investigate the checkout service for this symptom: \\u0027queue depth rising\\u0027. Start with ops_status, inspect failed checks, then propose the smallest safe next step.\""
}
}
]
}
The text contains the serialized JSON string, including extra quotes and escapes.
Expected behavior
Prompt text should be plain text, e.g.:
Investigate the checkout service for this symptom: 'queue depth rising'. Start with ops_status, inspect failed checks, then propose the smallest safe next step.
Likely cause
McpToolAdapter forces --output:json for MCP command execution. When a Repl handler returns a string, the CLI output is a JSON string literal. ReplMcpServerPrompt.GetAsync() then forwards that text directly into TextContentBlock.
There is already a similar unwrapping pattern for MCP App UI resources (ReplMcpServerUiResource.UnwrapJsonString). Prompts may need equivalent handling, or prompt execution may need a prompt-specific output path.
Environment observed
- Repl.Mcp:
0.11.0-dev.56
- .NET SDK:
10.0.301
- OS: Ubuntu 24.04 linux-x64
Summary
Prompt handlers that return
stringcurrently surface as JSON string literals in MCP prompt text.Reproduction
Call:
npx --yes @modelcontextprotocol/inspector --cli ./run-mcp.sh \ --method prompts/get \ --prompt-name ops_troubleshoot \ --prompt-args symptom="queue depth rising"Observed prompt content:
{ "messages": [ { "role": "user", "content": { "type": "text", "text": "\"Investigate the checkout service for this symptom: \\u0027queue depth rising\\u0027. Start with ops_status, inspect failed checks, then propose the smallest safe next step.\"" } } ] }The text contains the serialized JSON string, including extra quotes and escapes.
Expected behavior
Prompt text should be plain text, e.g.:
Likely cause
McpToolAdapterforces--output:jsonfor MCP command execution. When a Repl handler returns astring, the CLI output is a JSON string literal.ReplMcpServerPrompt.GetAsync()then forwards that text directly intoTextContentBlock.There is already a similar unwrapping pattern for MCP App UI resources (
ReplMcpServerUiResource.UnwrapJsonString). Prompts may need equivalent handling, or prompt execution may need a prompt-specific output path.Environment observed
0.11.0-dev.5610.0.301