Lesson 12 MCP Concepts & Protocol
Theme:

Lab Guide — MCP Concepts & Protocol

Three exercises exploring MCP client connections, tool calls, and the server ecosystem.

Setup: Open lab.pdf in Jupyter. Install the MCP Python SDK: pip install mcp. The notebook uses a mock MCP server for Exercises 1–2, so no external server is required.

📥 Lab Notebooks

⬇ lab.pdf ⬇ lab_answer.pdf

📥 Demo Files

⬇ claude_desktop_config.json

Exercise 1 — MCP Client: Connect & List Tools

EX 1

Connect to an MCP server and discover its capabilities

Using the MCP Python SDK, create a client session that connects to a server process and lists its available tools.

  1. Create an MCP ClientSession connected via stdio transport
  2. Call initialize() to perform the capability handshake
  3. Call list_tools() and print each tool’s name, description, and input schema
# Expected output format:
# Tool: read_file
#   Description: Read the contents of a file
#   Parameters: {"path": {"type": "string"}}
# Tool: list_directory
#   Description: List files in a directory
#   Parameters: {"path": {"type": "string"}}

Checkpoint: You can list all tools from the connected server with their schemas.

Exercise 2 — Call a Tool via MCP

EX 2

Execute a tool call through the MCP protocol

Use the client session to call a tool and process the result.

  1. Call a tool using session.call_tool(name, arguments)
  2. Parse the response content
  3. Handle errors (invalid tool name, missing parameters)
# Call a tool
result = await session.call_tool("read_file", {"path": "/tmp/test.txt"})
print(result.content[0].text)

Checkpoint: You can call a tool, receive its result, and handle error cases.

Exercise 3 — MCP Server Survey

EX 3

Research 5 popular MCP servers

Survey the MCP ecosystem and document 5 servers. For each, record:

Compile your findings into a comparison table in the notebook.

Checkpoint: A completed table with 5 servers, their capabilities, and use cases.

Tip: Start your survey at github.com/modelcontextprotocol/servers. The README lists official and community servers with descriptions.