Expose your existing NestJS backend as an MCP
Quando usar: You don't want to rewrite service logic in Python or TS MCP SDK — reuse what's already tested.
Pré-requisitos
- NestJS 10+ app — Your existing project
- Install @rekog/mcp-nest — npm i @rekog/mcp-nest
Fluxo
-
Register the moduleAdd McpModule.forRoot({name: 'acme', version: '1.0'}) to app.module.ts.✓ Copiado→ 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.✓ Copiado→ Tool shows in Claude's tool list -
Hook up authApply the existing JwtAuthGuard on the MCP controller so agents need a valid bearer token.✓ Copiado→ Unauth'd calls return 401
Resultado: Your agents consume your real backend — same validation, same auth, no service duplication.
Armadilhas
- Mixing user-scoped and service-scoped tools creates auth confusion — Split into two MCP modules: one with user JWT, one with service token