
spring-2026-georgetown-university-dsan6725-applied-genai-for-ai-developers-spring-2026-lab06-mcp-ser created by GitHub Classroom
概览
Build an MCP (Model Context Protocol) server that exposes World Bank development data to AI agents like Claude. By completing this lab, you will: - Understand the difference between MCP (read-only data) and (executable actions) - Build an MCP server using transport - Integrate local CSV data with external REST APIs - Test your MCP server using the MCP Inspector and a Python client You will build an MCP server called world-bank-server that exposes: When complete, an AI agent can ask questions like: - "What's the GDP per capita of Germany?" - "Compare the population of USA, China, and India" - "Show me all indicators for Brazil from the local dataset" This lab intentionally uses local data (Resources) and API calls (Tools) to teach an important MCP design pattern: 1. - USA's GDP in 2015 is fixed forever. There's no reason to fetch it from an API repeatedly. 2. - Local file reads are ~1ms. API calls are ~200-500ms.
README
以下为原文 README 节选,完整内容请查看原文。
Week 4 Lab: Building a Streamable HTTP MCP Server
Build an MCP (Model Context Protocol) server that exposes World Bank development data to AI agents like Claude.
Learning Objectives
By completing this lab, you will:
- Understand the difference between MCP Resources (read-only data) and Tools (executable actions)
- Build an MCP server using Streamable HTTP transport
- Integrate local CSV data with external REST APIs
- Test your MCP server using the MCP Inspector and a Python client
Overview
You will build an MCP server called world-bank-server that exposes:
| Part | Type | Description |
|---|---|---|
| Part 1 | Resources | Read local World Bank indicator data from a CSV file |
| Part 2 | Tools | Fetch live data from REST Countries and World Bank APIs |
When complete, an AI agent can ask questions like:
- “What’s the GDP per capita of Germany?”
- “Compare the population of USA, China, and India”
- “Show me all indicators for Brazil from the local dataset”
Why Resources vs Tools? (Design Pattern)
This lab intentionally uses both local data (Resources) and API calls (Tools) to teach an important MCP design pattern:
| Resources (Local CSV) | Tools (API Calls) | |
|---|---|---|
| Data type | Historical indicators (2000-2023) | Current country metadata |
| Example | “GDP of USA in 2015” | “What’s the capital of USA?” |
Why not just call the API every time?
-
Historical data doesn’t change - USA’s GDP in 2015 is fixed forever. There’s no reason to fetch it from an API repeatedly.
-
Performance - Local file reads are ~1ms. API calls are ~200-500ms. For bulk queries across 200 countries, that’s the difference between instant and waiting 2 minutes.
-
Reliability - APIs can fail, have rate limits, or go down. Local data is always available.
-
Cost at scale - Many APIs charge per request or have rate limits. In production, you’d pay for every unnecessary API call.
-
Offline capability - Local resources work without internet. Your agent can still answer historical questions on an airplane.
-
Data consistency - You control the exact dataset version. APIs might update data or change formats unexpectedly.
The real-world pattern:
Cache what you can (Resources), fetch what you must (Tools)
In production MCP servers, you typically:
- Resources for: configuration, cached data, historical records, local files, database snapshots
- Tools for: real-time data, actions with side effects, data that changes frequently, external service integrations
This is why we split the lab this way - it mirrors how you’d actually build a production MCP server.
Prerequisites
- Python 3.11+
uvpackage manager installed- Basic understanding of async Python
- Familiarity with REST APIs
Project Structure
lab-week4-mcp-server/
├── data/
│ └── world_bank_indicators.csv # PROVIDED - World Bank data (do not modify)
安装
npx @modelcontextprotocol/inspector配置
{
"mcpServers": {
"world-bank": {
"type": "streamable-http",
"url": "http://127.0.0.1:8765/mcp"
}
}
}