#29 AI agents and MCP 5.3 min
MCP Resources and Prompts, Not Just Tools
Tools are only one of three things an MCP server can offer. Here are the other two, and the one default that stopped a file leak.
List what the server offers
Copy the code folder first. With the mcp package from the video installed, run python client.py. Check that you see one tool, one resource, one template and one prompt, and that the prompt role is user. Then write down, for each of the four, who decides when it is used: the model, the application or the user.
A hint
The video's own run listed book_slot, shop://opening-hours, shop://docs/{+path} and quote_reply.
See why a path can escape
In a Python prompt in the code folder, set docs to Path('docs').resolve() and build two paths: (docs / 'returns.txt').resolve() and (docs / '../staff_pay.txt').resolve(). For each, check whether its parent equals docs. Predict first. We got True for the first and False for the second, and the second file exists. Write one sentence on what the SDK's path check protects.
A hint
Import Path from pathlib. The two dots mean one folder up.
Add a policy document
Create docs/shipping.txt with one line that starts with Shipping:, then change client.py to read shop://docs/shipping instead of warranty. Predict what the line labelled warranty in the output now shows (the label stays the same), then run python client.py with the mcp package installed. This is a prediction task: we did not run the server.
A hint
The resource template adds .txt to the path, so use the name without the extension.
Add a second prompt
In server.py add a second prompt function called order_update that takes a customer and an order number and returns a short message. Write it like quote_reply, with the decorator and a docstring, and put it above the line that starts with if __name__, because that block starts the server and anything written after it is never registered. Predict what the prompts line in python client.py shows, then run it with the mcp package installed. This is a prediction task: we did not run the server.
A hint
Use the same decorator as quote_reply. The prompts line prints the names of all prompts.
These tasks are for you to try on your own machine. Nothing is checked or saved.
What this does not show
The shop and every file are made up, including the private one. Tested with the SDK's own client only, one template form and one transport. The path check covers template arguments, not other ways to build a path.
Up next in AI agents and MCP
More in AI agents and MCP
- #01 Local AI Agent in Python: No API Key (Ollama)
- #12 Multi-Agent Patterns in Plain Python: Pipeline, Router, Loop
- #22 OpenAI Agents SDK vs LangGraph vs Plain Python
- #23 Agent Memory: What to Keep and What to Forget
- #24 Approval Gates for Risky Agent Actions
- #25 Tool Errors: Retries, Fallbacks and Made-Up Answers
Related videos
- #292 MCP Explained Simply: A Flight Booking Demo in Python AI agents and MCP
- #231 MCP Gateway: Per-Tool Policy for Agent Tools (Python) Enterprise architecture and AI agents
- #28 Build an MCP Client That Uses Many Servers in Python AI agents and MCP
- #30 MCP Over HTTP: Remote Servers and a Token Check AI agents and MCP
