Skip to main content

Module resources

Module resources 

Source
Expand description

Static MCP resources for config-driven servers.

StaticResourceHandler implements pmcp::server::ResourceHandler over an in-memory IndexMap of LoadedResource entries. The handler does NOT redefine the trait — it consumes the trait shape from pmcp.

§Wire shape — MIME-typed-wire (PATTERNS §5)

read() returns content via Content::resource_with_text (NOT Content::text) so per-resource MIME types survive the JSON-RPC wire round-trip. Reference files like schema.graphql keep their application/graphql MIME type rather than being downgraded to text/plain.

§Determinism (Pattern D)

Storage is IndexMap<String, LoadedResource> (NOT HashMap). This guarantees that list() returns resources in deterministic, configuration order — required for snapshot tests, stable example output, and predictable host UX.

§Orthogonality with skills

StaticResourceHandler is independent of [pmcp::server::skills::Skill] and bootstrap_skill_and_prompt. Downstream consumers can register both surfaces side-by-side; the toolkit makes no assumption about skill registration (RESEARCH §Risks #3).

§Example configuration

[[resources]]
uri = "docs://policies/guide"
name = "Policy Guide"
description = "How to interpret policies"
mime_type = "text/markdown"
content = """
# Policy Guide
This document explains...
"""

Structs§

LoadedResource
A loaded resource with resolved content.
ResourceConfig
MCP Resource configuration.
StaticResourceHandler
Handler for static resources loaded from configuration.