К основному содержанию
скилл CX Codex

react-mcp — скилл для Claude Code: MCP-серверы в браузере

Скилл для работы с @assistant-ui/react-mcp: подключает MCP-серверы, выбранные пользователем, прямо в браузере и регистрирует их инструменты в чате.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add assistant-ui/skills --skill react-mcp -a claude-code
Открыть на GitHub

Что делает react-mcp

Скилл описывает, как встроить в assistant-ui менеджер MCP-серверов, которыми управляет конечный пользователь. Пресеты объявляются через defineConnector, менеджер хранит состояние серверов и авторизации, а каждый подключённый инструмент попадает в modelContext под именем serverId__toolName.

Внутри три справочника: настройка менеджера и хранилища, примитивы интерфейса и работа с OAuth. Готовый диалог конфигурации ставится командой npx assistant-ui@latest add mcp-config и импортируется из @/components/assistant-ui/elements/mcp-config.aui. Для своей страницы настроек или боковой панели собираются headless-примитивы.

Скилл покрывает серверы, которые выбирает пользователь, а не MCP-инструменты бэкенда приложения. Если чат-рантайм не передаёт modelContext, менеджер поднимает минимальный свой. Учтите: после вызовов фронтенд-инструментов рантайму всё равно нужно отправить результаты на маршрут, иначе модель не продолжит ответ.

Какие задачи решает

  • дать пользователю подключить свой MCP-сервер из браузера
  • объявить пресеты серверов через defineConnector
  • сохранить список серверов и состояние OAuth между сессиями
  • отрисовать запрос структурированного ввода во время вызова инструмента
  • разобраться, почему у сервера не появились инструменты или сорвался редирект OAuth

Примеры запросов агенту

  • Подключи McpManagerResource с пресетом Linear через defineConnector и OAuth со scope read
  • Собери страницу настроек на McpManagerPrimitive и McpAddFormPrimitive вместо готового диалога
  • Почему после вызова фронтенд-инструмента модель не продолжает ответ?

Как установить react-mcp

1Через Skills CLI (Vercel)

npx skills add assistant-ui/skills --skill react-mcp -a claude-code

2Вручную: положить файлы

~/.claude/skills/react-mcp/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/react-mcp/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Из того же набора13

tools Скилл про то, как объявлять инструменты, которые вызывает модель, и рисовать их вызовы в assistant-ui. Пригодится, когда инструмент не вызывается или его UI не отрисовывается. CX Codex +1 6 300установок thread-list Скилл для assistant-ui: добавляет боковую панель с несколькими диалогами, переключением, переименованием, архивацией и удалением. CX Codex +1 6 200установок update Обновляет существующее приложение на assistant-ui до актуальных версий AI SDK v7 и assistant-ui 0.15.x, применяя нужные миграции. Пригодится, когда после апдейта посыпались ошибки типов или пропали хуки. CX Codex +1 5 900установок cloud Подключает AssistantCloud к приложению на assistant-ui: история тредов между сессиями, обратная связь по сообщениям и загрузка файлов. CX Codex +1 5 000установок observability Подключает Langfuse, LangSmith или Helicone к бэкенд-роутам assistant-ui на AI SDK и рисует собранные спаны через экспериментальный @assistant-ui/react-o11y. CX Codex +1 4 000установок copilots Скилл для assistant-ui: учит агента читать состояние страницы, кликать по компонентам и менять их состояние через хуки React. CX Codex +1 3 900установок generative-ui Скилл для assistant-ui: модель собирает интерфейс из готовых компонентов во время ответа, а не заполняет заранее написанный вами. CX Codex +1 1 000установок ink Скилл для сборки чат-интерфейсов прямо в терминале: связывает рантайм assistant-ui с рендерером Ink и выводит ответы как ANSI-разметку. CX Codex +1 923установок

Похожие

adk-frontend botpress Скилл с готовыми шаблонами для фронтенда, который работает с ботами на Botpress ADK: авторизация, клиент, типы и вызовы действий. CX Codex +1 1 700установок react vercel-labs Скилл помогает собирать React-интерфейсы из JSON-спецификаций через json-render. Нужен для каталогов компонентов и UI, который создаёт ИИ. CX Codex +1 16 300установок react-expert https://github.com/Jeffallan Скилл для разработки на React 18+, Next.js App Router и create-react-app. Генерирует компоненты, хуки, чинит рендер и переводит классовые компоненты на функциональные. CX Codex +1 5 500установок typescript-react-patterns agent-skills Скилл с 33 правилами типизации React на TypeScript: пропсы, хуки, события, refs, дженерики и контекст. Пригодится, когда агент пишет компоненты и лезет в типы. CX Codex +1 1 100установок react-flow framara Скилл для работы с React Flow (@xyflow/react): кастомные узлы и рёбра, состояние, лейаут, типизация и отладка графов. CX Codex +1 821установок syncfusion-react-dashboard-layout Syncfusion Inc Скилл для ИИ-агента: подсказывает, как собрать дашборд на React с перетаскиваемыми панелями Syncfusion. CX Codex +1 703установок

