Skip to content

armgit / pdfcn

Public Imported from GitHub
0

Beautiful pdf components, built on Takumi and Forme. 100% Free, Zero config, one command setup.

feat: add 12 WebMCP tools for AI agent interaction

Aniket-5083e1aa1e7bdd5
diff --git a/app/(app)/layout.tsx b/app/(app)/layout.tsx
index 9d845b9..5a6bac8 100644
--- a/app/(app)/layout.tsx
+++ b/app/(app)/layout.tsx
@@ -1,6 +1,6 @@
import { SiteFooter } from "@/components/site-footer";
import { SiteHeader } from "@/components/site-header";
-import { WebMcpTools } from "@/components/web-mcp-tools";
+import { WebMcpTools } from "@/components/web-mcp/web-mcp-tools";
import { AGENT_DOCS_DIRECTIVE_TEXT } from "@/lib/agent-discovery/directive";
const AppLayout = ({ children }: { children: React.ReactNode }) => (
diff --git a/components/web-mcp-tools.tsx b/components/web-mcp-tools.tsx
deleted file mode 100644
index bab2e0d..0000000
--- a/components/web-mcp-tools.tsx
+++ /dev/null
@@ -1,120 +0,0 @@
-"use client";
-
-import { useEffect } from "react";
-
-import { ROUTES } from "@/constants/routes";
-import { SITE } from "@/constants/site";
-
-type ToolExecute = (
- input: unknown,
- options: { signal: AbortSignal }
-) => Promise<unknown>;
-
-interface ModelContextApi {
- registerTool?: (
- def: {
- description: string;
- execute: ToolExecute;
- inputSchema: Record<string, unknown>;
- name: string;
- },
- options?: { signal: AbortSignal }
- ) => (() => void) | undefined;
-}
-
-const getPath = (input: unknown, fallback: string): string => {
- if (
- typeof input === "object" &&
- input !== null &&
- "path" in input &&
- typeof (input as { path: unknown }).path === "string"
- ) {
- return (input as { path: string }).path;
- }
-
- return fallback;
-};
-
-export const WebMcpTools = () => {
- useEffect(() => {
- const { modelContext } = navigator as Navigator & {
- modelContext?: ModelContextApi;
- };
- const registerTool = modelContext?.registerTool;
- if (typeof registerTool !== "function") {
- return;
- }
-
- const ac = new AbortController();
- const cleanups: (() => void)[] = [];
-
- const register = (def: {
- description: string;
- execute: ToolExecute;
- inputSchema: Record<string, unknown>;
- name: string;
- }) => {
- const maybeCleanup = registerTool(def, { signal: ac.signal });
- if (typeof maybeCleanup === "function") {
- cleanups.push(maybeCleanup);
- }
- };
-
- register({
- description: `Navigate this tab to a ${SITE.NAME} documentation path (e.g. /docs/installation).`,
- execute: (input) => {
- const path = getPath(input, ROUTES.DOCS);
- window.location.assign(path);
-
- return Promise.resolve({ ok: true, path });
- },
- inputSchema: {
- properties: {
- path: {
- description: "Path beginning with /docs",
- type: "string",
- },
- },
- type: "object",
- },
- name: `${SITE.NAME}_open_docs`,
- });
-
- register({
- description:
- "Fetch the published shadcn registry manifest (registry.json) for this site.",
- execute: async (_input, { signal }) => {
- const res = await fetch(`${window.location.origin}${ROUTES.REGISTRY}`, {
- signal,
- });
- if (!res.ok) {
- return { ok: false, status: res.status };
- }
-
- return res.json();
- },
- inputSchema: { properties: {}, type: "object" },
- name: `${SITE.NAME}_fetch_registry`,
- });
-
- register({
- description: "Open the llms.txt documentation index for this site.",
- execute: () => {
- window.location.assign(ROUTES.LLMS);
-
- return Promise.resolve({ ok: true, path: ROUTES.LLMS });
- },
- inputSchema: { properties: {}, type: "object" },
- name: `${SITE.NAME}_open_llms_index`,
- });
-
- return () => {
- ac.abort();
- for (const fn of cleanups) {
- fn();
- }
- };
- }, []);
-
- return null;
-};
diff --git a/components/web-mcp/block-tools.tsx b/components/web-mcp/block-tools.tsx
new file mode 100644
index 0000000..61b22ff
--- /dev/null
+++ b/components/web-mcp/block-tools.tsx
@@ -0,0 +1,323 @@
+"use client";
+
+import { useWebMCP } from "use-webmcp-tool";
+
+import { SITE } from "@/constants/site";
+
+interface BlockInfo {
+ name: string;
+ type: "invoice" | "report";
+ title: string;
+ description: string;
+ bases: string[];
+ installCommand: string;
+}
+
+const BLOCKS: BlockInfo[] = [
+ {
+ bases: ["takumi", "forme"],
+ description:
+ "Traditional invoice layout with company header, bill-to section, itemized table, and payment terms.",
+ installCommand:
+ 'npx shadcn@latest add "https://pdfcn.vercel.app/r/takumi/invoice-classic.json"',
+ name: "invoice-classic",
+ title: "Classic Invoice",
+ type: "invoice",
+ },
+ {
+ bases: ["takumi", "forme"],
+ description:
+ "Professional invoice designed for consulting services with hourly billing sections.",
+ installCommand:
+ 'npx shadcn@latest add "https://pdfcn.vercel.app/r/takumi/invoice-consultant.json"',
+ name: "invoice-consultant",
+ title: "Consultant Invoice",
+ type: "invoice",
+ },
+ {
+ bases: ["takumi", "forme"],
+ description:
+ "Clean corporate invoice with modern styling and structured data tables.",
+ installCommand:
+ 'npx shadcn@latest add "https://pdfcn.vercel.app/r/takumi/invoice-corporate.json"',
+ name: "invoice-corporate",
+ title: "Corporate Invoice",
+ type: "invoice",
+ },
+ {
+ bases: ["takumi", "forme"],
+ description:
+ "Visually distinctive invoice with creative layout and accent colors.",
+ installCommand:
+ 'npx shadcn@latest add "https://pdfcn.vercel.app/r/takumi/invoice-creative.json"',
+ name: "invoice-creative",
+ title: "Creative Invoice",
+ type: "invoice",
+ },
+ {
+ bases: ["takumi", "forme"],
+ description:
+ "Stripped-down invoice with clean typography and generous whitespace.",
+ installCommand:
+ 'npx shadcn@latest add "https://pdfcn.vercel.app/r/takumi/invoice-minimal.json"',
+ name: "invoice-minimal",
+ title: "Minimal Invoice",
+ type: "invoice",
+ },
+ {
+ bases: ["takumi", "forme"],
+ description:
+ "Contemporary invoice with bold headers and a polished layout.",
+ installCommand:
+ 'npx shadcn@latest add "https://pdfcn.vercel.app/r/takumi/invoice-modern.json"',
+ name: "invoice-modern",
+ title: "Modern Invoice",
+ type: "invoice",
+ },
+ {
+ bases: ["takumi", "forme"],
+ description:
+ "Comprehensive financial report with summary metrics, data tables, and charts.",
+ installCommand:
+ 'npx shadcn@latest add "https://pdfcn.vercel.app/r/takumi/report-financial.json"',
+ name: "report-financial",
+ title: "Financial Report",
+ type: "report",
+ },
+ {
+ bases: ["takumi", "forme"],
+ description:
+ "Marketing performance report with KPI summaries, campaign data, and trend analysis.",
+ installCommand:
+ 'npx shadcn@latest add "https://pdfcn.vercel.app/r/takumi/report-marketing.json"',
+ name: "report-marketing",
+ title: "Marketing Report",
+ type: "report",
+ },
+ {
+ bases: ["takumi", "forme"],
+ description:
+ "Operational metrics report with status tracking, progress indicators, and risk assessment.",
+ installCommand:
+ 'npx shadcn@latest add "https://pdfcn.vercel.app/r/takumi/report-operations.json"',
+ name: "report-operations",
+ title: "Operations Report",
+ type: "report",
+ },
+ {
+ bases: ["takumi", "forme"],
+ description:
+ "Security audit report with compliance metrics, vulnerability tracking, and incident summary.",
+ installCommand:
+ 'npx shadcn@latest add "https://pdfcn.vercel.app/r/takumi/report-security.json"',
+ name: "report-security",
+ title: "Security Report",
+ type: "report",
+ },
+];
+
+const BLOCK_SCHEMAS: Record<string, object> = {
+ "invoice-classic": {
+ properties: {
+ billTo: {
+ properties: {
+ address: { type: "string" },
+ email: { type: "string" },
+ name: { type: "string" },
+ phone: { type: "string" },
+ },
+ required: ["name", "address", "email", "phone"],
+ type: "object",
+ },
+ companyAddress: { description: "Sender address", type: "string" },
+ companyEmail: { description: "Sender email", type: "string" },
+ companyName: { description: "Sender company name", type: "string" },
+ dueDate: { description: "Payment due date", type: "string" },
+ invoiceDate: { description: "Issue date", type: "string" },
+ invoiceNumber: {
+ description: "Invoice identifier (e.g. INV-001)",
+ type: "string",
+ },
+ items: {
+ items: {
+ properties: {
+ description: { type: "string" },
+ quantity: { type: "number" },
+ unitPrice: { type: "number" },
+ },
+ required: ["description", "quantity", "unitPrice"],
+ type: "object",
+ },
+ type: "array",
+ },
+ notes: { description: "Optional notes", type: "string" },
+ paymentTerms: {
+ properties: {
+ dueDate: { type: "string" },
+ gst: { type: "string" },
+ method: { type: "string" },
+ },
+ type: "object",
+ },
+ subtitle: { description: "Tagline or subtitle", type: "string" },
+ summary: {
+ properties: {
+ subtotal: { type: "number" },
+ tax: { type: "number" },
+ total: { type: "number" },
+ },
+ type: "object",
+ },
+ },
+ required: [
+ "invoiceNumber",
+ "invoiceDate",
+ "dueDate",
+ "companyName",
+ "billTo",
+ "items",
+ ],
+ type: "object",
+ },
+ "report-marketing": {
+ properties: {
+ author: { type: "string" },
+ generatedAt: { type: "string" },
+ highlights: { items: { type: "string" }, type: "array" },
+ period: {
+ description: "Reporting period (e.g. Q1 2026)",
+ type: "string",
+ },
+ rows: {
+ items: {
+ properties: {
+ label: { type: "string" },
+ owner: { type: "string" },
+ progress: { type: "number" },
+ status: { type: "string" },
+ },
+ type: "object",
+ },
+ type: "array",
+ },
+ series: {
+ items: {
+ properties: {
+ label: { type: "string" },
+ value: { type: "number" },
+ },
+ type: "object",
+ },
+ type: "array",
+ },
+ subtitle: { type: "string" },
+ summary: {
+ items: {
+ properties: {
+ label: { type: "string" },
+ tone: {
+ enum: ["success", "warning", "destructive", "info"],
+ type: "string",
+ },
+ trend: { type: "string" },
+ value: { type: "string" },
+ },
+ type: "object",
+ },
+ type: "array",
+ },
+ title: { description: "Report title", type: "string" },
+ },
+ required: ["title", "subtitle", "generatedAt", "period", "author"],
+ type: "object",
+ },
+};
+
+export const ListBlocksTool = () => {
+ useWebMCP({
+ description:
+ "List all available PDF document templates (invoices and reports). Use this to find the right template before generating a PDF.",
+ execute: ({ type = "all" }: { type?: string }) => {
+ const filtered =
+ type === "all" ? BLOCKS : BLOCKS.filter((b) => b.type === type);
+ return filtered;
+ },
+ inputSchema: {
+ properties: {
+ type: {
+ description: "Filter by template type (default: all)",
+ enum: ["invoice", "report", "all"],
+ type: "string",
+ },
+ },
+ type: "object",
+ },
+ name: `${SITE.NAME}_list_blocks`,
+ });
+
+ return null;
+};
+
+export const GetBlockTool = () => {
+ useWebMCP({
+ description:
+ "Get the data schema and installation command for a specific PDF template. Use this to understand what data fields are needed to populate the template.",
+ execute: ({ name }: { name: string }) => {
+ const block = BLOCKS.find((b) => b.name === name);
+ if (!block) {
+ throw new Error(
+ `Unknown block: ${name}. Available: ${BLOCKS.map((b) => b.name).join(", ")}`
+ );
+ }
+ const schema = BLOCK_SCHEMAS[name] ?? null;
+ return { ...block, dataSchema: schema, docsUrl: `/docs/blocks#${name}` };
+ },
+ inputSchema: {
+ properties: {
+ name: {
+ description: "Template name (e.g. invoice-classic, report-marketing)",
+ type: "string",
+ },
+ },
+ required: ["name"],
+ type: "object",
+ },
+ name: `${SITE.NAME}_get_block`,
+ });
+
+ return null;
+};
+
+export const PreviewBlockTool = () => {
+ useWebMCP({
+ description:
+ "Open a PDF preview for a template in a new browser tab. The preview uses sample data and the current theme.",
+ execute: ({ name, base = "takumi" }: { name: string; base?: string }) => {
+ const block = BLOCKS.find((b) => b.name === name);
+ if (!block) {
+ throw new Error(`Unknown block: ${name}`);
+ }
+ const url = `/api/pdf/${base}?name=${name}`;
+ window.open(url, "_blank");
+ return { base, block: name, ok: true, url };
+ },
+ inputSchema: {
+ properties: {
+ base: {
+ description: "PDF rendering engine (default: takumi)",
+ enum: ["takumi", "forme"],
+ type: "string",
+ },
+ name: {
+ description: "Template name (e.g. invoice-classic)",
+ type: "string",
+ },
+ },
+ required: ["name"],
+ type: "object",
+ },
+ name: `${SITE.NAME}_preview_block`,
+ });
+
+ return null;
+};
diff --git a/components/web-mcp/docs-tools.tsx b/components/web-mcp/docs-tools.tsx
new file mode 100644
index 0000000..6308c3b
--- /dev/null
+++ b/components/web-mcp/docs-tools.tsx
@@ -0,0 +1,136 @@
+"use client";
+
+import { useWebMCP } from "use-webmcp-tool";
+
+import { ROUTES } from "@/constants/routes";
+import { SITE } from "@/constants/site";
+
+const DOC_PAGES = [
+ {
+ description: "Overview of pdfcn and its features",
+ path: ROUTES.DOCS,
+ title: "Introduction",
+ },
+ {
+ description: "How to install and set up pdfcn",
+ path: ROUTES.DOCS_INSTALLATION,
+ title: "Installation",
+ },
+ {
+ description: "Browse all PDF components",
+ path: ROUTES.DOCS_COMPONENTS,
+ title: "Components",
+ },
+ {
+ description: "Pre-built document templates (invoices, reports)",
+ path: ROUTES.DOCS_BLOCKS,
+ title: "Blocks",
+ },
+ {
+ description: "How to customize PDF themes",
+ path: ROUTES.DOCS_THEMING,
+ title: "Theming",
+ },
+ {
+ description: "Built-in theme gallery",
+ path: ROUTES.DOCS_THEMES,
+ title: "Theme Presets",
+ },
+ {
+ description: "Using pdfcn with MCP servers",
+ path: ROUTES.DOCS_MCP,
+ title: "MCP Integration",
+ },
+ {
+ description: "shadcn registry format and usage",
+ path: ROUTES.DOCS_REGISTRY,
+ title: "Registry",
+ },
+ {
+ description: "Recent updates and releases",
+ path: ROUTES.DOCS_CHANGELOG,
+ title: "Changelog",
+ },
+ {
+ description: "LLM-friendly documentation index",
+ path: ROUTES.LLMS,
+ title: "llms.txt",
+ },
+];
+
+export const OpenDocsTool = () => {
+ useWebMCP({
+ description:
+ "Navigate to a pdfcn documentation page. Use this to learn about components, theming, installation, or any other topic.",
+ execute: ({ path }: { path?: string }) => {
+ const target = path || ROUTES.DOCS;
+ window.location.assign(target);
+ return { ok: true, path: target };
+ },
+ inputSchema: {
+ properties: {
+ path: {
+ description:
+ "Documentation path (e.g. /docs/installation, /docs/components). If omitted, opens the main docs page.",
+ type: "string",
+ },
+ },
+ type: "object",
+ },
+ name: `${SITE.NAME}_open_docs`,
+ });
+
+ return null;
+};
+
+export const ListDocsTool = () => {
+ useWebMCP({
+ annotations: {
+ readOnlyHint: true,
+ },
+ description:
+ "List all available documentation pages with their paths and descriptions. Use this to discover what documentation is available.",
+ execute: () => DOC_PAGES,
+ inputSchema: {
+ properties: {},
+ type: "object",
+ },
+ name: `${SITE.NAME}_list_docs`,
+ });
+
+ return null;
+};
+
+export const GetInstallCommandTool = () => {
+ useWebMCP({
+ annotations: {
+ readOnlyHint: true,
+ },
+ description:
+ "Get the npx shadcn add command to install a specific pdfcn component or block into the user's project.",
+ execute: ({ component }: { component: string }) => {
+ const registryUrl = `https://pdfcn.vercel.app/r/${component}.json`;
+ const command = `npx shadcn@latest add "${registryUrl}"`;
+ return {
+ command,
+ component,
+ docsUrl: ROUTES.DOCS_INSTALLATION,
+ registryUrl,
+ };
+ },
+ inputSchema: {
+ properties: {
+ component: {
+ description:
+ "Component or block name (e.g. takumi/text, forme/invoice-classic)",
+ type: "string",
+ },
+ },
+ required: ["component"],
+ type: "object",
+ },
+ name: `${SITE.NAME}_get_install_command`,
+ });
+
+ return null;
+};
diff --git a/components/web-mcp/pdf-tool.tsx b/components/web-mcp/pdf-tool.tsx
new file mode 100644
index 0000000..82ee12c
--- /dev/null
+++ b/components/web-mcp/pdf-tool.tsx
@@ -0,0 +1,61 @@
+"use client";
+
+import { useWebMCP } from "use-webmcp-tool";
+
+import { SITE } from "@/constants/site";
+
+const BLOCK_NAMES = [
+ "invoice-classic",
+ "invoice-consultant",
+ "invoice-corporate",
+ "invoice-creative",
+ "invoice-minimal",
+ "invoice-modern",
+ "report-financial",
+ "report-marketing",
+ "report-operations",
+ "report-security",
+];
+
+export const GeneratePdfTool = () => {
+ useWebMCP({
+ description:
+ "Generate and download a PDF document. Opens the PDF in a new browser tab for viewing or downloading. Uses the template's default sample data.",
+ execute: ({ block, base = "takumi" }: { block: string; base?: string }) => {
+ if (!BLOCK_NAMES.includes(block)) {
+ throw new Error(
+ `Unknown block: ${block}. Available: ${BLOCK_NAMES.join(", ")}`
+ );
+ }
+ const url = `/api/pdf/${base}?name=${block}`;
+ window.open(url, "_blank");
+ return {
+ base,
+ block,
+ message: `Opening ${block} PDF in a new tab using ${base} engine.`,
+ ok: true,
+ url,
+ };
+ },
+ inputSchema: {
+ properties: {
+ base: {
+ description: "PDF rendering engine (default: takumi)",
+ enum: ["takumi", "forme"],
+ type: "string",
+ },
+ block: {
+ description:
+ "The document template to generate (e.g. invoice-classic)",
+ enum: BLOCK_NAMES,
+ type: "string",
+ },
+ },
+ required: ["block"],
+ type: "object",
+ },
+ name: `${SITE.NAME}_generate_pdf`,
+ });
+
+ return null;
+};
diff --git a/components/web-mcp/registry-tool.tsx b/components/web-mcp/registry-tool.tsx
new file mode 100644
index 0000000..114cc12
--- /dev/null
+++ b/components/web-mcp/registry-tool.tsx
@@ -0,0 +1,30 @@
+"use client";
+
+import { useWebMCP } from "use-webmcp-tool";
+
+import { ROUTES } from "@/constants/routes";
+import { SITE } from "@/constants/site";
+
+export const FetchRegistryTool = () => {
+ useWebMCP({
+ annotations: {
+ readOnlyHint: true,
+ },
+ description:
+ "Fetch the full shadcn registry manifest for pdfcn. Returns all available components, blocks, themes, and utilities with their file structures and dependencies.",
+ execute: async () => {
+ const res = await fetch(`${window.location.origin}${ROUTES.REGISTRY}`);
+ if (!res.ok) {
+ throw new Error(`Failed to fetch registry: ${res.status}`);
+ }
+ return res.json();
+ },
+ inputSchema: {
+ properties: {},
+ type: "object",
+ },
+ name: `${SITE.NAME}_fetch_registry`,
+ });
+
+ return null;
+};
diff --git a/components/web-mcp/search-tool.tsx b/components/web-mcp/search-tool.tsx
new file mode 100644
index 0000000..0e88441
--- /dev/null
+++ b/components/web-mcp/search-tool.tsx
@@ -0,0 +1,93 @@
+"use client";
+
+import { useWebMCP } from "use-webmcp-tool";
+
+import { ROUTES } from "@/constants/routes";
+import { SITE } from "@/constants/site";
+
+interface RegistryItem {
+ name: string;
+ title: string;
+ description: string;
+ type: string;
+}
+
+let cachedRegistry: RegistryItem[] | null = null;
+
+const fetchRegistry = async (): Promise<RegistryItem[]> => {
+ if (cachedRegistry) {
+ return cachedRegistry;
+ }
+ const res = await fetch(`${window.location.origin}${ROUTES.REGISTRY}`);
+ if (!res.ok) {
+ throw new Error(`Failed to fetch registry: ${res.status}`);
+ }
+ const data = await res.json();
+ cachedRegistry = (data.items ?? []) as RegistryItem[];
+ return cachedRegistry;
+};
+
+export const SearchComponentsTool = () => {
+ useWebMCP({
+ annotations: {
+ readOnlyHint: true,
+ },
+ description:
+ "Search the pdfcn component registry by name or description. Returns matching components, blocks, themes, and utilities with install commands.",
+ execute: async ({
+ query,
+ type = "all",
+ }: {
+ query: string;
+ type?: string;
+ }) => {
+ const items = await fetchRegistry();
+ const q = query.toLowerCase();
+
+ const matches = items.filter((item) => {
+ const nameMatch = item.name.toLowerCase().includes(q);
+ const descMatch = item.description?.toLowerCase().includes(q);
+ const titleMatch = item.title?.toLowerCase().includes(q);
+ return nameMatch || descMatch || titleMatch;
+ });
+
+ const typeMap: Record<string, string> = {
+ block: "registry:block",
+ lib: "registry:lib",
+ theme: "registry:theme",
+ ui: "registry:ui",
+ };
+ const typeFiltered =
+ type === "all"
+ ? matches
+ : matches.filter((item) => item.type === typeMap[type]);
+
+ return typeFiltered.map((item) => ({
+ description: item.description,
+ installCommand: `npx shadcn@latest add "https://pdfcn.vercel.app/r/${item.name}.json"`,
+ name: item.name,
+ title: item.title,
+ type: item.type,
+ }));
+ },
+ inputSchema: {
+ properties: {
+ query: {
+ description:
+ "Search query (fuzzy match against component names and descriptions)",
+ type: "string",
+ },
+ type: {
+ description: "Filter by item type (default: all)",
+ enum: ["ui", "block", "theme", "lib", "all"],
+ type: "string",
+ },
+ },
+ required: ["query"],
+ type: "object",
+ },
+ name: `${SITE.NAME}_search_components`,
+ });
+
+ return null;
+};
diff --git a/components/web-mcp/theme-tools.tsx b/components/web-mcp/theme-tools.tsx
new file mode 100644
index 0000000..f0c4f19
--- /dev/null
+++ b/components/web-mcp/theme-tools.tsx
@@ -0,0 +1,125 @@
+"use client";
+
+import { useWebMCP } from "use-webmcp-tool";
+
+import { ROUTES } from "@/constants/routes";
+import { SITE } from "@/constants/site";
+import { THEME_NAMES, getTheme, THEMES } from "@/registry/themes";
+import type { ThemePresetName } from "@/registry/themes";
+
+const themeSummary = (entry: (typeof THEMES)[number]) => ({
+ colors: {
+ accent: entry.theme.colors.accent,
+ background: entry.theme.colors.background,
+ foreground: entry.theme.colors.foreground,
+ primary: entry.theme.colors.primary,
+ },
+ name: entry.name,
+ page: entry.theme.page,
+ title: entry.title,
+ typography: {
+ bodyFont: entry.theme.typography.body.fontFamily,
+ headingFont: entry.theme.typography.heading.fontFamily,
+ },
+});
+
+export const ListThemesTool = () => {
+ useWebMCP({
+ description:
+ "List all available PDF themes with their color palettes, typography, and page settings. Use this to discover themes before applying one.",
+ execute: () => THEMES.map(themeSummary),
+ inputSchema: {
+ properties: {
+ category: {
+ description: "Filter category (currently only 'all' is supported)",
+ enum: ["all"],
+ type: "string",
+ },
+ },
+ type: "object",
+ },
+ name: `${SITE.NAME}_list_themes`,
+ });
+
+ return null;
+};
+
+export const GetThemeTool = () => {
+ useWebMCP({
+ description:
+ "Get the full token details for a specific PDF theme, including all colors, typography, spacing, and page settings.",
+ execute: ({ name }: { name: ThemePresetName }) => {
+ const entry = getTheme(name);
+ if (!entry) {
+ throw new Error(`Unknown theme: ${name}`);
+ }
+ return entry.theme;
+ },
+ inputSchema: {
+ properties: {
+ name: {
+ description: "The theme preset name to retrieve",
+ enum: [...THEME_NAMES],
+ type: "string",
+ },
+ },
+ required: ["name"],
+ type: "object",
+ },
+ name: `${SITE.NAME}_get_theme`,
+ });
+
+ return null;
+};
+
+export const ApplyThemeTool = () => {
+ useWebMCP({
+ description:
+ "Navigate to the Theme Builder with a specific theme pre-loaded. The user can then customize it visually. Returns the URL the browser will navigate to.",
+ execute: ({
+ name,
+ base = "takumi",
+ }: {
+ name: ThemePresetName;
+ base?: string;
+ }) => {
+ const entry = getTheme(name);
+ if (!entry) {
+ throw new Error(`Unknown theme: ${name}`);
+ }
+
+ const state = JSON.stringify({
+ basePreset: name,
+ theme: entry.theme,
+ });
+ const hash = new URLSearchParams({ theme: state }).toString();
+ const builderBase =
+ base === "forme"
+ ? ROUTES.THEME_BUILDER_FORME
+ : ROUTES.THEME_BUILDER_TAKUMI;
+ const url = `${builderBase}#${hash}`;
+
+ window.location.assign(url);
+ return { base, ok: true, theme: name, url };
+ },
+ inputSchema: {
+ properties: {
+ base: {
+ description: "PDF rendering engine (default: takumi)",
+ enum: ["takumi", "forme"],
+ type: "string",
+ },
+ name: {
+ description: "The theme preset to apply",
+ enum: [...THEME_NAMES],
+ type: "string",
+ },
+ },
+ required: ["name"],
+ type: "object",
+ },
+ name: `${SITE.NAME}_apply_theme`,
+ });
+
+ return null;
+};
diff --git a/components/web-mcp/web-mcp-tools.tsx b/components/web-mcp/web-mcp-tools.tsx
new file mode 100644
index 0000000..c8123bf
--- /dev/null
+++ b/components/web-mcp/web-mcp-tools.tsx
@@ -0,0 +1,29 @@
+"use client";
+
+import { ListBlocksTool, GetBlockTool, PreviewBlockTool } from "./block-tools";
+import {
+ OpenDocsTool,
+ ListDocsTool,
+ GetInstallCommandTool,
+} from "./docs-tools";
+import { GeneratePdfTool } from "./pdf-tool";
+import { FetchRegistryTool } from "./registry-tool";
+import { SearchComponentsTool } from "./search-tool";
+import { ListThemesTool, GetThemeTool, ApplyThemeTool } from "./theme-tools";
+
+export const WebMcpTools = () => (
+ <>
+ <ListThemesTool />
+ <GetThemeTool />
+ <ApplyThemeTool />
+ <ListBlocksTool />
+ <GetBlockTool />
+ <PreviewBlockTool />
+ <GeneratePdfTool />
+ <SearchComponentsTool />
+ <OpenDocsTool />
+ <ListDocsTool />
+ <GetInstallCommandTool />
+ <FetchRegistryTool />
+ </>
+);
diff --git a/package.json b/package.json
index 9b1214e..2cacfeb 100644
--- a/package.json
+++ b/package.json
@@ -47,6 +47,7 @@
"tailwind-merge": "^3.5.0",
"takumi-pdf": "^0.11.0",
"ts-morph": "^26.0.0",
+ "use-webmcp-tool": "^0.2.0",
"vaul": "^1.1.2",
"web-haptics": "^0.0.6",
"zod": "^4.3.6"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 3df0307..88ef0ce 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -107,6 +107,9 @@ importers:
ts-morph:
specifier: ^26.0.0
version: 26.0.0
+ use-webmcp-tool:
+ specifier: ^0.2.0
+ version: 0.2.0([email protected])
vaul:
specifier: ^1.1.2
@@ -4466,6 +4469,11 @@ packages:
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ resolution: {integrity: sha512-kYUpV1xFmX3Wnq68KOM1MbedpRc6mbgWEcVFtWpFPBTGEcuc7Sva4bHjRxM3k8mkGshkwxnLKn9/I4/NP2bTBw==}
+ peerDependencies:
+ react: '>=18'
+
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
@@ -9056,6 +9064,10 @@ snapshots:
dependencies:
react: 19.2.5
+ dependencies:
+ react: 19.2.5
+