Examples
The mcp-lite repository includes runnable samples that demonstrate different adapters, runtimes, and features.
Validation Examples
Section titled “Validation Examples”Standard validation using Zod for schema validation and type inference.
Location: examples/validation-zod
Features:
- Type-safe input/output schemas
- Automatic JSON Schema conversion
- Runtime validation
Valibot
Section titled “Valibot”Lightweight validation using Valibot.
Location: examples/validation-valibot
Features:
- Valibot schema support
- Standard Schema compatibility
- Smaller bundle size
Effect Schema
Section titled “Effect Schema”Functional validation using Effect Schema.
Location: examples/validation-effectschema
Features:
- Effect ecosystem integration
- Composable schemas
- Advanced transformations
ArkType
Section titled “ArkType”TypeScript-first validation with ArkType.
Location: examples/validation-arktype
Features:
- Native TypeScript types
- Minimal runtime overhead
- Developer experience focus
Deployment Examples
Section titled “Deployment Examples”Cloudflare Workers with KV
Section titled “Cloudflare Workers with KV”Production-ready serverless deployment using Cloudflare KV for session and client request storage.
Location: examples/cloudflare-worker-kv
Features:
- KV-backed session adapter
- KV-backed client request adapter
- Distributed elicitation support
- Request polling patterns
Key Files:
src/mcp/session-adapter.ts- KV session storagesrc/mcp/client-request-adapter.ts- KV client request tracking
Feature Examples
Section titled “Feature Examples”Server Composition
Section titled “Server Composition”Multiple servers grouped behind one transport with namespacing.
Location: examples/composing-servers
Features:
- Modular server organization
- Namespace support
- Shared middleware
- Independent tool sets
Authentication with Clerk
Section titled “Authentication with Clerk”Complete authentication example using Clerk middleware.
Location: examples/auth-clerk
Features:
- Clerk integration
- Protected routes
- User context in handlers
- Auth state management
Quick Start
Section titled “Quick Start”Each example includes:
- Complete source code
README.mdwith setup instructions- Package configuration
- Environment variable templates (when applicable)
To run an example:
cd examples/<example-name>npm installnpm run devExample Structure
Section titled “Example Structure”Most examples follow this structure:
examples/<name>/├── src/│ ├── server.ts # Main MCP server setup│ └── tools/ # Tool definitions├── package.json└── README.mdContributing Examples
Section titled “Contributing Examples”Have a useful pattern or integration? Consider contributing an example to help others!
Next Steps
Section titled “Next Steps”- Getting Started - Build your first server
- Deployment - Deploy to production