Skip to content

MCP results carry their JSON as text; instructions describe the result shape and how to run a plan - #24

Merged
joeldickson merged 1 commit into
mainfrom
fix/mcp-text-results
Oct 28, 2026
Merged

joeldickson merged 1 commit into
mainfrom
fix/mcp-text-results

Conversation

@joeldickson

Copy link
Copy Markdown
Contributor

Closes #21. Closes #23.

Why

Cursor, through the MCP gateway, shows the model only a tool result's content, and every ShipLean tool put the whole result in structuredContent with one summary line as the only text. In that client capture_plan couldn't be applied, nothing could be read back, and get_brief / planning_guide returned no guidance. So agents went looking in saved output, transcripts, ShipLean's source and MCP config. This happened again this morning: an agent asked to run UNF-64 got "The brief for UNF-64." and nothing else.

What changes

Every result also carries its JSON as text (#21). A new McpToolResult.Of builds every tool result, errors included. content is the summary line, then the Markdown for get_brief and planning_guide, then the same JSON as structuredContent. This is the spec's backwards-compatible shape. The seven reply helpers (WorkReply, PlanningReply, OrientReply, SprintReply, StatusReply, CaptureSupport.Reply, ToolErrorFilter.Result) keep their own serialization (OrientReply still drops nulls) and call it. Clients that read structuredContent see no change.

Summary lines name what the next call needs (#21, #23 item 5). The capture_plan, capture_work, plan_sprint and end_sprint previews now say "…with the plan value from the JSON below". The planning guide says to copy that token verbatim.

Server instructions (#23). These describe the result shape, and say what to do when a client hides everything but the summary line: tell the person, and don't search saved output, transcripts or source. They also give the run-a-plan route (get_brief on the Feature, get_brief per task, report_task), and say that these tools are the only way in.

Docs. docs/mcp.md has a new "Tool results" section, an updated error paragraph, and an "Adding a tool" note: return through your area's reply helper.

Trade-off

A client that shows both copies reads the result twice. get_brief and planning_guide carry the Markdown three times (as text, inside the JSON text, and in structuredContent). I kept the JSON block identical to structuredContent instead of stripping the Markdown from it, so the two copies can't drift. That's what #21's acceptance criteria ask for.

Tests

  • TextOnlyCapturePlanTests: preview → apply → plan_status, reading the plan token, created keys and the waves (with model and context per task) only from text. It also checks that a result's JSON text equals its structuredContent, and that an error carries its McpError as JSON text.
  • GetBriefTests, PlanningGuideTests: the summary line, then the Markdown, then the JSON.
  • OrientItemTests: get_work_item text JSON is the whole item (tags, children).
  • McpToolRulesTests: the guard rail fails for any type other than McpToolResult that builds tool-result content. A fixture shows that a hand-built reply is caught.
  • McpServerInstructionsTests: the instructions name get_brief and report_task, and describe the result shape and the only way in.

Run locally (Release, warnings as errors): ShipLean.WebApi, ShipLean.UnitTest and ShipLean.WebApi.Tests build clean. 28 MCP unit and guard-rail tests and all 427 MCP API tests (ShipLean.WebApi.Tests.Mcp) pass.

ShipLean.AcceptanceTests doesn't build on this machine: its SDK (10.0.113) reports S8969 in two journey files this PR doesn't touch. CI's newer 10.0.x builds main clean, so CI covers that project.

After deploy

#23's last criterion can only be checked live. Replay a "run this plan" prompt in Cursor: the agent should call get_brief on the Feature within its first few calls and read the waves, without listing saved files, grepping transcripts, or reading ShipLean's source or MCP config.

…t shape and how to run a plan (#21, #23)

Every tool result, errors included, is built by McpToolResult.Of: a summary line, the Markdown for get_brief and
planning_guide, then the same JSON as structuredContent, so a client that shows the model only text gets the whole
result. Preview summary lines name the plan value. The server instructions describe the result shape, the
run-a-plan route and that the MCP is the only way in. A guard-rail test fails for any other type that builds
tool-result content.
@joeldickson
joeldickson merged commit d1a95b8 into main Oct 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants