FrontMcpProvider
The provider manages the MCP client lifecycle and populates the sharedServerRegistry.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
server | DirectMcpServer | — | Required. Primary MCP server instance |
name | string | 'default' | Logical name for the primary server in the registry |
servers | Record<string, DirectMcpServer> | — | Additional named servers |
components | Record<string, ComponentType> | — | Components for DynamicRenderer and ComponentRegistry |
autoConnect | boolean | true | Connect on mount |
children | ReactNode | — | Required. Child elements |
onConnected | (client: DirectClient) => void | — | Called after successful connection |
onError | (error: Error) => void | — | Called if connection fails |
Lifecycle
- On mount, registers the primary server (and any
servers) inServerRegistry - If
autoConnectis true, callsserver.connect()and discovers tools/resources/prompts - Updates registry entry with
status: 'connected'and populates tool/resource/prompt lists - Also auto-connects additional servers from
serversprop - On unmount, unregisters all servers from the registry
FrontMcpContext
The React context carries a slim value — no state, just pointers:ServerRegistry and is accessed via hooks.
ServerRegistry
A singleton that stores all server entries and notifies subscribers on change.ServerEntry
| Field | Type | Description |
|---|---|---|
server | DirectMcpServer | The server instance |
client | DirectClient | null | Connected client (null until connected) |
status | FrontMcpStatus | 'idle' | 'connecting' | 'connected' | 'error' |
error | Error | null | Connection error |
tools | ToolInfo[] | Discovered tools |
resources | ResourceInfo[] | Discovered resources |
resourceTemplates | ResourceTemplateInfo[] | Discovered resource templates |
prompts | PromptInfo[] | Discovered prompts |