Skip to content

Inventory Planning Agentic: fix Challenge 6 MCP step with a stdio client - #613

Open
Digvijay (Digvijay) wants to merge 1 commit into
microsoft:mainfrom
Digvijay:fix/inventory-agentic-challenge-06-mcp
Open

Digvijay (Digvijay) wants to merge 1 commit into
microsoft:mainfrom
Digvijay:fix/inventory-agentic-challenge-06-mcp

Conversation

@Digvijay

Copy link
Copy Markdown

Fixes a Challenge 6 (stretch) blocker in Agentic Inventory Planning, reported by Fatih Durgut while preparing a delivery.

Problem

Part C told participants to open a second terminal and run:

uv run python mcp_server.py

mcp_server.py is a stdio MCP server: it starts and silently waits for JSON-RPC messages from an MCP client on stdin. Run by hand, it looks hung, and pressing Enter sends a blank line, which produces:

Received exception from stream: 1 validation error for JSONRPCMessage
  Invalid JSON: EOF while parsing a value at line 2 column 0 [type=json_invalid, input_value='\n', input_type=str]

The challenge never gave participants an MCP client, so they couldn't complete Part C.

Changes

  • New src/mcp_client.py: a minimal MCP client built on the mcp package the hack already depends on. It launches mcp_server.py as a child process over stdio, lists its tools and calls inject_signal.
    # from src/, in a second terminal while the planner console runs
    uv run python mcp_client.py "Competitor out of stock on chainsaws in the West" --region West
  • Challenge 6, Part C:
    • rewritten around the client, with the expected output
    • an Important note not to run mcp_server.py by itself (Ctrl+C to stop it)
    • a troubleshooting row for the exact error above
    • GitHub Copilot Chat as an MCP host, added under Go further
  • Walkthrough solution-06.md: client command plus a coach note explaining the error.
  • mcp_server.py docstring, src/README.md, hack README layout: mention the client.
  • Dependency cap mcp>=1.2.0,<2: mcp 2.x removes mcp.server.fastmcp.FastMCP, which the server uses. uv.lock already pins 1.30.0, so current labs are unaffected, but the open range would break if the lock were ever regenerated. The lock change is only the specifier line; uv lock --check passes offline, so uv sync doesn't re-resolve.

Verified

With mcp 1.30.0 (the locked version), using a stub inventory_store instead of Cosmos:

  • mcp_client.py starts the server, finds inject_signal, calls it and exits 0.
  • Running mcp_server.py by hand and sending an empty line reproduces the reported error exactly.
  • With mcp 2.x the server fails to import FastMCP, which confirms the cap is needed.

Not tested live: the real Cosmos write and the console's change-feed reaction. The client calls the same append_signal path that the console's ⚡ Inject signal button already uses.

Workaround until merged: use the ⚡ Inject signal button in the console (Part B), which triggers the same reaction.

…r isn't run by hand

- Add src/mcp_client.py: launches mcp_server.py over stdio and calls inject_signal
- Challenge 6 Part C, walkthrough, READMEs: use the client; explain the 'Invalid JSON' error
- Cap mcp<2 (2.x removes FastMCP); lock still pins 1.30.0

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@fatihdurgut Fatih (fatihdurgut) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@Digvijay

Copy link
Copy Markdown
Author

Fatih (@fatihdurgut) - i would request Marco Weber (@qxsch) for review and merge - I can not do it myself

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