diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..c007cbad --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,5 @@ +# AGENTS.md + +**MANDATORY: Read `CLAUDE.md` before starting any task.** + +All project instructions are in `CLAUDE.md`. diff --git a/CLAUDE.md b/CLAUDE.md index fa603194..98f3dea5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -62,7 +62,8 @@ Each package README has the detailed API. Don't duplicate here. ## Learnings - + + + + + diff --git a/packages/create-app/AGENTS.md b/packages/create-app/AGENTS.md new file mode 100644 index 00000000..ac982532 --- /dev/null +++ b/packages/create-app/AGENTS.md @@ -0,0 +1,52 @@ +# @mcp-apps-kit/create-app + +CLI tool for scaffolding MCP applications. Creates new projects with React or vanilla JS templates. + +## Quick Commands + +```bash +pnpm -C packages/create-app test # Run tests +pnpm -C packages/create-app typecheck # Type check only +pnpm -C packages/create-app lint # Lint only +``` + +## Key Exports + +- `scaffoldProject` - Programmatic project creation +- CLI binary: `create-mcp-apps-kit` + +## Templates + +- `react` - React + Vite + @mcp-apps-kit/ui-react +- `vanilla` - Vanilla JS + Vite + @mcp-apps-kit/ui + +Both include: + +- Server with example tool +- UI with theming +- Integration tests +- Optional Vercel deployment config + +## Dependencies + +- commander (CLI framework) +- @inquirer/prompts (interactive prompts) +- figlet, chalk (CLI styling) + +## Common Mistakes + +- Running in non-empty directory (fails) +- Fetches latest package versions from npm at runtime +- Generated projects use npm (not pnpm) to avoid workspace conflicts + +--- + +## Learnings + + + + + diff --git a/packages/testing/AGENTS.md b/packages/testing/AGENTS.md new file mode 100644 index 00000000..acf6ec96 --- /dev/null +++ b/packages/testing/AGENTS.md @@ -0,0 +1,52 @@ +# @mcp-apps-kit/testing + +Comprehensive testing library for MCP applications. Supports unit, integration, behavior, property, and LLM evaluation testing. + +## Quick Commands + +```bash +pnpm -C packages/testing test # Run tests +pnpm -C packages/testing typecheck # Type check only +pnpm -C packages/testing lint # Lint only +``` + +## Key Exports + +- `createTestEnvironment` - Full test setup with server and client +- `startTestServer` / `createTestClient` - Individual components +- `expectToolResult` - Fluent assertions for tool results +- `createMCPEval` / `describeEval` - LLM-based evaluation +- Framework adapters: `@mcp-apps-kit/testing/vitest`, `@mcp-apps-kit/testing/jest` + +## Patterns + +```typescript +const env = await createTestEnvironment({ app }); +const result = await env.client.callTool("greet", { name: "Alice" }); +expectToolResult(result).toMatchObject({ message: "Hello, Alice!" }); +await env.cleanup(); +``` + +## Dependencies + +- @modelcontextprotocol/sdk +- Zod 4 +- Optional: vitest, jest, fast-check, openai, @anthropic-ai/sdk + +## Common Mistakes + +- Forgetting `await env.cleanup()` (leaves server running) +- Not setting up vitest/jest matchers in setup file +- Missing optional peer deps for LLM eval features + +--- + +## Learnings + + + + + diff --git a/packages/testing/tests/unit/eval/generators.test.ts b/packages/testing/tests/unit/eval/generators.test.ts index f0db3060..537b24fc 100644 --- a/packages/testing/tests/unit/eval/generators.test.ts +++ b/packages/testing/tests/unit/eval/generators.test.ts @@ -262,7 +262,9 @@ describe.skipIf(!isFastCheckAvailable)("generated value validation", () => { const gen = generators.float(0, 1); const resolved = await resolveArbitrary(gen); const samples = fc.sample(resolved, 50); - expect(samples.every((n) => n >= 0 && n <= 1)).toBe(true); + // Use small epsilon for floating point comparison tolerance + const epsilon = 1e-10; + expect(samples.every((n) => n >= 0 - epsilon && n <= 1 + epsilon)).toBe(true); }); it("should generate booleans", async () => { diff --git a/packages/ui-react-builder/AGENTS.md b/packages/ui-react-builder/AGENTS.md new file mode 100644 index 00000000..52b6bf5d --- /dev/null +++ b/packages/ui-react-builder/AGENTS.md @@ -0,0 +1,54 @@ +# @mcp-apps-kit/ui-react-builder + +Build tool for React-based MCP application UIs. Bundles React components into self-contained HTML. + +## Quick Commands + +```bash +pnpm -C packages/ui-react-builder test # Run tests +pnpm -C packages/ui-react-builder typecheck # Type check only +pnpm -C packages/ui-react-builder lint # Lint only +``` + +## Key Exports + +- `defineReactUI` - Define UI with React component +- `buildReactUIs` / `buildReactUI` - Build to HTML +- `buildAndTransform` - Build and convert to core UIDefs in one step +- Vite plugin available via `@mcp-apps-kit/ui-react-builder/vite` + +## Patterns + +```typescript +const widgetUI = defineReactUI({ + component: MyWidget, + name: "My Widget", + prefersBorder: true, +}); + +const uis = await buildAndTransform({ "my-widget": widgetUI }); +``` + +## Dependencies + +- esbuild (bundling) +- @typescript-eslint/typescript-estree (AST parsing) +- Peer deps: @mcp-apps-kit/core, @mcp-apps-kit/ui-react, react, react-dom, vite (optional) + +## Common Mistakes + +- Forgetting to rebuild after component changes +- Not including component dependencies in build +- Missing vite peer dep when using vite plugin + +--- + +## Learnings + + + + + diff --git a/packages/ui-react/AGENTS.md b/packages/ui-react/AGENTS.md new file mode 100644 index 00000000..99bd065d --- /dev/null +++ b/packages/ui-react/AGENTS.md @@ -0,0 +1,56 @@ +# @mcp-apps-kit/ui-react + +React bindings for MCP applications. Provides hooks and context for building UIs. + +## Quick Commands + +```bash +pnpm -C packages/ui-react test # Run tests +pnpm -C packages/ui-react typecheck # Type check only +pnpm -C packages/ui-react lint # Lint only +``` + +## Key Exports + +- `AppsProvider` - Context provider (wrap your app) +- `useAppsClient` - Get client instance +- `useToolResult` - Get current tool result +- `useHostContext` - Get host context (theme, locale, etc.) +- `useDocumentTheme` / `useHostStyleVariables` - Auto-apply theming + +## Patterns + +```tsx + + +; + +function App() { + const result = useToolResult(); + useDocumentTheme("light", "dark"); + // ... +} +``` + +## Dependencies + +- @mcp-apps-kit/ui (re-exports many types) +- React 18 or 19 + +## Common Mistakes + +- Forgetting `AppsProvider` wrapper +- Not typing `useToolResult()` generic +- Using hooks outside provider context + +--- + +## Learnings + + + + + diff --git a/packages/ui/AGENTS.md b/packages/ui/AGENTS.md new file mode 100644 index 00000000..7fabddd7 --- /dev/null +++ b/packages/ui/AGENTS.md @@ -0,0 +1,49 @@ +# @mcp-apps-kit/ui + +Client-side SDK for MCP applications (vanilla JavaScript). Auto-detects host platform (MCP Apps vs ChatGPT) and provides unified API. + +## Quick Commands + +```bash +pnpm -C packages/ui test # Run tests +pnpm -C packages/ui typecheck # Type check only +pnpm -C packages/ui lint # Lint only +``` + +## Key Exports + +- `createClient` - Main entry point, auto-detects platform +- `detectProtocol` - Manual platform detection +- `McpAdapter` / `OpenAIAdapter` / `MockAdapter` - Protocol adapters +- Theme/style utilities: `applyDocumentTheme`, `applyHostStyleVariables` + +## Patterns + +```typescript +const client = await createClient(); +const result = await client.callTool("greet", { name: "Alice" }); +``` + +Subscribe to events with `onHostContextChange`, `onToolResult`. + +## Dependencies + +- @modelcontextprotocol/ext-apps + +## Common Mistakes + +- Forgetting to await `createClient()` (it's async) +- Not handling both MCP and OpenAI response formats +- Missing type parameter for typed tool calls + +--- + +## Learnings + + + + +