Lab 10 — MCP + Semantic Kernel / Agent Framework

Goal. Make the two "good to have" agent technologies concrete and runnable: MCP (Model Context Protocol) and Semantic Kernel (now folded into the Microsoft Agent Framework). You'll build a minimal MCP client/server and a minimal SK-style kernel from scratch, then bridge them — proving the headline point: MCP decouples tools from frameworks, so a tool written once is usable by any host. Read K03 §7-9.

Stack. Pure Python standard library + pytest — no SDKs, no Azure.

Concepts (from zero)

Semantic Kernel pioneered the "kernel hosts plugins" model: you write plugins (classes) whose methods are kernel functions (decorated with a name + description = the schema an LLM reads), and the kernel registers and invokes them; an LLM planner picks which to call. In 2025 SK + AutoGen converged into the Microsoft Agent Framework — same idea, unified runtime, Foundry-native. sk_mini.py captures the kernel/plugin/function shape; the real SDK adds the LLM planner, Azure OpenAI connectors, memory, filters, and telemetry.

MCP is an open client–server protocol (JSON-RPC) that standardizes how an LLM host discovers and uses external capabilities. A server exposes:

  • tools — callable functions (tools/list, tools/call),
  • resources — readable data/context by URI (resources/list, resources/read),
  • prompts — reusable templates (prompts/list, prompts/get).

The bank win: write your core-banking tools once as an MCP server with central auth/governance; any MCP-aware host (LangGraph, Foundry Agent Service, Claude, …) consumes them with no rewrite, and the server — not the prompt — enforces permissions. mcp_mini.py implements this in-process; the real protocol runs over stdio/HTTP.

Run it (offline)

pip install -r requirements.txt        # only pytest
python run.py                          # SK kernel + MCP client/server + the bridge
pytest -q                              # 8 tests

Code tour

FileTeaches
sk_mini.pya Semantic-Kernel-style Kernel + @kernel_function plugins + a BankingPlugin
mcp_mini.pya minimal MCP MCPServer/MCPClient (JSON-RPC: tools/resources/prompts) + a core-banking server whose tool enforces permissions itself
run.pydemos kernel invocation, MCP discovery/call, server-side permission enforcement, and the MCP→kernel bridge
test_lab.pysuccess criteria for both, incl. the bridge and the unauthorized-user block

Talking point

"Semantic Kernel's model is a kernel hosting plugins of typed functions an LLM planner can call; it and AutoGen converged into the Microsoft Agent Framework in 2025, Foundry-native. MCP is the open client–server protocol that decouples those tools from any one framework — I'd expose core-banking as an MCP server with central auth so the same governed tools work from LangGraph, Foundry Agent Service, or a kernel, and the server enforces permissions, not the prompt."