Expand description
Type-safe MCP resource definitions
This module provides a high-level API for defining MCP resources with compile-time type checking and automatic JSON generation for the resources/list, resources/templates/list, and resources/read protocol messages.
Structs§
- Compiled
Template Matcher - Pre-compiled URI template matcher. Built once at initialization time so that
read_resourcedispatch only runs the regex (no compilation overhead per request). - Resource
- A resource definition for the resources/list response
- Resource
Builder - Builder for creating resources with a fluent API
- Resource
Content - Content of a resource, either text or binary (base64-encoded).
- Resource
Template - Parameterized resource definition for
resources/templates/listand template-based reads. - Resource
Template Builder
Functions§
- match_
uri_ against_ template - Match
uriagainst a template string with{var}placeholders.
Type Aliases§
- Generic
Resource Read Handler - Fallback handler when no static resource or template matches (user parses URI as needed).
- Resource
Contents - Collection of resource contents (e.g. multi-part resource)
- Resource
Handler - Resource read handler function type
- Template
Resource Handler - Handler for a URI template match: receives the request URI and extracted
{name}values.