Resources are read-only data exposed by the server. A resource might be a file, a generated report, or any other content the server can provide without side effects.
List resources
Resource schema
Each resource includes:
Read resources
Read a specific resource by URI:
result is a ReadResourceResult with a contents list. It can contain TextResourceContents (text) or BlobResourceContents (base64 blob).
Response structure (text vs binary)
Example: Configuration reader
Resource templates
Resource templates are just “patterns” a server can publish (like resource://users/{user_id}) to show what kinds of resource URLs exist. They don’t automatically create resources. To read something, you still call read_resource(...) with a real URL (like resource://users/123), and it only works if the server actually serves that exact URI.
Context manager
Again, open_connection(...) is an async context manager. It means you don’t have to remember to call await client.close(). When the async with block exits, it automatically closes the underlying connection for you.
Last modified on June 30, 2026