Expose your existing NestJS backend as an MCP
Quand l'utiliser : You don't want to rewrite service logic in Python or TS MCP SDK — reuse what's already tested.
Prérequis
- NestJS 10+ app — Your existing project
- Install @rekog/mcp-nest — npm i @rekog/mcp-nest
Déroulement
-
Register the moduleAdd McpModule.forRoot({name: 'acme', version: '1.0'}) to app.module.ts.✓ Copié→ App starts; /mcp endpoint present
-
Decorate a service method as a toolIn TicketsService, decorate
searchTicketswith @Tool({name:'search_tickets', description:'...'}) and a Zod schema. Existing auth guards still apply.✓ Copié→ Tool shows in Claude's tool list -
Hook up authApply the existing JwtAuthGuard on the MCP controller so agents need a valid bearer token.✓ Copié→ Unauth'd calls return 401
Résultat : Your agents consume your real backend — same validation, same auth, no service duplication.
Pièges
- Mixing user-scoped and service-scoped tools creates auth confusion — Split into two MCP modules: one with user JWT, one with service token