Skip to content

[week-05] 25620024 -- lab steps 2-4: week-01 tools as an MCP server, week-01 loop as an MCP host - #1

Closed
dragonash22 wants to merge 31 commits into
mainfrom
week-05/25620024
Closed

dragonash22 wants to merge 31 commits into
mainfrom
week-05/25620024

Conversation

@dragonash22

Copy link
Copy Markdown
Owner

Work in progress. This covers the week-05 lab only, steps 2 to 4 of 7. The graded assignment (negotiation market server) has not been started, so check_week05.py does not pass yet. Everything lives under submissions/25620024/week-05/lab/.

What I built

The week-01 tools now run behind an MCP server, and the week-01 agent loop is now an MCP host that uses them.

  • lab/tools_server.py (step 2): calculator and read_file copied unchanged from week-01, each marked with @mcp.tool(). The hand-written TOOLS schema list is gone. The MCP SDK v2 (MCPServer) builds each tool's description from its docstring and its inputSchema from its type hints. The server runs over stdio by default, or over Streamable HTTP at http://127.0.0.1:8000/mcp with --http.
  • lab/logs/step3-curl.txt (step 3): requests sent by hand with curl.
    • (A) a correct tools/list returns 200 with both tools.
    • (B) the same request without the Mcp-Method header returns 400 (-32020, header does not match the body).
    • (C) the same request without clientCapabilities in _meta returns 400 (-32602).
    • (D) tools/call calculator 48000+9500 returns 57500.
  • lab/host.py (step 4): the week-01 loop with two changes. TOOLS now comes from list_tools(), converted to the Anthropic tool format. TOOLS_IMPL[name](**args) is now call_tool(name, args). The tool's is_error flag is also passed through to the model. The rest of the loop is untouched.
  • lab/logs/step4-run-http-*.txt: the first host run over HTTP. It called read_file(notes.txt), then calculator("4 + 48000 + 9500 + 12000"), and answered 69504. The model left the date 2026-09-01 out of "every number" on its own.

What I tried and discarded

  • My first check of the generated tool list read tool.inputSchema. That fails in SDK v2, where the Python attribute is input_schema (the JSON field is still inputSchema). The bug was in my check script, not in the server.
  • Installing mcp>=2 replaced an existing mcp 1.25.0. Any old v1 code that imports mcp.server.fastmcp.FastMCP would now fail to import.
  • git checkout -b stalled for several minutes on the Google Drive-synced working copy and left a stale .git/index.lock. I stopped the process, removed the lock, and created the branch with git branch + git symbolic-ref, which leaves the working tree untouched.

How to run

pip install "mcp>=2" anthropic          # mcp 2.2.0, anthropic 0.79.0 used here
cd submissions/25620024/week-05/lab
python tools_server.py --http           # terminal 1
python host.py                          # terminal 2; needs ANTHROPIC_API_KEY, model claude-sonnet-4-5

Remaining

  • Lab step 5: choose the transport with MCP_SERVER, without touching the loop
  • Lab step 6: attach the same server to a second client (Claude Code)
  • Lab step 7: move write_note over without touching the host
  • The assignment itself: market server with bearer tokens, scenarios.json, results.csv, logs/, auth_checks.txt, REPORT.md

Checklist

  • python scripts/check_week05.py submissions/25620024/week-05 passes locally. It does not yet: only the .py parse check passes, and the other 5 fail because the assignment files do not exist.
  • Run logs are committed under logs/ (lab logs)
  • No API keys anywhere in the diff
  • History is not squashed

🤖 Generated with Claude Code

jaydenkim22 and others added 30 commits September 29, 2026 20:46
…(tools_server.py)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cp-Method or clientCapabilities gets 400

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ols(), execution via call_tool()

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ator via MCP, answer 69504

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o child, URL -> HTTP); loop untouched

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ol calls, both 69504

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…CP tools only) -- read_file then calculator, 69504

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ns read_file -> calculator -> write_note, result.md = 69504

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tted before any run

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tiation binding, turn checks, token-carried limits, injection, admin routes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a plain exception as 'Error executing tool'

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gent; auth_checks.txt re-run, all four reasons visible

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…luded) for the runner's attempted-violation audit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s bearer token; week-04 role prompts, identical across conditions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ernates host runs, audits the server record, appends results.csv, resumes; --out for smoke runs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es / 16 tool calls each, injection shown to buyer; both end open (no deal), kept out of results.csv

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…6 episodes done

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rpretation, discarded attempts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ewritten as terse bullet points

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, one point per line

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…abeled in 억 원 throughout

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…auth-check market server, not the lab server)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pt_inject attempts was the seller's (buyer-only 4 vs 3); run 2 scenario 4 buyer reached 380, not stayed below it

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dragonash22

Copy link
Copy Markdown
Owner Author

Closed without merging: the real submission is Q00#263. Merging this would put lab commits on the fork's main and break 'git merge --ff-only upstream/main'.

@dragonash22 dragonash22 closed this Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants