@toolgrain/mcp. Wire types such as
TextResourceContents, BlobResourceContents, and protocol Resource come
directly from @toolgrain/protocol.
resource
ResourceDefinition and ResourceMetadata
ResourceDefinition<Result> combines readonly protocol resource metadata with
read(uri: string, ctx: ToolContext): Result.
ResourceMetadata is the readonly protocol resource description.
Resource<Result> is a type-only export describing the branded definition;
construct it with resource(). Like tools, compatible duplicate package copies
recognize each other’s definitions. Object spreads must pass through the helper
again before registration.
ResourceReadResult
blob.
Empty contents are valid for an existing resource. Results and metadata are
validated and copied at server conversion; direct read() calls bypass this work.
Server registration
ServerOptions.resources?: readonly Resource[] registers the static resource list.
The optional array enables the capability even when empty. Duplicate URIs,
invalid metadata, or unbranded definitions fail construction. tools remains
required; resource-only applications pass tools: {}.
The same reader and metadata serve both supported revisions and every authorized
caller. Context uses existing auth accessors, lazy providers, and cooperative
cancellation. See resource behavior
for response fields, error codes, and deferred features.