Skip to main content
MCP Apps SDK
import { App } from "@modelcontextprotocol/ext-apps";

Overview

getHostVersion() returns the host application’s name and version, as reported during the initialization handshake. Use this to identify the host platform, log diagnostics, or adapt behavior for specific hosts. Returns undefined before connect() completes.

Signature

getHostVersion(): { name: string; version: string } | undefined

Returns

return
{ name: string; version: string } | undefined
The host’s self-reported identity, or undefined if the app has not connected yet.
name
string
The host application name (e.g., "ChatGPT", "Claude").
version
string
The host application version string.

Usage

Log the host identity

await app.connect();

const host = app.getHostVersion();
console.log(`Running in ${host?.name} v${host?.version}`);
// → "Running in ChatGPT v1.0.0"

Adapt behavior per host

const host = app.getHostVersion();

if (host?.name === "ChatGPT") {
  // ChatGPT-specific initialization
} else if (host?.name === "Claude") {
  // Claude-specific initialization
}

Include in error reports

function reportError(error: Error) {
  const host = app.getHostVersion();
  sendToErrorService({
    error: error.message,
    hostName: host?.name,
    hostVersion: host?.version,
    appVersion: "1.0.0",
  });
}
The sunpeak framework provides useHostInfo for reactive access to the host’s name and version in React components.