Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

mcp-apps-sdk

БесплатноБез исполняемых скриптовНе проверен

This skill should be used when writing code against @modelcontextprotocol/ext-apps — registerAppTool, registerAppResource, RESOURCE_MIME_TYPE, the App class…

TheLobbiот TheLobbi★ 22 звезды на GitHub

Об этом скилле

@modelcontextprotocol/ext-apps — the SDK

One package, four entry points:

Import Side Contains
@modelcontextprotocol/ext-apps View App class
@modelcontextprotocol/ext-apps/server Server registerAppTool, registerAppResource, RESOURCE_MIME_TYPE
@modelcontextprotocol/ext-apps/react View useApp and React bindings
@modelcontextprotocol/ext-apps/app-bridge View low-level bridge for non-JS frameworks
npm install @modelcontextprotocol/ext-apps @modelcontextprotocol/sdk
npm install -D typescript vite vite-plugin-singlefile express cors tsx \
               @types/express @types/cors

Always npm install by name. Do not hand-pin versions in package.json — the View SDK and server SDK must move together.

Server side

// server.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
import {
  registerAppTool,
  registerAppResource,
  RESOURCE_MIME_TYPE,
} from "@modelcontextprotocol/ext-apps/server";
import express from "express";
import cors from "cors";
import fs from "node:fs/promises";
import path from "node:path";

const server = new McpServer({ name: "Weather", version: "1.0.0" });
const resourceUri = "ui://weather/forecast.html";

registerAppTool(
  server,
  "render_forecast",
  {
    title: "Render forecast",
    description: "Render the 7-day forecast widget. Call get_forecast first.",
    inputSchema: { city: z.string(), days: z.array(DayShape) },
    _meta: { ui: { resourceUri } },
  },
  async ({ city, days }) => ({
    // structuredContent is what the View renders …
    structuredContent: { city, days },
    // … content is what a text-only host and the model read.
    content: [{ type: "text", text: `7-day forecast for ${city}.` }],
  }),
);

registerAppResource(
  server,
  "forecast-ui",            // human-readable name
  resourceUri,              // the ui:// URI
  { mimeType: RESOURCE_MIME_TYPE },
  async () => ({
    contents: [
      {
        uri: resourceUri,
        mimeType: RESOURCE_MIME_TYPE,
        text: await fs.readFile(
          path.join(import.meta.dirname, "dist", "mcp-app.html"),
          "utf-8",
        ),
        // CSP belongs HERE, in the contents _meta — not in the config arg above.
        _meta: {
          ui: {
            prefersBorder: true,
            csp: {
              connectDomains: ["https://api.weather.example"],
              resourceDomains: ["https://static.weather.example"],
            },
          },
        },
      },
    ],
  }),
);

const app = express();
app.use(cors());
app.use(express.json());
app.post("/mcp", async (req, res) => {
  const transport = new StreamableHTTPServerTransport({
    sessionIdGenerator: undefined,
    enableJsonResponse: true,
  });
  res.on("close", () => transport.close());
  await server.connect(transport);
  await transport.handleRequest(req, res, req.body);
});
app.listen(3001, () => console.log("http://localhost:3001/mcp"));

registerAppTool/registerAppResource are thin wrappers over the base SDK's registerTool/registerResource that enforce the MCP Apps shape. Using the base functions directly works too — you just have to spell _meta and the mimeType yourself.

View side — vanilla

import { App } from "@modelcontextprotocol/ext-apps";

const app = new App({ name: "Forecast", version: "1.0.0" });

// ⚠ Every handler BEFORE connect().
app.ontoolinput   = (params) => renderSkeleton(params);
app.ontoolresult  = (result) => render(result.structuredContent);
app.onteardown    = () => flush();
app.onhostcontextchanged = (ctx) => applyTheme(ctx.theme);

app.connect();

App surface

Member Kind Notes
connect() method Performs ui/initialize. Call once, last.
callServerTool({ name, arguments }) method Full round-trip to the server. Returns CallToolResult.
readResource({ uri }) method Read another server resource.
sendMessage({ … }) method Inject a follow-up message into the conversation.
updateModelContext(ctx) method Tell the model what the user is now looking at.
requestDisplayMode({ mode }) method "inline" | "fullscreen" | "pip". Check availability first.
sendSizeChanged({ width, height }) method Drives host iframe resizing.
openLink({ url }) method Host-mediated navigation.
sendLog({ level, data }) method Logs to the host — survives when devtools do not.
getHostContext() method Theme, display mode, viewport, locale, safe area.
getHostCapabilities() method What this host actually implements.
getHostVersion() method Host name/version.
ontoolinput handler Arguments, before the result.
ontoolinputpartial handler Streaming healed-JSON args. May be incomplete.
ontoolresult handler The CallToolResult.
`o
Полный SKILL.md на GitHub

Установить mcp-apps-sdk в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл mcp-apps-sdk?

This skill should be used when writing code against @modelcontextprotocol/ext-apps — registerAppTool, registerAppResource, RESOURCE_MIME_TYPE, the App class and its handlers, the React useApp hook, the app-bridge entry point, and the Vite single-file build that MCP Apps expect.

Как установить скилл mcp-apps-sdk?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл mcp-apps-sdk запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить mcp-apps-sdk с