MCP Server Framework - v1.0.0
    Preparing search index...
    • Define an MCP App with automatic resource and tool registration.

      Creates a tool linked to a UI resource via _meta.ui.resourceUri. Both the tool and the resource are registered in the global registries, so they are automatically available when createServer() is called.

      Type Parameters

      • TInput extends ZodTypeAny

        Zod schema type for the tool input (inferred)

      Parameters

      Returns AppDefinition<TInput>

      The original app definition (for re-export and type inference)

      import { defineApp, text, z } from 'mcp-server-framework';

      export const calculator = defineApp({
      name: 'calculator',
      description: 'An interactive calculator app',
      resource: {
      uri: 'ui://calculator',
      mimeType: 'text/html;profile=mcp-app',
      read: async () => '<html>...calculator UI...</html>',
      },
      input: z.object({ expression: z.string() }),
      handler: async ({ expression }) => text('42'),
      });
      // With annotations and custom _meta
      export const dashboard = defineApp({
      name: 'dashboard',
      description: 'System monitoring dashboard',
      resource: {
      uri: 'ui://dashboard',
      name: 'Dashboard UI',
      description: 'Interactive system monitoring dashboard',
      mimeType: 'text/html;profile=mcp-app',
      read: async () => generateDashboardHtml(),
      },
      input: z.object({ metric: z.string().optional() }),
      handler: async ({ metric }, ctx) => json(await getMetrics(metric)),
      annotations: { readOnlyHint: true },
      _meta: { version: '2.0' },
      });