Skip to main content

Documentation Index

Fetch the complete documentation index at: https://sunpeak.ai/docs/llms.txt

Use this file to discover all available pages before exploring further.

sunpeak API

Overview

The useToolInfo hook returns metadata about the tool call that instantiated the current app. It is a convenience wrapper around useHostContext.

Wraps onhostcontextchanged

MCP Apps SDK reference

Import

import { useToolInfo } from 'sunpeak';

Signature

function useToolInfo(): ToolInfo | undefined

Returns

return
ToolInfo | undefined
Metadata about the tool call, or undefined if not available.
{
  id?: RequestId;   // JSON-RPC id of the tools/call request
  tool: Tool;       // Tool definition including name, inputSchema, etc.
}

Usage

import { useToolInfo } from 'sunpeak';

function MyResource() {
  const toolInfo = useToolInfo();

  return (
    <div>
      <p>Rendered by: {toolInfo?.tool.name ?? 'unknown tool'}</p>
    </div>
  );
}
The tool info comes from McpUiHostContext.toolInfo.