> ## 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.

# Host Detection

> Detect which host is running your MCP App.

<Badge color="yellow">sunpeak API</Badge>

## Overview

Host detection utilities help you identify which host (ChatGPT, Claude, etc.) is running your app, so you can conditionally use host-specific features.

## Import

```tsx theme={null}
import { detectHost, isChatGPT, isClaude } from 'sunpeak/host';
```

## detectHost

Detect the current host.

### Signature

```tsx theme={null}
function detectHost(): Host
```

### Host Type

```tsx theme={null}
type Host = 'chatgpt' | 'claude' | 'unknown';
```

### Detection Order

1. **Runtime objects** — checks for `window.openai` (injected by ChatGPT and by the inspector when ChatGPT host is selected)
2. **User agent** — checks `navigator.userAgent` for host identifiers
3. **Hostname** — checks `window.location.hostname` for known host domains

### Usage

```tsx theme={null}
import { detectHost } from 'sunpeak/host';

function MyResource() {
  const host = detectHost();

  switch (host) {
    case 'chatgpt':
      return <ChatGPTFeatures />;
    case 'claude':
      return <ClaudeFeatures />;
    default:
      return <GenericUI />;
  }
}
```

***

## isChatGPT

Check if the app is running in a ChatGPT host.

### Signature

```tsx theme={null}
function isChatGPT(): boolean
```

### Usage

```tsx theme={null}
import { isChatGPT } from 'sunpeak/host';
import { useUploadFile } from 'sunpeak/host/chatgpt';

function MyResource() {
  if (!isChatGPT()) {
    return <p>Upload requires ChatGPT.</p>;
  }
  return <Uploader />;
}

function Uploader() {
  const uploadFile = useUploadFile();
  // ...
}
```

***

## isClaude

Check if the app is running in a Claude host.

### Signature

```tsx theme={null}
function isClaude(): boolean
```

### Usage

```tsx theme={null}
import { isClaude } from 'sunpeak/host';

function MyResource() {
  if (isClaude()) {
    // Claude-specific behavior
  }
}
```

***

## Inspector Behavior

In the [Inspector](/testing/inspector), host detection reflects the currently selected host:

| Host selected | `isChatGPT()` | `isClaude()` | `detectHost()` |
| ------------- | ------------- | ------------ | -------------- |
| ChatGPT       | `true`        | `false`      | `'chatgpt'`    |
| Claude        | `false`       | `false`\*    | `'unknown'`\*  |

\* Claude detection relies on user agent or hostname, which aren't present in the inspector. Use [`useHostContext()`](/app-framework/hooks/use-host-context) to read host identity from the MCP protocol instead.

## See Also

<Card horizontal title="ChatGPT Hooks" icon="bolt" href="/app-framework/hooks/chatgpt-hooks">
  Host-specific hooks for ChatGPT features.
</Card>

<Card horizontal title="useHostContext" icon="circle-info" href="/app-framework/hooks/use-host-context">
  Read host identity and capabilities via the MCP protocol.
</Card>
