eSeGeCe
software
In MCP, resources represent addressable data objects that the server exposes such as files, database records, generated documents, or dynamic API outputs.
They are client-controlled, meaning the client can decide which resource to request and how to interpret the content.
The two main methods involved are:
Additionally, if the server sets resources.listChanged = true in its declared capabilities, it may send notifications like notifications/resources/list_changed when the resource catalog updates.
The server keeps an in-memory catalogue of resources in TsgcAI_MCP_ResourcesList. Resources are guaranteed to be unique by uri, expose descriptions and provide a JSON Schema like input uri that is emitted in the response to the specification's resources.list method. When a client invokes resources.list, TsgcWSAPIServer_MCP loads the request, serializes the current catalogue and sends it back with a 200 HTTP status code.
Example code that publishes a file resource:
procedure TMainForm.FormCreate(Sender: TObject);
begin
MCPServer.Resources.Clear;
MCPServer.Resources.AddResource(
'file:///project/src/main.rs', // URI
'main.rs', // Name
'Rust Software Application Main File', // Title
'Primary application entry point', // Description
'text/x-rust');
end;
When a client issues a resource.read JSON-RPC request, TsgcWSAPIServer_MCP hydrates the strongly-typed request object (including uri resource, name and the provided arguments) before raising the OnMCPRequestResource event. Your handler populates the response payload which is then serialized back to the client, alongside a success HTTP status code.
A typical handler looks like this:
procedure OnMCPRequestResource(Sender: TObject;
const aSession: TsgcAI_MCP_Session; const aRequest: TsgcAI_MCP_Request_ResourcesRead;
const aResponse: TsgcAI_MCP_Response_ResourcesRead);
begin
if aRequest.Params.Uri = 'file:///project/src/main.rs' then
aResponse.Result.Contents.AddContentText('file:///project/src/main.rs',
'main.rs', 'Rust Software Application Main File', 'text/x-rust',
'fn main() {\n println!(\"Hello world!\");\n}');
end;
For in-depth documentation and component reference, visit:
sgcWebSockets MCP Prompts Resources Guide
Find below a Delphi MCP Server Demo for windows:
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.