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:

  • resources/list: Requests the list of all available resource definitions the server exposes. It's handled internally by the TsgcWSAPIServer_MCP component.
  • resources/read: Retrieves the content and optional metadata of a specific resource. The event OnMCPRequestResource is called when a new request is received by the server. A resource typically includes:
    • uri: resource identifier.
    • mimeType: content type (text/plain, application/json, image/png, etc.).
    • data or content: the actual payload (text or binary).

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.

Resources List

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; 

Resources Request

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; 

Learn More

For in-depth documentation and component reference, visit:


sgcWebSockets MCP Prompts Resources Guide 

Find below a Delphi MCP Server Demo for windows:

sgcMCP_Server
3.9 mb