What are Adapters?
Adapters allow you to integrate xmcp into your existing web applications instead of running it as a standalone server. They provide a seamless way to add MCP capabilities to Next.js, Express, or NestJS applications.Standalone vs Adapter Mode
xmcp can run in two modes:Standalone Mode
Run xmcp as an independent HTTP server:- Quick prototyping and testing
- Microservice architectures
- When you want MCP isolated from your main application
Adapter Mode
Integrate xmcp directly into your existing web framework:xmcp.config.ts
- Adding MCP to existing applications
- Sharing authentication and middleware
- Unified deployment and monitoring
- Leveraging framework-specific features
Available Adapters
Next.js Adapter
Next.js
Integrate xmcp into Next.js App Router with native support for API routes and authentication
- Full-stack React applications
- Edge runtime support
- OAuth 2.0 Bearer token authentication
- Server components and API routes
- Drop-in API route handler
- Built-in OAuth authentication
- Web standards (Request/Response)
- Protected resource metadata endpoints
Express Adapter
Express
Add xmcp to your Express.js server with minimal configuration
- Traditional Node.js REST APIs
- Existing Express applications
- Custom middleware integration
- Simple, straightforward setup
- Single-function integration
- CORS support out of the box
- Works with existing Express middleware
- Lightweight and performant
NestJS Adapter
NestJS
Bring xmcp into your NestJS application with full dependency injection support
- Enterprise applications
- TypeScript-first architecture
- Dependency injection patterns
- Advanced guards and interceptors
- Module, controller, and service structure
- NestJS dependency injection
- Guards for authentication
- OAuth module for protected resources
- Exception filters for error handling
Choosing an Adapter
I have an existing Next.js app
I have an existing Next.js app
Use the Next.js adapter. It integrates seamlessly with App Router and supports modern authentication patterns.
I have a simple Express API
I have a simple Express API
Use the Express adapter. It’s the simplest integration with minimal overhead.
I have a NestJS application
I have a NestJS application
Use the NestJS adapter. It follows NestJS patterns and supports dependency injection.
I need OAuth authentication
I need OAuth authentication
Use Next.js or NestJS adapters. Both provide built-in OAuth 2.0 support with protected resource metadata.
I'm starting from scratch
I'm starting from scratch
Consider standalone mode first for simplicity, or choose Next.js for a full-stack framework.
Configuration
All adapters are configured throughxmcp.config.ts:
xmcp.config.ts
Build Process
With adapters, you typically run two processes during development:The
xmcp CLI compiles your tools, prompts, and resources into optimized code that the adapter can use at runtime.Next Steps
Next.js Setup
Configure the Next.js adapter
Express Setup
Configure the Express adapter
NestJS Setup
Configure the NestJS adapter