Skip to content

Resources

Resources let you expose data that an LLM can read. MCPConnect supports three kinds:

TypeAttributeDescription
Class-based resources[McpResource]Methods that return dynamic content
MCP Apps[McpAppUI]Methods that return a UI (e.g. HTML) rendered by the client
Static filesFiles served directly from disk

Class-Based Resources

Decorate a method with [McpResource] to expose it as a readable resource:

pascal
type
  TWeatherResource = class
  public
    [McpResource('weather-resource', 'text://weather', 'text/csv', 'Current weather data')]
    function GetWeatherInfo: string;
  end;

The [McpResource] attribute takes (name, uri, mimeType, description).

MCP Apps

MCP Apps are UI resources served via a ui:// URI scheme. The client (if it supports it) renders the returned content as an interactive widget.

pascal
type
  TMyApp = class
  public
    [McpAppUI('my-app', 'ui://my-app/index.html', 'An interactive UI panel')]
    function GetUI: string;
  end;

function TMyApp.GetUI: string;
begin
  Result := TFile.ReadAllText(TPath.Combine(TPath.GetAppPath, 'data', 'my-app.html'));
end;

The [McpAppUI] attribute takes (name, uri, description).

Linking a Tool to an App

A tool can declare that its result should be rendered by an MCP App in two equivalent ways:

Option A — separate [McpApp] attribute on the tool method (takes the app URI):

pascal
[McpTool('get_tickets', 'List available tickets')]
[McpApp('ui://my-app/index.html')]
function GetTickets: TTickets;

Option Bapp= annotation in the third parameter of [McpTool]:

pascal
[McpTool('get_tickets', 'List available tickets', 'app=ui://my-app/index.html')]
function GetTickets: TTickets;

Both tell the client that the tool result can be rendered inside the specified app UI.

Registering Resources and Static Files

All resource types are registered in the .Resources section:

pascal
.Resources
  .SetBasePath(GetCurrentDir + '\data')
  .RegisterClass(TWeatherResource)             // [McpResource] class
  .RegisterClass(TMyApp)                       // [McpAppUI] class
  .RegisterFile('readme.md', 'Documentation') // Static text file
  .RegisterFile('docs\guide.pdf', 'User Guide') // Static binary file
.BackToMCP

Remember to declare Resources in .SetCapabilities:

pascal
.Server
  .SetCapabilities([Tools, Resources])
.BackToMCP