Рядом в теме «Фронтенд и UI»

Всё по теме «Фронтенд и UI» →

Вопросы о react-mcp

Как установить react-mcp в Claude?

Выполните npx skills add assistant-ui/skills --skill react-mcp -a claude-code. Скилл окажется в ~/.claude/skills/react-mcp/SKILL.md.

Что делает react-mcp?

Помогает добавить в assistant-ui менеджер MCP-серверов, которыми управляет пользователь: пресеты, свои серверы, состояние авторизации и регистрацию инструментов в modelContext.

Чем это отличается от инструментов бэкенда приложения?

Скилл про серверы, которые выбирает конечный пользователь. MCP-инструменты, принадлежащие приложению, — отдельная тема, для них есть скилл tools.

Исходный текст

SKILL.md · MIT
---
name: react-mcp
description: "Adds user managed browser MCP servers to assistant-ui with `@assistant-ui/react-mcp`. Use when mounting `McpManagerResource`, declaring `defineConnector` presets, persisting custom servers and OAuth state, composing `McpManagerPrimitive`, `McpServerPrimitive`, `McpAddFormPrimitive`, or `McpElicitationPrimitive`, handling an OAuth callback, browsing MCP resources, or diagnosing missing server tools, connection failures, and OAuth redirects. This covers end user chosen servers, not application owned backend MCP tools. For those use tools; for the chat runtime use runtime; for the copied dialog use elements."
license: MIT
---

# assistant-ui React MCP

