- Start the server (stdio mode for the demo).
- Observe the MCP handshake and the
resources/listexchange in the Inspector. - Examine how a resource is declared in the server code and what it returns.
resources/list; the server responds with a resource entry describing a fleet summary resource.
The Inspector displays the resource entry with a short description and a MIME type of text/plain. The resource is exposed under a URI like shipment://fleet/summary. The server stores a text representation for that URI which the client can read on demand.
Example content returned by the resource (as shown by the Inspector):
- Resources are application-controlled, read-only artifacts. The host (your application) decides what to read and when to provide their contents to a model.
- The client asks the server for a list of available resources. The client then fetches a resource and supplies its contents to the model when relevant to the task.
- Resource reads must be side-effect free. If reading something mutates state, it should be implemented as a tool (not a resource).
Resources are read-only, application-controlled artifacts. They provide contextual data to the model but are never automatically accessed by the model itself.
Inspecting the registration and server configuration
The server registers itself with the MCP runtime usingmcp.json (stdio example):
server.py we register an application resource with a URI using @server.resource(...). Below is the relevant fragment showing the resource registration and the server run logic:
- The decorator
@server.resource("shipment://fleet/summary")registers the resource URI with the server so clients can discover it viaresources/list. fleet_summary()iterates over theSHIPMENTSfixture, tallies statuses, and returns a plain-text summary. This returned string is exactly what clients (and the Inspector) see when requesting the resource.- Because the function returns a static/plain text summary (no side effects), it fits the resource model. Any version that mutates state should instead be a tool.
Notes about running the server and fetching the resource
- Default (stdio): run without flags to integrate with the MCP Inspector and demo client.
- HTTP mode: run with
--httpto serve MCP over HTTP. This setsjson_response=Trueso curl and the Inspector’s Network tab show a readable body rather than an SSE stream.
--http):
- Historically, resources are explicitly application-controlled: the host decides when to fetch them and when to supply them to the model. The model does not autonomously fetch resources from the server — the client mediates access.
- In later lessons we’ll examine handlers and explore the
trace_journeytool inserted intoserver.py. Tools are the mechanism the model CAN reach for (they are not passive, read-only artifacts).
- MCP overview and protocol concepts
- SSE (Server-Sent Events) explanation
- Python packaging and virtual environments