← Back to Pull requests

[Docs] Fix invented Python APIs in advanced topics and pin doc dependencies #1231

Open
unknown opened this pull request with 650 lines diff across 8 files
View on GitHub
unknown unknown commented on Nov 03, 2026 22:49 UTC
Author

Rebased onto main: #1227 is closed and its changes moved to the per-folder PRs #1233–#1254. This PR now contains only its own changes.

Why

  • 05-AdvancedTopics/mcp-realtimestreaming taught Python against modules that never existed in the MCP SDK (mcp.core.*, ServerOptions, …).

  • 05-AdvancedTopics/mcp-foundry-agent-integration pinned mcp==1.11.0, which the notebook never imports, and installed the Azure packages unpinned with -U. The azure-ai-projects API has also changed between major versions.

  • Example CI YAML in 11-MCPServerHandsOnLabs installed test and security tools unpinned.

  • AGENTS.md's "Python sample validation" command ran pytest -q in a folder with no tests (exit code 5), and the docs still listed Python 3.8+ / Node.js 18+ as minimums. mcp needs Python ≥ 3.10, Node 18 is end-of-life, and the current Inspector requires Node ≥ 22.19.
  • What changed

    mcp-realtimestreaming: rewrote the "MCP in Various Data Streaming Frameworks" section against the real mcp 2.3.0 API. It explains the two ways to combine MCP with a broker: put the broker behind an MCP server, or use it as the transport.

  • Kafka: an MCPServer with publish_reading and consume_window. The consumer streams each event with ctx.report_progress, commits offsets after processing, and returns a structured summary over Streamable HTTP. The matching mcp.Client receives the progress through progress_callback.

  • Pulsar: a custom transport that moves JSON-RPC messages between two topics, used by a low-level Server (on_list_tools / on_call_tool) and by mcp.Client.

  • Pins: mcp>=2.3.0,<3, aiokafka>=0.15.0,<1 (Python 3.11+, noted in the README), pulsar-client>=3.13.0,<4.
  • mcp-foundry-agent-integration (Python README sections and mcp_support_python.ipynb)

  • azure-ai-projects 2.x API: agents.create_version with PromptAgentDefinition and MCPTool(require_approval="always"), then get_openai_client(), conversations.create, and responses.create with agent_reference.

  • Approvals: handled via mcp_approval_request / McpApprovalResponse; the agent version is deleted at the end.

  • Dependencies: dropped the unused mcp==1.11.0 and azure-ai-agents==1.1.0b4. Now pinned: azure-ai-projects>=2.10.0,<3, azure-identity>=1.27.0,<2, openai>=3.44.0,<4. The notebook uses %pip and has its outputs cleared.
  • 11-MCPServerHandsOnLabs CI examples (10-Deployment, 12-Best-Practices): pytest>=9.2.0,<10, pytest-cov>=7.1.0,<8, pytest-asyncio>=1.4.1,<2, bandit[toml]>=1.9.4,<2. The labs' mcp 1.x choice is unchanged, since it follows the external sample repo.

    AGENTS.md

  • Python validation: cd 03-GettingStarted/samples/python && python -m pip install -r requirements.txt "pytest>=9.2.0,<10" && python -m pytest -q, which runs real tests.

  • Code style: Python 3.8+ → 3.10+.
  • Minimum versions in the docs

  • Python 3.8 → 3.10: 11-MCPServerHandsOnLabs README and 03-Setup, and python_requires in 06-CommunityContributions.

  • Node.js 18 → 22: 13-mcp-inspector now says 22.19+ (from @modelcontextprotocol/inspector's engines). 05-stdio-server TypeScript README and the module 10 table say 22 LTS.
  • Testing

  • AGENTS.md Python command: run exactly as written in a fresh Python 3.12 venv → 2 passed, exit 0.

  • mcp-realtimestreaming: all 5 Python blocks parse and import with mcp 2.3.0, aiokafka 0.15.0 and pulsar-client 3.13.0.

  • - The Kafka server and client ran as separate processes over Streamable HTTP: 4 progress notifications, then the structured summary.
    - The Pulsar-transport server and client ran tools/list and tools/call end to end.
    - No broker was available here, so these runs used small in-memory or file-backed stand-ins for aiokafka / pulsar.asyncio. The calls they mirror were checked against the real library signatures.
  • Foundry: the notebook is valid JSON with no outputs, and all 7 README Python blocks parse.

  • - Imports, config, client and tool construction ran for real against azure-ai-projects 2.10.0, azure-identity 1.27.0, and openai 3.44.0.
    - The agent create/delete calls ran against stubs matching the real SDK signatures, and the OpenAI traffic went to a mock transport so the real openai types parsed mcp_approval_request / mcp_call.
    - No Azure endpoint was contacted.
  • markdownlint-cli2 on the changed Markdown files: +21 line-length (MD013) findings from unwrapped paragraphs (the repo's usual style); one MD022 and one MD031 finding fixed.
  • Not changed

  • The Foundry .NET section (C# snippets are handled in a separate PR) and the notebook's RBAC role name (couldn't confirm the current name).

  • The rest of the 06-CommunityContributions Python example, which still uses an invented mcp_tools package (only python_requires was fixed).

  • GitHub Actions versions in the 10-Deployment example workflow (trivy-action@master, codeql-action@v2).

  • 03-GettingStarted/05-stdio-server/solution/typescript/package.json has @modelcontextprotocol/sdk >=1.26.0 with no major cap; that will be covered by the TypeScript SDK update.
  • 🤖 Generated with Claude Code

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: skytin1004 Review duration: 38523m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #1231"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 27.7% · Safe to merge
    27.7%