**Always consult [assistant-ui.com/llms.txt](https://www.assistant-ui.com/llms.txt) for the latest API.**

`@assistant-ui/react-mcp` lets users connect preset or custom Streamable HTTP MCP servers in the browser. The manager persists server and auth state, exposes connection state to primitives, and registers each connected tool into `modelContext` as a frontend tool named `serverId__toolName`.

## References

- [./references/setup.md](./references/setup.md) -- manager configuration, storage, state, imperative methods, and resource reads
- [./references/ui.md](./references/ui.md) -- the copied configuration dialog and every manager, server, and add form primitive
- [./references/oauth.md](./references/oauth.md) -- auth shapes, OAuth callback handling, CIMD, and connection states

## Mount the manager

Declare fixed connectors with `defineConnector`, then extend the nearest `aui` scope with a config. `connectionTimeout` is a manager default in milliseconds. A connector or custom server can override it for its own connect and `listTools()` readiness flow.

```tsx
"use client";

import type { ReactNode } from "react";
import { AuiConfig, AuiProvider, useAui } from "@assistant-ui/react";
import { McpManagerResource, defineConnector } from "@assistant-ui/react-mcp";

const connectors = [
  defineConnector({
    id: "linear",
    name: "Linear",
    url: "https://mcp.linear.app",
    auth: { type: "oauth", scopes: ["read"] },
    icon: "/icons/linear.svg",
  }),
  defineConnector({
    id: "weather",
    name: "Weather",
    url: "https://mcp.example.com/weather",
    auth: { type: "none" },
    connectionTimeout: 10_000,
  }),
];

export function Providers({ children }: { children: ReactNode }) {
  const aui = useAui();
  const config = AuiConfig({
    mcp: McpManagerResource({
      connectors,
      connectionTimeout: 15_000,
    }),
  });

  return (
    <AuiProvider extends={aui} config={config}>
      {children}
    </AuiProvider>
  );
}
```

Connectors are application presets and cannot be removed. A custom server is user supplied through `McpAddFormPrimitive` or `aui.mcp.addCustomServer(...)`. Both kinds share state, storage, elicitation, and the tool registration path. See [setup](./references/setup.md) for manager options and storage lifetime rules.

## Continue after frontend tool calls

The manager registers connected tools automatically. A chat runtime still needs to send completed frontend tool results to the route so the model can continue.

```tsx
"use client";

import type { ReactNode } from "react";
import { lastAssistantMessageIsCompleteWithToolCalls } from "ai";
import { AssistantRuntimeProvider } from "@assistant-ui/react";
import { useChatRuntime } from "@assistant-ui/ai-sdk";

export function Chat({ children }: { children: ReactNode }) {
  const runtime = useChatRuntime({
    sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
  });

  return <AssistantRuntimeProvider runtime={runtime}>{children}</AssistantRuntimeProvider>;
}
```

If no chat runtime provides `modelContext`, the manager mounts a minimal one. Use `aui.mcp.server({ id }).callTool(...)` for a direct call in an event handler.

## Use the configuration UI

Install the styled dialog with `npx assistant-ui@latest add mcp-config`. It is a copied runtime connected element, so import it from `@/components/assistant-ui/elements/mcp-config.aui` and render it under the manager provider.

```tsx
import { McpConfigDialog } from "@/components/assistant-ui/elements/mcp-config.aui";

export function ServerSettings() {
  return <McpConfigDialog />;
}
```

Pass an element as `children` to replace its default trigger. For a settings page, sidebar, or custom add flow, compose the headless primitives in [ui](./references/ui.md).

## Render elicitation requests

An MCP server can request structured input while a tool call is in flight. Render `Items` in the same `mcpServer` scope as the connected server. Set `elicitation: false` on a connector or custom server to opt it out of the protocol capability.

```tsx
import { McpElicitationPrimitive } from "@assistant-ui/react-mcp";

type FieldSchema = {
  type?: string;
  enum?: readonly string[];
};

export function ElicitationRequests() {
  return (
    <McpElicitationPrimitive.Items>
      {() => (
        <McpElicitationPrimitive.Root>
          <McpElicitationPrimitive.Message />
          <McpElicitationPrimitive.Error />
          <McpElicitationPrimitive.Fields>
            {({ name, schema, value, setValue }) => {
              const field = schema as FieldSchema;
              if (field.type === "boolean") {
                return (
                  <label>
                    {name}
                    <input
                      type="checkbox"
                      checked={value === true}
                      onChange={(event) => setValue(event.target.checked)}
                    />
                  </label>
                );
              }
              if (field.enum) {
                return (
                  <label>
                    {name}
                    <select
                      value={typeof value === "string" ? value : ""}
                      onChange={(event) => setValue(event.target.value)}
                    >
                      {!field.enum.includes("") && <option value="">Select {name}</option>}
                      {field.enum.map((option) => (
                        <option key={option} value={option}>
                          {option}
                        </option>
                      ))}
                    </select>
                  </label>
                );
              }
              return (
                <label>
                  {name}
                  <input
                    value={typeof value === "string" || typeof value === "number" ? String(value) : ""}
                    onChange={(event) => setValue(event.target.value)}
                  />
                </label>
              );
            }}
          </McpElicitationPrimitive.Fields>
          <McpElicitationPrimitive.Accept>Submit</McpElicitationPrimitive.Accept>
          <McpElicitationPrimitive.Decline>Decline</McpElicitationPrimitive.Decline>
          <McpElicitationPrimitive.Cancel>Cancel</McpElicitationPrimitive.Cancel>
        </McpElicitationPrimitive.Root>
      )}
    </McpElicitationPrimitive.Items>
  );
}
```

The render function receives a separate active request each time. Numeric strings are coerced when valid, while boolean fields must set a boolean. An empty string is unanswered unless the property allows it through an enum member or default, so render enum properties as a select. `Accept` remains disabled for missing required fields and invalid values.

## v1 scope

This package ships tool listing and invocation, resource listing and reads, form elicitation, OAuth with PKCE and DCR, bearer and no auth, Streamable HTTP transport, and manual connect or disconnect. Prompts, sampling, automatic reconnect with backoff, persisted per tool enablement, per tool consent, and built in token encryption are deferred.

## Common Gotchas

**Tools never reach the model**

- The server must be `connected`. Its tools are named `serverId__toolName`, not just the MCP tool name.
- Configure `sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls` on `useChatRuntime` so completed frontend tool calls resume the model.

**OAuth callback fails or never completes**

- The callback route must exactly match `oauthRedirectUri` and render `McpOAuthCallback` beneath the manager provider.
- A CIMD only authorization server without a registration endpoint needs a static OAuth `clientId`.

**Server state leaks across users or a storage swap loses records**

- `McpLocalStorage()` is browser only and stores tokens in plain text. Use an HTTP only cookie backed `McpCustomStorage` for production auth state.
- Do not swap `storage` for another user. Remount the manager because custom server records hydrate only once. See [storage identity](./references/setup.md#storage-and-scope-identity).

**An elicitation form stays blank**

- `Items` renders nothing without pending requests and requires the matching server scope. Confirm that the server is connected and has not set `elicitation: false`.

**A resource browser stops after the first page**

- Pass each returned `nextCursor` to `listResources({ cursor })` until it is absent, then call `readResource(uri)` for a selected item.

## Related Skills

- [tools](../tools/SKILL.md) -- developer owned frontend and backend tools that complement user managed MCP servers
- [setup](../setup/SKILL.md) -- CLI setup and the `mcp` project template
- [runtime](../runtime/SKILL.md) -- `useChatRuntime` and runtime provider configuration
- [elements](../elements/SKILL.md) -- installing and modifying the copied `mcp-config` element

© assistant-ui · MIT · assistant-ui/skills

Смотрите также

Спонсоры проекта

Компании, которые помогают держать аналитику открытой