Skip to contents

MCP App

MCP App

Details

An R6 class that bundles UI components and tools into a servable MCP App. The app generates HTML with an embedded JS bridge and provides tools annotated with resource URIs for MCP consumption.

Public fields

name

App name

version

App version

Methods


Method new()

Create a new McpApp

Usage

McpApp$new(
  ui,
  tools = list(),
  name = "shinymcp-app",
  version = "0.1.0",
  theme = NULL
)

Arguments

ui

An htmltools tag or tagList defining the UI. Can be a simple tagList of shinymcp components, or a full bslib::page() with theme.

tools

A list of tool definitions (ellmer tool objects or named list)

name

App name (used in resource URIs)

version

App version string

theme

Optional bslib theme (a bslib::bs_theme() object). If provided, the UI will be wrapped in a themed page. Not needed if ui is already a bslib::page().


Method html_resource()

Generate the full HTML resource Returns a character string of the complete HTML page including UI components, bridge script, and config. HTML dependencies from bslib or other htmltools-based packages are inlined automatically.

Usage

McpApp$html_resource()


Method mcp_tools()

Get tools annotated with MCP metadata Returns the tools list with _meta.ui.resourceUri added to each tool.

Usage

McpApp$mcp_tools()


Method tool_definitions()

Get tool definitions for MCP tools/list responses Returns a list of tool definition objects suitable for JSON-RPC. Each tool includes _meta.ui.resourceUri linking it to the app's UI resource, which tells MCP Apps-capable hosts to render the UI.

Usage

McpApp$tool_definitions()


Method call_tool()

Call a tool by name

Usage

McpApp$call_tool(name, arguments = list())

Arguments

name

Name of the tool to call

arguments

Named list of arguments to pass to the tool


Method resource_uri()

Get the ui:// resource URI for this app

Usage

McpApp$resource_uri()


Method print()

Print method

Usage

McpApp$print(...)

Arguments

...

Ignored. Inline HTML dependencies as