MCP vs API: rename folder to match slug and sync code with the article - #850
Open
realpython-bot wants to merge 1 commit into
Open
realpython-bot wants to merge 1 commit into
realpython-bot wants to merge 1 commit into
Conversation
Consolidates the two open PRs on this folder into one. - Renames mcp-vs-api-calls/ to mcp-vs-api/ to match the tutorial slug (supersedes #819, minus its stray root-level uv.lock). - Syncs client.py and client_api.py with the tech-review changes in tutorial-drafts#1184: collect every tool_use block and append the assistant turn once, select the text block by type rather than position, and raise max_tokens to 2048 (supersedes #832). - Repairs the leftover fragments in #832: client_api.py did not parse, and client.py ran its __main__ block twice. - Points the README at the correct tutorial URL and the pinned install command. Code verified line-for-line against the article. ruff check and ruff format pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
realpython-bot
force-pushed
the
mcp-vs-api-materials
branch
from
September 16, 2026 15:31
10efbe5 to
d79776c
Compare
This was referenced Sep 16, 2026
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.
Consolidates the two open PRs on this folder (#819 and #832) into a single mergeable change, so there is one PR to review rather than three states of the same five files.
What's here
1. Rename
mcp-vs-api-calls/→mcp-vs-api/to match the tutorial slug. This is #819's change, minus its stray root-leveluv.lock(3 lines,masterhas no root lockfile — it looks accidental).2. Sync the client code with the tech review on realpython/tutorial-drafts#1184. Both clients now:
tool_useblock, append the assistant turn once, and return all results in a single user message, instead of appending per blocknext(b.text for b in final.content if b.type == "text")— rather thanfinal.content[0].text, which crashes when the model returns a thinking block firstmax_tokens=2048, since thinking tokens come out of the same budgetThis is #832's intent.
3. Repair two defects in #832 that would have shipped to readers:
client_api.pydid not parse — an orphaned fragment of the oldmain()was left belowif __name__ == "__main__":(SyntaxError: unexpected indent)client.pyhad a duplicatedif __name__ == "__main__":block, so it launched the server and ran the whole conversation twice4. README points at the correct tutorial URL (
/mcp-vs-api/) and the pinned install command.server.pyandtool.pyare unchanged — rename only.Verification
ruff checkpasses;ruff format --checkreports all five files already formattedmcp-vs-apisatisfies dircheck's folder-name ruleOpt-in
CMS Optin 1283's
download_urlnow points at.../tree/master/mcp-vs-api/, so it resolves automatically when this merges — the same pattern as the other in-flight tutorials, whose opt-ins also 404 until their materials land. Nothing to do at merge time.Supersedes #819 and #832. The code changes are @leriomaggio's work.
🤖 Opened by Claude Code (RPBot) on Stephen's behalf, with his permission. The review decisions behind it are his.