TTMSMCPResource Class
One piece of read-only context a server publishes for clients to fetch by address, either at one fixed address or through a template that covers a family of addresses.
API unit family: TMS.MCP.Resources
Inherits from: TTMSMCPBase
Syntax
TTMSMCPResource = class(TTMSMCPBase)
Remarks
An entry carries the metadata that is published in the listing — name, description, title, media type and icons — plus the handler that produces the content when the address is actually read. Setting the template address turns the entry into a template; an entry is meant to have either a fixed address or a template, not both, and the builder refuses to set the second one. A template also takes part in argument completion, so a client can ask for suggestions for one of its variables while the user is typing.
Properties
| Name | Description |
|---|---|
| IconsJSON | Icon descriptors published with the entry, serialized as a JSON array. |
| MimeType | Media type of the content this entry produces, for example application/json. Left out of the descriptor when empty. |
| Size | Size of the raw resource content in bytes, before any encoding, when known. Left out of the descriptor while it is -1 (the default, meaning unknown). |
| Title | Display name a client shows for the entry, as opposed to the identifier it is addressed by. Left out of the descriptor when empty. |
| URI | Fixed address under which the entry is published, for example file:///config/app.json. Clients read the entry by quoting this address exactly. |
| URITemplate | Address pattern covering a family of addresses, with each variable part written between braces, for example db://tables/{table}/rows/{id}. |
Methods
| Name | Description |
|---|---|
| CreateBuilder | Creates a builder for describing an entry through chained calls. |
| IsTemplate | Reports whether the entry stands for a family of addresses rather than one fixed address. |
| ReadResource | Runs the handler for an address and converts what it produces into the content object sent back to the client. |
| ToJSON | Builds the descriptor published for this entry in a listing. |
Events
| Name | Description |
|---|---|
| ResourceReader | Code that produces the content when this entry is read. |