Add structured MCP work proof guidance#317
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR adds JSON guidance capability to the MCP submit_work_proof tool. The MCP handler now routes dict results to result.structuredContent, and submit_work_proof accepts a format argument to return structured guidance objects for bounty-specific or generic cases, with new tests validating both paths and format validation. ChangesJSON Structured Guidance for submit_work_proof
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_api_mcp.py`:
- Around line 1159-1173: Add an assertion for the new structured "title" field
after structured = result["structuredContent"]; verify structured["title"]
equals the expected bounty title (use the existing bounty fixture or literal
expected string used elsewhere in this test suite, e.g., compare to the same
title used when creating the bounty or to result["content"][0]["title"]) so the
test covers the new contract field.
- Around line 1183-1211: Update the test in tests/test_api_mcp.py that posts to
client.post("/mcp",
json={"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"submit_work_proof","arguments":{"format":"json"}}})
so it also asserts the JSON text fallback is present and equal to the same
guidance; after obtaining result = ... .json()["result"]["structuredContent"],
add an assertion that the response's fallback text (e.g.
response.json()["result"]["text"] or whichever top-level key your API uses for
text fallback) matches the expected submission guidance string (the same value
used for structuredContent["submission_format"]) to ensure parity for text-only
MCP clients.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 743546d8-3520-4bd4-adb4-9acb9e2b9ac2
📒 Files selected for processing (2)
app/main.pytests/test_api_mcp.py
tolga-tom-nook
left a comment
There was a problem hiding this comment.
No blockers from my review.
Evidence checked:
- Inspected
app/main.pyandtests/test_api_mcp.pyagainst Bounty #315 acceptance criteria. - Confirmed omitted
format/ default text behavior remains unchanged, whileformat: "json"returns machine-readable bounty-specific guidance and generic no-selector guidance. - Confirmed invalid
formatvalues and non-string format values are covered by the existing invalid-argument path. - Ran focused MCP tests:
./.venv/bin/python -m pytest tests/test_api_mcp.py -q→ 67 passed. - Ran static validation:
./.venv/bin/python -m ruff check app/main.py tests/test_api_mcp.py,./.venv/bin/python -m mypy app, andgit diff --check origin/main...HEAD→ all passed.
One implementation detail I verified as useful: JSON-mode results are exposed both as structuredContent and as JSON text in the MCP content block, preserving compatibility for text-only MCP clients while giving structured callers actual fields.
ayskobtw-lil
left a comment
There was a problem hiding this comment.
No blockers from my review.
Evidence checked:
- Inspected the PR diff for
app/main.pyandtests/test_api_mcp.py. - Verified
formatparsing preserves the existing default text guidance, accepts case/whitespace-normalizedjson, and rejects unsupported or non-string format values through the existing JSON-RPC invalid-arguments path. - Confirmed JSON-mode bounty-specific guidance includes the expected public bounty fields, including
title, reward/capacity/availability values, issue URL, acceptance text, submission instructions, and safety rules. - Confirmed JSON-mode generic guidance returns structured guidance when no selector is supplied, while the MCP text
contentfallback is the same JSON object serialized for text-only clients. - Checked the follow-up commit addressed the prior CodeRabbit coverage comments for
titleand content/structured parity.
Validation run on current PR head 214a341:
python -m pytest tests/test_api_mcp.py::test_mcp_submit_work_proof_keeps_generic_guidance tests/test_api_mcp.py::test_mcp_submit_work_proof_returns_structured_bounty_guidance tests/test_api_mcp.py::test_mcp_submit_work_proof_returns_structured_generic_guidance tests/test_api_mcp.py::test_mcp_submit_work_proof_rejects_invalid_bounty_selectors -q->10 passedpython -m ruff check app/main.py tests/test_api_mcp.py->All checks passed!python -m ruff format --check app/main.py tests/test_api_mcp.py->2 files already formattedgit diff --check HEAD~2..HEAD-> clean
Refs #315
What changed:
formatargument to MCPsubmit_work_proof.formatis omitted or set totext.format: "json"support that returns machine-readablestructuredContentplus a JSON text fallback for clients that only inspect text content.Contributor / agent impact:
Validation:
uv run --with pytest pytest tests/test_api_mcp.py::test_mcp_submit_work_proof_returns_bounty_specific_guidance tests/test_api_mcp.py::test_mcp_submit_work_proof_keeps_generic_guidance tests/test_api_mcp.py::test_mcp_submit_work_proof_returns_structured_bounty_guidance tests/test_api_mcp.py::test_mcp_submit_work_proof_returns_structured_generic_guidance tests/test_api_mcp.py::test_mcp_submit_work_proof_reports_unknown_bounty tests/test_api_mcp.py::test_mcp_submit_work_proof_rejects_invalid_bounty_selectors tests/test_api_mcp.py::test_mcp_submit_work_proof_rejects_ambiguous_issue_number -q-> 13 passed.uv run --with ruff ruff check app/main.py tests/test_api_mcp.py-> passed.uv run --with ruff ruff format --check app/main.py tests/test_api_mcp.py-> passed.uv run --with mypy mypy app-> success.git diff --check-> clean.No private keys, seed material, secrets, deployment credentials, private vulnerability details, payout details, or price claims are included.
Summary by CodeRabbit
New Features
Tests