Day 1 - Block 5
We know how to use use tools …
… but how do we build them?
<!-- Too verbose — the agent already knows what PDFs are -->
## Extract PDF text
PDF (Portable Document Format) files are a common file format that contains
text, images, and other content. To extract text from a PDF, you'll need to
use a library. pdfplumber is recommended because it handles most cases well.
<!-- Better — jumps straight to what the agent wouldn't know on its own -->
## Extract PDF text
Use pdfplumber for text extraction. For scanned documents, fall back to
pdf2image with pytesseract.
import pdfplumber
with pdfplumber.open("file.pdf") as pdf:
text = pdf.pages[0].extract_text()SKILL.md is high level; Precision: Use scripts!
# Agent-friendly script usage
python scripts/tool.py --help
python scripts/tool.py --input data.csv --format jsonUse an AI agent to create skills: skill-creator
weather.py
from mcp.server.fastmcp import FastMCP
# Initialize FastMCP server
mcp = FastMCP("weather")
def call_weather_api(city: str, date: str) -> dict[str, Any] | None:
"""Make a request to the Weather API"""
headers = {"City": city, "Date": date}
response = client.get(
api_key=WEATHER_API_KEY,
headers=headers,
timeout=30.0)
return response.json()
@mcp.tool()
async def get_weather(city: str, date: str) -> str:
"""Get weather information for a city.
Args:
city: Name of the city
date: Date for which to get weather information; options are "today", "tomorrow", or "YYYY-MM-DD"
"""
try:
data = call_weather_api(city, date)
except Exception as e:
return f"Error fetching weather data: {str(e)}"
return "\n---\n".join(data)Run your server in a terminal:
In the settings of your agent (e.g. MCP servers, …) add
TI Workshop | D1 B5