Use output converter MIME types for MCP resources#38
Merged
carldebilly merged 6 commits intoJun 26, 2026
Conversation
bd20936 to
a28e2a8
Compare
Contributor
Author
|
Addressed the review feedback in the updated head What changed:
Not addressed in this PR by design:
Local verification and CI are both green. |
carldebilly
reviewed
Jun 26, 2026
Contributor
Author
|
Addressed this review round in Changes made:
Verification:
|
Member
|
@codex Please review again |
Contributor
Author
|
Addressed the latest non-blocking review notes in Changes:
Verification:
|
Contributor
Author
Contributor
Author
|
Addressed the latest review round in Changes:
Verification:
|
Contributor
Author
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.
Summary
This PR closes #32 by making MCP command-backed resources advertise the MIME type that the Repl output pipeline actually emits.
The final design is intentionally converter-driven, not a per-resource label override: MCP resource reads currently force Repl commands through the JSON output path, so the truthful wire contract is
jsontransformer output +application/jsonmetadata.Closes #32
What changed
IOutputTransformer.MimeType, defaulting totext/plain.application/jsontext/markdownapplication/xmlapplication/yamltext/plainresources/listadvertises the forced MCP output MIME type instead of hard-codedtext/plain.resources/readso successful command-backed resources return the same forced output MIME type with the rendered command result.OKor paged summaries;null, preserving theapplication/jsoncontract.IReplIoContext.OutputandIReplIoContext.Errorwrites during resource reads so side-channel command output/diagnostics are not mixed into the resource body.dotnet testfor the real wire contract.Design notes
This PR does not add
.WithMimeType(...)or.AsResource(mimeType: ...).That was considered, but a label-only API would let a resource claim
text/markdown,text/html, or another media type while the current MCP command-backed resource implementation still emits the forced JSON output pipeline. That would make the protocol metadata less truthful, not more.Non-JSON resource bodies should be handled by a future resource-specific converter/blob design where the declared MIME type and emitted bytes are controlled together.
Testing guidance
Repl.Testingremains the right layer for command behavior:GetResult<T>()/TryGetResult<T>(...)validate handler return values before rendering.ReadJson<T>()validates rendered JSON command output.MCP resource MIME types are protocol metadata, so this PR validates them through:
The Inspector smoke test is intentionally off by default:
This keeps the normal merge-gating path hermetic:
dotnet test src/Repl.slnxdoes not require Node, npm, or npm registry access.Test plan
dotnet test src/Repl.McpTests/Repl.McpTests.csproj -c Release --filter 'FullyQualifiedName~Given_McpResourceParameters|FullyQualifiedName~Given_McpInspectorCli'— 13 passed, 1 skipped opt-in Inspector smokeREPL_RUN_MCP_INSPECTOR_TESTS=1 dotnet test src/Repl.McpTests/Repl.McpTests.csproj -c Release --filter 'TestCategory=ExternalToolchain'— 1 passeddotnet build src/Repl.slnx -c Release -warnaserror --no-restore— 0 warnings/errorsdotnet test src/Repl.slnx -c Release— 989 passed, 1 skipped opt-in Inspector smokenpx -y markdownlint-cli2 '**/*.md'— 0 errorsgit diff --check