🛠️ Lab 9 — Trace a Live MCP Session (50 pts)

Goal: Map a running MCP connection onto the host-client-server model by hand, and prove to yourself that the JSON-RPC 2.0 data layer is identical whether it travels over stdio or over HTTP. Everything in this lab uses free, local, open-source tools — no paid API keys required. Steps:

  1. Install the official MCP Python SDK (pip install "mcp[cli]", SDK 1.2.0+) in a fresh virtual environment.
  2. Using the FastMCP decorator style from the MCP Python SDK, write a minimal local server (server.py) that exposes one Tool (e.g., get_word_count(text: str)), one Resource (e.g., a static readme://notes resource), and one Prompt template. Keep it under 40 lines.
  3. Run the server over stdio using the MCP Inspector (mcp dev server.py or npx @modelcontextprotocol/inspector, both free/local). Open the Inspector's network/message log and connect to your server.
  4. In the Inspector, step through the session and capture the raw JSON-RPC 2.0 messages for: (a) the initialize request/response handshake and the initialized notification, (b) tools/list and resources/list discovery calls, and (c) one tools/call execution with its result. Save these as screenshots or copy the raw JSON into a text file.
  5. Now change the transport: add a streamable-http run mode to the same server.py (the SDK supports this with a one-line change to the mcp.run(transport=...) call) and restart it as a local HTTP server on localhost.
  6. Reconnect the MCP Inspector to the HTTP endpoint instead of stdio, and repeat step 4 — capture the same three message types again.
  7. Write a one-page comparison memo: place the stdio and HTTP message captures side by side, highlight that the JSON-RPC method names, id fields, and payload shapes are identical, and explain in your own words which parts changed (only the transport envelope) and which didn't (the data layer).
  8. Add a short section mapping what you observed back to the host-client-server model: identify what played the role of Host, Client, and Server in your Inspector session.

Deliverables: Submit your server.py, your captured JSON-RPC message logs (stdio and HTTP), and your one-page comparison memo (PDF or text) as an upload, or paste the memo directly into the text-entry submission box.