{"_id":"@candide/nestjs-mcp-server","_rev":"12-b06e49e4998e0fdfc9247da42af24556","name":"@candide/nestjs-mcp-server","dist-tags":{"latest":"1.3.1"},"versions":{"1.1.0":{"name":"@candide/nestjs-mcp-server","version":"1.1.0","keywords":["decorators","integration","large-language-models","llm","mcp","model-context-protocol","module","nestjs","npm","pnpm","sdk","server","typescript","yarn"],"author":{"name":"Adrián Darío Hidalgo Flores"},"license":"MIT","_id":"@candide/nestjs-mcp-server@1.1.0","maintainers":[{"name":"naude.dewit","email":"naude.dewit@candide.com"},{"name":"dave.candide","email":"david.branton@candide.com"},{"name":"candide.eu","email":"tech@candide.eu"},{"name":"johnowennixon","email":"john.owen.nixon@gmail.com"},{"name":"jpcandide","email":"jean-paul.gorman@candide.com"},{"name":"mnightingale2","email":"michael.nightingale@candide.com"},{"name":"kiernan809","email":"lee.kiernan@gmail.com"},{"name":"duplessisvanaswegencandide","email":"duplessis.vanaswegen@candide.com"},{"name":"elna-pistorius","email":"elna.pistorius@candide.com"},{"name":"cmdrdats-stakara","email":"deon@stakara.com"},{"name":"gerhardp","email":"gerhard.potgieter@candide.com"}],"homepage":"https://github.com/adrian-d-hidalgo/nestjs-mcp-server#readme","bugs":{"url":"https://github.com/adrian-d-hidalgo/nestjs-mcp-server/issues"},"dist":{"shasum":"3114764a0c4a653c77e26e6fe17609592fde248f","tarball":"https://registry.npmjs.org/@candide/nestjs-mcp-server/-/nestjs-mcp-server-1.1.0.tgz","fileCount":79,"integrity":"sha512-DdmP8CM70qa1qKtYLaI13wOfVA4XScbEPRSGldXT6f1CMJwHSvkIqmSebCvnHaRXNYpHf2/i2odK/wK4UKr/AA==","signatures":[{"sig":"MEUCIQDCKkIkojnzZMZzbXjVShzu/gdmQ7fhqxjG6pfnYgSVuAIgZX3Z+ykxOmNA4edlZxlSqmyzVjycTFgThJy/xXMYgcE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":370888},"jest":{"rootDir":"src","testRegex":".*\\.spec\\.ts$","transform":{"^.+\\.(t|j)s$":["@swc/jest"]},"testEnvironment":"node","coverageDirectory":"../coverage","coverageThreshold":{"global":{"lines":85,"branches":55,"functions":70,"statements":80}},"collectCoverageFrom":["**/*.(t|j)s"],"moduleFileExtensions":["js","json","ts"],"coveragePathIgnorePatterns":["/index\\.ts$","\\.interface\\.ts$","\\.types\\.ts$"]},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18","pnpm":">=10"},"gitHead":"f5054294ec4016bd16e496064c39443d550990bf","scripts":{"test":"jest","build":"nest build","prepare":"is-ci || husky","lint:fix":"eslint \"{src,test,examples}/**/*.ts\" --fix","test:cov":"jest --coverage","test:e2e":"jest --config ./test/jest-e2e.json","typecheck":"tsc --noEmit","format:fix":"prettier --write \"{src,test,examples}/**/*.ts\"","lint:check":"eslint \"{src,test,examples}/**/*.ts\"","test:debug":"node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand","test:watch":"jest --watch","quality:fix":"pnpm lint:fix && pnpm format:fix","format:check":"prettier --check \"{src,test,examples}/**/*.ts\"","quality:check":"pnpm lint:check && pnpm format:check && pnpm typecheck","start:example":"npx -y ts-node-dev --respawn examples/$EXAMPLE/main.ts","start:inspector":"npx -y @modelcontextprotocol/inspector"},"_npmUser":{"name":"naude.dewit","email":"naude.dewit@candide.com"},"repository":{"url":"git+https://github.com/adrian-d-hidalgo/nestjs-mcp-server.git","type":"git"},"_npmVersion":"10.9.4","description":"Modular library for building scalable MCP servers with NestJS, providing decorators and integration patterns as a wrapper for the official MCP TypeScript SDK.","directories":{},"lint-staged":{"{src,test,examples}/**/*.ts":["eslint --fix","prettier --write"]},"_nodeVersion":"22.21.1","dependencies":{"zod":">=3.25.0","@modelcontextprotocol/sdk":"^1.26.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.12.1","devDependencies":{"jest":"^30.2.0","husky":"^9.1.7","is-ci":"^4.1.0","eslint":"^9.39.2","globals":"^16.5.0","ts-node":"^10.9.2","@swc/cli":"^0.7.10","prettier":"^3.8.1","@swc/core":"^1.15.11","@swc/jest":"^0.2.39","supertest":"^7.1.4","ts-loader":"^9.5.4","@eslint/js":"^9.39.2","typescript":"^5.9.3","@nestjs/cli":"^11.0.16","@types/jest":"^30.0.0","@types/node":"^25.0.3","lint-staged":"^16.2.7","@nestjs/config":"^4.0.3","@types/express":"^5.0.6","tsconfig-paths":"^4.2.0","@commitlint/cli":"^20.4.1","@nestjs/testing":"^11.1.13","@eslint/eslintrc":"^3.3.3","@types/supertest":"^6.0.3","semantic-release":"^25.0.3","@commitlint/types":"^20.4.0","typescript-eslint":"^8.51.0","@nestjs/schematics":"^11.0.9","source-map-support":"^0.5.21","@semantic-release/git":"^10.0.1","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","@semantic-release/github":"^12.0.6","@semantic-release/changelog":"^6.0.3","@commitlint/config-conventional":"^20.4.1"},"peerDependencies":{"rxjs":"^7.8.2","@nestjs/core":">=10.0.0","@nestjs/common":">=10.0.0","reflect-metadata":"^0.2.2","@nestjs/platform-express":">=10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/nestjs-mcp-server_1.1.0_1773637214054_0.9263241665239541","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@candide/nestjs-mcp-server","version":"1.1.1","keywords":["decorators","integration","large-language-models","llm","mcp","model-context-protocol","module","nestjs","npm","pnpm","sdk","server","typescript","yarn"],"author":{"name":"Adrián Darío Hidalgo Flores"},"license":"MIT","_id":"@candide/nestjs-mcp-server@1.1.1","maintainers":[{"name":"naude.dewit","email":"naude.dewit@candide.com"},{"name":"dave.candide","email":"david.branton@candide.com"},{"name":"candide.eu","email":"tech@candide.eu"},{"name":"johnowennixon","email":"john.owen.nixon@gmail.com"},{"name":"jpcandide","email":"jean-paul.gorman@candide.com"},{"name":"mnightingale2","email":"michael.nightingale@candide.com"},{"name":"kiernan809","email":"lee.kiernan@gmail.com"},{"name":"duplessisvanaswegencandide","email":"duplessis.vanaswegen@candide.com"},{"name":"elna-pistorius","email":"elna.pistorius@candide.com"},{"name":"cmdrdats-stakara","email":"deon@stakara.com"},{"name":"gerhardp","email":"gerhard.potgieter@candide.com"}],"homepage":"https://github.com/adrian-d-hidalgo/nestjs-mcp-server#readme","bugs":{"url":"https://github.com/adrian-d-hidalgo/nestjs-mcp-server/issues"},"dist":{"shasum":"ffc59baca2fc63c1737a5a16c2142e485928c97a","tarball":"https://registry.npmjs.org/@candide/nestjs-mcp-server/-/nestjs-mcp-server-1.1.1.tgz","fileCount":79,"integrity":"sha512-6fF/FrP8+EFEnP2Cyk9uClnlGJda1J9vAsZ1/wHdUJ2MSLfE5jpbW0rXFSBp2LypVgNfvPrX105/lDCfA+4L6g==","signatures":[{"sig":"MEUCIG65BRHzcPMtutRHD98q6RnGNR5OEHp4hPqfgd8EX8LrAiEA2HzvbTVwYTkfREbqRU7Bsxl2l8sXkvTdL8DVHtaR6MQ=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":370891},"jest":{"rootDir":"src","testRegex":".*\\.spec\\.ts$","transform":{"^.+\\.(t|j)s$":["@swc/jest"]},"testEnvironment":"node","coverageDirectory":"../coverage","coverageThreshold":{"global":{"lines":85,"branches":55,"functions":70,"statements":80}},"collectCoverageFrom":["**/*.(t|j)s"],"moduleFileExtensions":["js","json","ts"],"coveragePathIgnorePatterns":["/index\\.ts$","\\.interface\\.ts$","\\.types\\.ts$"]},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18","pnpm":">=10"},"gitHead":"f5054294ec4016bd16e496064c39443d550990bf","scripts":{"test":"jest","build":"nest build","prepare":"is-ci || husky","lint:fix":"eslint \"{src,test,examples}/**/*.ts\" --fix","test:cov":"jest --coverage","test:e2e":"jest --config ./test/jest-e2e.json","typecheck":"tsc --noEmit","format:fix":"prettier --write \"{src,test,examples}/**/*.ts\"","lint:check":"eslint \"{src,test,examples}/**/*.ts\"","test:debug":"node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand","test:watch":"jest --watch","quality:fix":"pnpm lint:fix && pnpm format:fix","format:check":"prettier --check \"{src,test,examples}/**/*.ts\"","quality:check":"pnpm lint:check && pnpm format:check && pnpm typecheck","start:example":"npx -y ts-node-dev --respawn examples/$EXAMPLE/main.ts","start:inspector":"npx -y @modelcontextprotocol/inspector"},"_npmUser":{"name":"naude.dewit","email":"naude.dewit@candide.com"},"repository":{"url":"git+https://github.com/adrian-d-hidalgo/nestjs-mcp-server.git","type":"git"},"_npmVersion":"10.9.4","description":"Modular library for building scalable MCP servers with NestJS, providing decorators and integration patterns as a wrapper for the official MCP TypeScript SDK.","directories":{},"lint-staged":{"{src,test,examples}/**/*.ts":["eslint --fix","prettier --write"]},"_nodeVersion":"22.21.1","dependencies":{"zod":">=3.25.0","@modelcontextprotocol/sdk":"^1.26.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.12.1","devDependencies":{"jest":"^30.2.0","husky":"^9.1.7","is-ci":"^4.1.0","eslint":"^9.39.2","globals":"^16.5.0","ts-node":"^10.9.2","@swc/cli":"^0.7.10","prettier":"^3.8.1","@swc/core":"^1.15.11","@swc/jest":"^0.2.39","supertest":"^7.1.4","ts-loader":"^9.5.4","@eslint/js":"^9.39.2","typescript":"^5.9.3","@nestjs/cli":"^11.0.16","@types/jest":"^30.0.0","@types/node":"^25.0.3","lint-staged":"^16.2.7","@nestjs/config":"^4.0.3","@types/express":"^5.0.6","tsconfig-paths":"^4.2.0","@commitlint/cli":"^20.4.1","@nestjs/testing":"^11.1.13","@eslint/eslintrc":"^3.3.3","@types/supertest":"^6.0.3","semantic-release":"^25.0.3","@commitlint/types":"^20.4.0","typescript-eslint":"^8.51.0","@nestjs/schematics":"^11.0.9","source-map-support":"^0.5.21","@semantic-release/git":"^10.0.1","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","@semantic-release/github":"^12.0.6","@semantic-release/changelog":"^6.0.3","@commitlint/config-conventional":"^20.4.1"},"peerDependencies":{"rxjs":">=7.0.0","@nestjs/core":">=10.0.0","@nestjs/common":">=10.0.0","reflect-metadata":">=0.1.13","@nestjs/platform-express":">=10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/nestjs-mcp-server_1.1.1_1773652850633_0.17148216524979465","host":"s3://npm-registry-packages-npm-production"}},"1.3.0":{"name":"@candide/nestjs-mcp-server","version":"1.3.0","keywords":["decorators","integration","large-language-models","llm","mcp","model-context-protocol","module","nestjs","npm","pnpm","sdk","server","typescript","yarn"],"author":{"name":"Adrián Darío Hidalgo Flores"},"license":"MIT","_id":"@candide/nestjs-mcp-server@1.3.0","maintainers":[{"name":"naude.dewit","email":"naude.dewit@candide.com"},{"name":"dave.candide","email":"david.branton@candide.com"},{"name":"candide.eu","email":"tech@candide.eu"},{"name":"johnowennixon","email":"john.owen.nixon@gmail.com"},{"name":"jpcandide","email":"jean-paul.gorman@candide.com"},{"name":"mnightingale2","email":"michael.nightingale@candide.com"},{"name":"kiernan809","email":"lee.kiernan@gmail.com"},{"name":"duplessisvanaswegencandide","email":"duplessis.vanaswegen@candide.com"},{"name":"elna-pistorius","email":"elna.pistorius@candide.com"},{"name":"cmdrdats-stakara","email":"deon@stakara.com"},{"name":"gerhardp","email":"gerhard.potgieter@candide.com"}],"homepage":"https://github.com/adrian-d-hidalgo/nestjs-mcp-server#readme","bugs":{"url":"https://github.com/adrian-d-hidalgo/nestjs-mcp-server/issues"},"dist":{"shasum":"691891f502b7950222574c9eeb7879ee3d1b089e","tarball":"https://registry.npmjs.org/@candide/nestjs-mcp-server/-/nestjs-mcp-server-1.3.0.tgz","fileCount":80,"integrity":"sha512-dMy3XdEn0fA046yOI/sHhInut80mRgbSkifncN3n5Vngp7iwB+39isTwo/lDeEE4Xo7rhC2bXs358ad0fn4opg==","signatures":[{"sig":"MEYCIQC9weHnGZAe9mPDoOp0gJ0dItCoTMlaZZY3KL62/RZj6gIhAJAwTtlc3yw7NJoDpPUYZ4G4jsluOylMCTQWsquOe1Ip","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":597373},"jest":{"rootDir":"src","testRegex":".*\\.spec\\.ts$","transform":{"^.+\\.(t|j)s$":["@swc/jest"]},"testEnvironment":"node","coverageDirectory":"../coverage","coverageThreshold":{"global":{"lines":85,"branches":55,"functions":70,"statements":80}},"collectCoverageFrom":["**/*.(t|j)s"],"moduleFileExtensions":["js","json","ts"],"coveragePathIgnorePatterns":["/index\\.ts$","\\.interface\\.ts$","\\.types\\.ts$"]},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18","pnpm":">=10"},"gitHead":"772a60d9d3e6103f4fe4166e1b01e54b290baa74","scripts":{"test":"jest","build":"nest build","prepare":"is-ci || husky","lint:fix":"eslint \"{src,test,examples}/**/*.ts\" --fix","test:cov":"jest --coverage","test:e2e":"jest --config ./test/jest-e2e.json","typecheck":"tsc --noEmit","format:fix":"prettier --write \"{src,test,examples}/**/*.ts\"","lint:check":"eslint \"{src,test,examples}/**/*.ts\"","test:debug":"node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand","test:watch":"jest --watch","quality:fix":"pnpm lint:fix && pnpm format:fix","format:check":"prettier --check \"{src,test,examples}/**/*.ts\"","quality:check":"pnpm lint:check && pnpm format:check && pnpm typecheck","start:example":"npx -y ts-node-dev --respawn examples/$EXAMPLE/main.ts","start:inspector":"npx -y @modelcontextprotocol/inspector"},"_npmUser":{"name":"naude.dewit","email":"naude.dewit@candide.com"},"repository":{"url":"git+https://github.com/adrian-d-hidalgo/nestjs-mcp-server.git","type":"git"},"_npmVersion":"10.9.4","description":"Modular library for building scalable MCP servers with NestJS, providing decorators and integration patterns as a wrapper for the official MCP TypeScript SDK.","directories":{},"lint-staged":{"{src,test,examples}/**/*.ts":["eslint --fix","prettier --write"]},"_nodeVersion":"22.21.1","dependencies":{"zod":">=3.25.0","@modelcontextprotocol/sdk":"^1.26.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.12.1","devDependencies":{"jest":"^30.2.0","husky":"^9.1.7","is-ci":"^4.1.0","eslint":"^9.39.2","globals":"^16.5.0","ts-node":"^10.9.2","@swc/cli":"^0.7.10","prettier":"^3.8.1","@swc/core":"^1.15.11","@swc/jest":"^0.2.39","supertest":"^7.1.4","ts-loader":"^9.5.4","@eslint/js":"^9.39.2","typescript":"^5.9.3","@nestjs/cli":"^11.0.16","@types/jest":"^30.0.0","@types/node":"^25.0.3","lint-staged":"^16.2.7","@nestjs/config":"^4.0.3","@types/express":"^5.0.6","tsconfig-paths":"^4.2.0","@commitlint/cli":"^20.4.1","@nestjs/testing":"^11.1.13","@eslint/eslintrc":"^3.3.3","@types/supertest":"^6.0.3","semantic-release":"^25.0.3","@commitlint/types":"^20.4.0","typescript-eslint":"^8.51.0","@nestjs/schematics":"^11.0.9","source-map-support":"^0.5.21","@semantic-release/git":"^10.0.1","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","@semantic-release/github":"^12.0.6","@semantic-release/changelog":"^6.0.3","@commitlint/config-conventional":"^20.4.1"},"peerDependencies":{"rxjs":">=7.0.0","@nestjs/core":">=10.0.0","@nestjs/common":">=10.0.0","reflect-metadata":">=0.1.13","@nestjs/platform-express":">=10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/nestjs-mcp-server_1.3.0_1774008166409_0.1155765764901826","host":"s3://npm-registry-packages-npm-production"}},"1.3.1":{"name":"@candide/nestjs-mcp-server","version":"1.3.1","keywords":["decorators","integration","large-language-models","llm","mcp","model-context-protocol","module","nestjs","npm","pnpm","sdk","server","typescript","yarn"],"author":{"name":"Adrián Darío Hidalgo Flores"},"license":"MIT","_id":"@candide/nestjs-mcp-server@1.3.1","maintainers":[{"name":"naude.dewit","email":"naude.dewit@candide.com"},{"name":"dave.candide","email":"david.branton@candide.com"},{"name":"candide.eu","email":"tech@candide.eu"},{"name":"johnowennixon","email":"john.owen.nixon@gmail.com"},{"name":"jpcandide","email":"jean-paul.gorman@candide.com"},{"name":"mnightingale2","email":"michael.nightingale@candide.com"},{"name":"kiernan809","email":"lee.kiernan@gmail.com"},{"name":"duplessisvanaswegencandide","email":"duplessis.vanaswegen@candide.com"},{"name":"elna-pistorius","email":"elna.pistorius@candide.com"},{"name":"cmdrdats-stakara","email":"deon@stakara.com"},{"name":"gerhardp","email":"gerhard.potgieter@candide.com"}],"homepage":"https://github.com/adrian-d-hidalgo/nestjs-mcp-server#readme","bugs":{"url":"https://github.com/adrian-d-hidalgo/nestjs-mcp-server/issues"},"dist":{"shasum":"bfb37be7bfff28efe5420d1bbf44e34a2c5023ad","tarball":"https://registry.npmjs.org/@candide/nestjs-mcp-server/-/nestjs-mcp-server-1.3.1.tgz","fileCount":80,"integrity":"sha512-q32/Op7mCEMvocXH1+XlSwmAEfvvbMovDiYPpy4/4BmDfyEPaEwe8JDtT+KViJwRKOWRdqwjsIyzI6Rw5MO1rg==","signatures":[{"sig":"MEQCIE6abaWXAM9wixdUNICm7GlNBVXaIpvWTkuot8ACTYwtAiAZKJ9Ws3nIRw4qa+Ggpc6O0z20MUNu/GvcAFmj6PV4Hw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":600306},"jest":{"rootDir":"src","testRegex":".*\\.spec\\.ts$","transform":{"^.+\\.(t|j)s$":["@swc/jest"]},"testEnvironment":"node","coverageDirectory":"../coverage","coverageThreshold":{"global":{"lines":85,"branches":55,"functions":70,"statements":80}},"collectCoverageFrom":["**/*.(t|j)s"],"moduleFileExtensions":["js","json","ts"],"coveragePathIgnorePatterns":["/index\\.ts$","\\.interface\\.ts$","\\.types\\.ts$"]},"main":"dist/index.js","types":"dist/index.d.ts","engines":{"node":">=18","pnpm":">=10"},"gitHead":"f7a76ce74489ef730103fbc5b50915bd9bafd7d2","scripts":{"test":"jest","build":"nest build","prepare":"is-ci || husky","lint:fix":"eslint \"{src,test,examples}/**/*.ts\" --fix","test:cov":"jest --coverage","test:e2e":"jest --config ./test/jest-e2e.json","typecheck":"tsc --noEmit","format:fix":"prettier --write \"{src,test,examples}/**/*.ts\"","lint:check":"eslint \"{src,test,examples}/**/*.ts\"","test:debug":"node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand","test:watch":"jest --watch","quality:fix":"pnpm lint:fix && pnpm format:fix","format:check":"prettier --check \"{src,test,examples}/**/*.ts\"","quality:check":"pnpm lint:check && pnpm format:check && pnpm typecheck","start:example":"npx -y ts-node-dev --respawn examples/$EXAMPLE/main.ts","start:inspector":"npx -y @modelcontextprotocol/inspector"},"_npmUser":{"name":"naude.dewit","email":"naude.dewit@candide.com"},"repository":{"url":"git+https://github.com/adrian-d-hidalgo/nestjs-mcp-server.git","type":"git"},"_npmVersion":"10.9.4","description":"Modular library for building scalable MCP servers with NestJS, providing decorators and integration patterns as a wrapper for the official MCP TypeScript SDK.","directories":{},"lint-staged":{"{src,test,examples}/**/*.ts":["eslint --fix","prettier --write"]},"_nodeVersion":"22.21.1","dependencies":{"zod":">=3.25.0","@modelcontextprotocol/sdk":"^1.26.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.12.1","devDependencies":{"jest":"^30.2.0","husky":"^9.1.7","is-ci":"^4.1.0","eslint":"^9.39.2","globals":"^16.5.0","ts-node":"^10.9.2","@swc/cli":"^0.7.10","prettier":"^3.8.1","@swc/core":"^1.15.11","@swc/jest":"^0.2.39","supertest":"^7.1.4","ts-loader":"^9.5.4","@eslint/js":"^9.39.2","typescript":"^5.9.3","@nestjs/cli":"^11.0.16","@types/jest":"^30.0.0","@types/node":"^25.0.3","lint-staged":"^16.2.7","@nestjs/config":"^4.0.3","@types/express":"^5.0.6","tsconfig-paths":"^4.2.0","@commitlint/cli":"^20.4.1","@nestjs/testing":"^11.1.13","@eslint/eslintrc":"^3.3.3","@types/supertest":"^6.0.3","semantic-release":"^25.0.3","@commitlint/types":"^20.4.0","typescript-eslint":"^8.51.0","@nestjs/schematics":"^11.0.9","source-map-support":"^0.5.21","@semantic-release/git":"^10.0.1","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","@semantic-release/github":"^12.0.6","@semantic-release/changelog":"^6.0.3","@commitlint/config-conventional":"^20.4.1"},"peerDependencies":{"rxjs":">=7.0.0","@nestjs/core":">=10.0.0","@nestjs/common":">=10.0.0","reflect-metadata":">=0.1.13","@nestjs/platform-express":">=10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/nestjs-mcp-server_1.3.1_1774017673851_0.25349256481129623","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-03-16T05:00:13.994Z","modified":"2026-09-07T07:39:01.312Z","1.1.0":"2026-03-16T05:00:14.227Z","1.1.1":"2026-03-16T09:20:50.769Z","1.3.0":"2026-03-20T12:02:46.550Z","1.3.1":"2026-03-20T14:41:14.019Z"},"bugs":{"url":"https://github.com/adrian-d-hidalgo/nestjs-mcp-server/issues"},"author":{"name":"Adrián Darío Hidalgo Flores"},"license":"MIT","homepage":"https://github.com/adrian-d-hidalgo/nestjs-mcp-server#readme","keywords":["decorators","integration","large-language-models","llm","mcp","model-context-protocol","module","nestjs","npm","pnpm","sdk","server","typescript","yarn"],"repository":{"url":"git+https://github.com/adrian-d-hidalgo/nestjs-mcp-server.git","type":"git"},"description":"Modular library for building scalable MCP servers with NestJS, providing decorators and integration patterns as a wrapper for the official MCP TypeScript SDK.","maintainers":[{"email":"naude.dewit@candide.com","name":"naude.dewit"},{"email":"david.branton@candide.com","name":"dave.candide"},{"email":"tech@candide.eu","name":"candide.eu"},{"email":"john.owen.nixon@gmail.com","name":"johnowennixon"},{"email":"michael.becker@candide.com","name":"mich.a.b"},{"email":"christiaan@pubfunc.com","name":"christiaan-pubfunc"},{"email":"lucian.blignaut@candide.com","name":"lucian-candide"},{"email":"rynhard@diefouries.com","name":"rynhardfourie1"},{"email":"henrike.basson@candide.com","name":"henrike.basson"},{"email":"gerhard.potgieter@candide.com","name":"gerhardp"}],"readme":"# MCP Server NestJS Module Library <!-- omit in toc -->\n\n[![NPM Version](https://img.shields.io/npm/v/@nestjs-mcp/server)](https://www.npmjs.com/package/@nestjs-mcp/server)\n[![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Downloads](https://img.shields.io/npm/dm/@nestjs-mcp/server)](https://www.npmjs.com/package/@nestjs-mcp/server)\n[![CI Pipeline](https://github.com/adrian-d-hidalgo/nestjs-mcp-server/actions/workflows/ci.yml/badge.svg)](https://github.com/adrian-d-hidalgo/nestjs-mcp-server/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/adrian-d-hidalgo/nestjs-mcp-server/graph/badge.svg?token=5E228VKY5K)](https://codecov.io/gh/adrian-d-hidalgo/nestjs-mcp-server)\n[![Known Vulnerabilities](https://snyk.io/test/github/adrian-d-hidalgo/nestjs-mcp-server/badge.svg)](https://snyk.io/test/github/adrian-d-hidalgo/nestjs-mcp-server)\n[![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](./LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](./CONTRIBUTING.md)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)\n\n---\n\n## Overview <!-- omit in toc -->\n\n**NestJS MCP Server** is a modular library for building [Model Context Protocol (MCP)](https://github.com/modelcontextprotocol/typescript-sdk/tree/server) servers using [NestJS](https://nestjs.com/). It provides decorators, modules, and integration patterns to expose MCP resources, tools, and prompts in a scalable, maintainable way. This project is a wrapper for the official [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk/tree/server) and is always kept compatible with its types and specification.\n\n---\n\n## Table of Contents <!-- omit in toc -->\n\n- [Installation](#installation)\n- [Quickstart](#quickstart)\n- [What is MCP?](#what-is-mcp)\n- [Core Concepts](#core-concepts)\n  - [Server](#server)\n  - [Resource](#resource)\n  - [Tool](#tool)\n  - [Prompt](#prompt)\n- [Module API](#module-api)\n  - [`McpModule.forRoot`](#mcpmoduleforroot)\n  - [`McpModule.forRootAsync`](#mcpmoduleforrootasync)\n  - [`McpModule.forFeature`](#mcpmoduleforfeature)\n- [Module Usage](#module-usage)\n  - [1. Global Registration with `McpModule.forRoot`](#1-global-registration-with-mcpmoduleforroot)\n  - [2. Feature Module Registration with `McpModule.forFeature`](#2-feature-module-registration-with-mcpmoduleforfeature)\n- [Capabilities](#capabilities)\n  - [Resolver Decorator](#resolver-decorator)\n  - [Prompt Decorator](#prompt-decorator)\n  - [Resource Decorator](#resource-decorator)\n  - [Tool Decorator](#tool-decorator)\n    - [Tool Annotations](#tool-annotations)\n    - [ToolOptions Variants](#tooloptions-variants)\n  - [RequestHandlerExtra Argument](#requesthandlerextra-argument)\n- [Guards](#guards)\n  - [Global-level guards](#global-level-guards)\n  - [Resolver-level guards](#resolver-level-guards)\n  - [Method-level guards](#method-level-guards)\n  - [Guard Example](#guard-example)\n  - [MCP Execution Context](#mcp-execution-context)\n  - [Guards with Dependency Injection](#guards-with-dependency-injection)\n- [Session Management](#session-management)\n  - [Session Management Options](#session-management-options)\n- [Transport Options](#transport-options)\n- [Inspector Playground](#inspector-playground)\n- [Examples](#examples)\n- [Changelog](#changelog)\n- [License](#license)\n- [Contributions](#contributions)\n\n---\n\n## Installation\n\n```sh\nnpm install @nestjs-mcp/server @modelcontextprotocol/sdk zod\n# or\nyarn add @nestjs-mcp/server @modelcontextprotocol/sdk zod\n# or\npnpm add @nestjs-mcp/server @modelcontextprotocol/sdk zod\n```\n\n---\n\n## Quickstart\n\nRegister the MCP module in your NestJS app and expose a simple tool:\n\n```ts\nimport { Module } from '@nestjs/common';\n\nimport { CallToolResult } from '@modelcontextprotocol/sdk/types';\n\nimport { Resolver, Tool, McpModule } from '@nestjs-mcp/server';\n\n@Resolver()\nexport class HealthResolver {\n  /**\n   * Simple health check tool\n   */\n  @Tool({ name: 'server_health_check' })\n  healthCheck(): CallToolResult {\n    return {\n      content: [\n        {\n          type: 'text',\n          text: 'Server is operational. All systems running normally.',\n        },\n      ],\n    };\n  }\n}\n\n@Module({\n  imports: [\n    McpModule.forRoot({\n      name: 'My MCP Server',\n      version: '1.0.0',\n    }),\n  ],\n  providers: [HealthResolver],\n})\nexport class AppModule {}\n```\n\n---\n\n## What is MCP?\n\nThe **Model Context Protocol (MCP)** is an open protocol for connecting LLMs to external data, tools, and prompts. MCP servers expose resources (data), tools (actions), and prompts (conversational flows) in a standardized way, enabling seamless integration with LLM-powered clients.\n\n- See the [Anthropic announcement](https://www.anthropic.com/news/model-context-protocol) for more background.\n\n---\n\n## Core Concepts\n\n### Server\n\nThe MCP Server is the main entry point for exposing capabilities to LLMs. It manages the registration and discovery of resources, tools, and prompts.\n\n### Resource\n\nA Resource represents structured data or documents that can be queried or retrieved by LLMs. Resources are typically read-only and are identified by a unique URI.\n\n- Learn more: [MCP Resources documentation](https://modelcontextprotocol.io/docs/concepts/resources)\n\n### Tool\n\nA Tool is an action or function that can be invoked by LLMs. Tools may have side effects and can accept parameters to perform computations or trigger operations.\n\n- Learn more: [MCP Tools documentation](https://modelcontextprotocol.io/docs/concepts/tools)\n\n### Prompt\n\nA Prompt defines a conversational flow, template, or interaction pattern for LLMs. Prompts help guide the model's behavior in specific scenarios.\n\n- Learn more: [MCP Prompts documentation](https://modelcontextprotocol.io/docs/concepts/prompts)\n\n> **See the [Capabilities](#capabilities) section for implementation details and code examples.**\n\n---\n\n## Module API\n\n### `McpModule.forRoot`\n\nRegisters the MCP Server globally in your NestJS application.\n\n**Parameters:**\n\n- `options: McpModuleOptions` — Main server configuration object:\n  - `name: string`: The name of your MCP server.\n  - `version: string`: The version of your MCP server.\n  - `instructions?: string`: Optional description of the MCP server for the client.\n  - `capabilities?: Record<string, unknown>`: Optional additional capabilities metadata.\n  - `providers?: Provider[]`: Optional array of NestJS providers to include in the module.\n  - `imports?: any[]`: Optional array of NestJS modules to import.\n  - `logging?: McpLoggingOptions`: Optional logging configuration:\n    - `enabled?: boolean` (default: `true`): Enable/disable logging.\n    - `level?: 'error' | 'warn' | 'log' | 'debug' | 'verbose'` (default: `'verbose'`): Set the logging level.\n  - `transports?: McpModuleTransportOptions`: Optional transport configuration (see [Transport Options](#transport-options)).\n  - `protocolOptions?: Record<string, unknown>`: Optional parameters passed directly to the underlying `@modelcontextprotocol/sdk` server instance.\n\n**Returns:**\n\n- A dynamic NestJS module with all MCP providers registered.\n\n**Example:**\n\n```ts\nimport { Module } from '@nestjs/common';\nimport { McpModule } from '@nestjs-mcp/server';\n\n@Module({\n  imports: [\n    McpModule.forRoot({\n      name: 'My Server',\n      version: '1.0.0',\n      instructions: 'A server providing utility tools and data.',\n      logging: { level: 'log' },\n      transports: { sse: { enabled: false } }, // Disable SSE transport\n      // ...other MCP options\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n### `McpModule.forRootAsync`\n\nRegisters the MCP Server globally using asynchronous options, useful for integrating with configuration modules like `@nestjs/config`.\n\n> **Note:**\n>\n> - The `imports` array should include any modules that provide dependencies required by your `useFactory` (e.g., `ConfigModule` if you inject `ConfigService`).\n> - Use `forRootAsync` only once in your root module (`AppModule`).\n> - See `McpModuleAsyncOptions` for all available options.\n\n**Parameters:**\n\n- `options: McpModuleAsyncOptions` — Asynchronous configuration object:\n  - `imports?: any[]`: Optional modules to import before the factory runs.\n  - `useFactory: (...args: any[]) => Promise<McpModuleOptions> | McpModuleOptions`: A factory function that returns the `McpModuleOptions`.\n  - `inject?: any[]`: Optional providers to inject into the `useFactory`.\n\n**Returns:**\n\n- A dynamic NestJS module.\n\n**Example (with ConfigModule):**\n\n```ts\nimport { Module } from '@nestjs/common';\nimport { ConfigModule, ConfigService } from '@nestjs/config';\nimport { McpModule } from '@nestjs-mcp/server';\n\n@Module({\n  imports: [\n    ConfigModule.forRoot(), // Make sure ConfigModule is imported\n    McpModule.forRootAsync({\n      imports: [ConfigModule], // Import ConfigModule here too\n      useFactory: (configService: ConfigService) => ({\n        name: configService.get<string>('MCP_SERVER_NAME', 'Default Server'),\n        version: configService.get<string>('MCP_SERVER_VERSION', '1.0.0'),\n        instructions: configService.get<string>('MCP_SERVER_DESC'),\n        logging: {\n          level: configService.get('MCP_LOG_LEVEL', 'verbose'),\n        },\n        // ... other options from configService\n      }),\n      inject: [ConfigService], // Inject ConfigService into the factory\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n### `McpModule.forFeature`\n\nRegisters additional MCP resources, tools, or prompts within a feature module. Use this to organize large servers into multiple modules. Resolvers containing MCP capabilities must be included in the `providers` array of the feature module.\n\n**Parameters:**\n\n- `options?: McpFeatureOptions` (Currently unused, reserved for future enhancements).\n\n**Returns:**\n\n- A dynamic module.\n\n**Example:**\n\n```ts\n// src/status/status.resolver.ts\nimport { Resolver, Tool } from '@nestjs-mcp/server';\nimport { CallToolResult } from '@modelcontextprotocol/sdk/types';\n\n@Resolver('status')\nexport class StatusResolver {\n  @Tool({ name: 'health_check' })\n  healthCheck(): CallToolResult {\n    return { content: [{ type: 'text', text: 'OK' }] };\n  }\n}\n\n// src/status/status.module.ts\nimport { Module } from '@nestjs/common';\nimport { McpModule } from '@nestjs-mcp/server';\nimport { StatusResolver } from './status.resolver';\n\n@Module({\n  imports: [McpModule.forFeature()], // Import forFeature here\n  providers: [StatusResolver], // Register your resolver\n})\nexport class StatusModule {}\n```\n\n---\n\n## Module Usage\n\nThis library provides two main ways to register MCP capabilities in your NestJS application:\n\n### 1. Global Registration with `McpModule.forRoot`\n\nUse `McpModule.forRoot` in your root application module to configure and register the MCP server globally. This is required for every MCP server application.\n\n```ts\nimport { Module } from '@nestjs/common';\nimport { McpModule } from '@nestjs-mcp/server';\nimport { PromptsResolver } from './prompts.resolver';\n\n@Module({\n  imports: [\n    McpModule.forRoot({\n      name: 'My MCP Server',\n      version: '1.0.0',\n      // ...other MCP options\n    }),\n  ],\n  providers: [PromptsResolver],\n})\nexport class AppModule {}\n```\n\n### 2. Feature Module Registration with `McpModule.forFeature`\n\nUse `McpModule.forFeature` in feature modules to register additional resolvers, tools, or resources. This is useful for organizing large servers into multiple modules.\n\n```ts\nimport { Module } from '@nestjs/common';\nimport { McpModule } from '@nestjs-mcp/server';\n\nimport { ToolsResolver } from './tools.resolver';\n\n@Module({\n  imports: [McpModule.forFeature()],\n  providers: [ToolsResolver],\n})\nexport class ToolsModule {}\n```\n\n- Use `forRoot` or `forRootAsync` **only once** in your root module (`AppModule`).\n- Use `forFeature` in any feature module where you define MCP capabilities (`@Resolver` classes).\n- Ensure all Resolvers are listed in the `providers` array of their respective modules.\n\n---\n\n## Capabilities\n\nThis library provides a set of decorators to define MCP capabilities and apply cross-cutting concerns such as guards. Decorators can be used at both the Resolver (class) level and the method level.\n\n### Resolver Decorator\n\nA Resolver is a class that groups related MCP capabilities. **All** MCP capability methods (`@Prompt`, `@Resource`, `@Tool`) **must** belong to a class decorated with `@Resolver`.\n\n- **No `@Injectable()` Needed:** Resolver classes are automatically treated as providers by the MCP module and **do not** require the `@Injectable()` decorator.\n- **Dependency Injection:** Standard NestJS dependency injection works within Resolver constructors.\n- **Namespacing:** You can optionally provide a string argument to `@Resolver('my_namespace')` to namespace the capabilities within that resolver.\n- **Guards:** Guards can be applied at the class level using `@UseGuards()`.\n\n**Example:**\n\n```ts\nimport { Resolver, Prompt, Resource, Tool } from '@nestjs-mcp/server';\n// Import any services you need to inject\nimport { SomeService } from '../some.service';\n\n@Resolver('workspace') // No @Injectable()\nexport class MyResolver {\n  // Inject dependencies as usual\n  constructor(private readonly someService: SomeService) {}\n\n  @Prompt({ name: 'greet_user' }) // Capabilities must be inside a Resolver\n  greetPrompt(/*...args...*/) {\n    const greeting = this.someService.getGreeting();\n    /* ... */\n  }\n\n  @Resource({ name: 'user_profile', uri: 'user://{id}' })\n  getUserResource(/*...args...*/) {\n    /* ... */\n  }\n\n  @Tool({ name: 'calculate_sum' })\n  sumTool(/*...args...*/) {\n    /* ... */\n  }\n}\n```\n\nYou can also apply guards at the resolver level:\n\n```ts\nimport { UseGuards, Resolver } from '@nestjs-mcp/server';\nimport { MyGuard } from './guards/my.guard';\n\n@UseGuards(MyGuard) // Applied to all capabilities in this Resolver\n@Resolver('secure') // No @Injectable()\nexport class SecureResolver {\n  // All capabilities in this resolver will use MyGuard\n}\n```\n\n### Prompt Decorator\n\nDecorate methods within a Resolver class to expose them as MCP Prompts. Accepts options compatible with `server.prompt()` from `@modelcontextprotocol/sdk`. **The `name` should use `snake_case`.**\n\n```ts\nimport { Prompt, Resolver } from '@nestjs-mcp/server';\nimport { RequestHandlerExtra } from '@nestjs-mcp/server'; // Import type for extra info\nimport { z } from 'zod'; // Example if using Zod schema\n\n// Optional: Define schema if needed\n// const SummaryArgs = z.object({ topic: z.string() });\n\n@Resolver('prompts') // Must be in a Resolver class\nexport class MyPrompts {\n  @Prompt({\n    name: 'generate_summary',\n    description: 'Generates a summary for the given text.',\n    // argsSchema: SummaryArgs\n  })\n  generateSummaryPrompt(\n    // params: z.infer<typeof SummaryArgs>, // Arguments based on argsSchema (if defined)\n    extra: RequestHandlerExtra, // Contains sessionId and other metadata\n  ) {\n    console.log(`Generating summary for session: ${extra.sessionId}`);\n    /* ... return CallPromptResult ... */\n    return { content: [{ type: 'text', text: 'Summary generated.' }] };\n  }\n}\n```\n\n### Resource Decorator\n\nDecorate methods within a Resolver class to expose them as MCP Resources. Accepts options compatible with `server.resource()` from `@modelcontextprotocol/sdk`. **The `name` should use `snake_case`.**\n\n```ts\nimport { Resource, Resolver } from '@nestjs-mcp/server';\nimport { RequestHandlerExtra } from '@nestjs-mcp/server'; // Import type for extra info\nimport { URL } from 'url'; // Type for URI resource\nimport { z } from 'zod'; // Example if using Zod template\n\n// Optional: Define template schema if needed\n// const DocQueryTemplate = z.object({ query: z.string() });\n\n@Resolver('data') // Must be in a Resolver class\nexport class MyResources {\n  @Resource({\n    name: 'user_profile',\n    uri: 'user://profiles/{userId}',\n    // metadata: { description: '...' } // Optional\n  })\n  getUserProfile(\n    uri: URL, // First argument is the parsed URI\n    // metadata: Record<string, any> // Second argument if is defined\n    extra: RequestHandlerExtra, // Contains sessionId and other metadata\n  ) {\n    const userId = uri.pathname.split('/').pop(); // Example: Extract ID from URI\n    console.log(`Fetching profile for ${userId}, session: ${extra.sessionId}`);\n    /* ... return CallResourceResult ... */\n    return { content: [{ type: 'text', text: `Profile data for ${userId}` }] };\n  }\n\n  @Resource({\n    name: 'document_list',\n    template: { type: 'string', description: 'Document content query' }, // Simple template example\n    // metadata: { list: true } // Optional\n  })\n  findDocuments(\n    uri: URL, // First arg based on simple template type\n    variables: Record<string, string>, // Second arg is path params (if any)\n    extra: RequestHandlerExtra, // Contains sessionId and other metadata\n  ) {\n    console.log(\n      `Finding documents matching '${query}', session: ${extra.sessionId}`,\n    );\n    /* ... return CallResourceResult ... */\n    return { content: [{ type: 'text', text: 'List of documents.' }] };\n  }\n}\n```\n\n### Tool Decorator\n\nDecorate methods within a Resolver class to expose them as MCP Tools. Accepts options compatible with `server.tool()` from `@modelcontextprotocol/sdk`. **The `name` should use `snake_case`.**\n\n```ts\nimport { Tool, Resolver } from '@nestjs-mcp/server';\nimport { RequestHandlerExtra } from '@nestjs-mcp/server';\nimport { z } from 'zod';\nimport { CallToolResult } from '@modelcontextprotocol/sdk/types';\n\n@Resolver('user_tools')\nexport class UserToolsResolver {\n  @Tool({\n    name: 'delete_user',\n    description: 'Deletes a user by ID',\n    paramsSchema: { userId: z.string() },\n    annotations: { destructiveHint: true, readOnlyHint: false },\n  })\n  deleteUser(\n    { userId }: { userId: string },\n    extra: RequestHandlerExtra,\n  ): CallToolResult {\n    // ...logic...\n    return { content: [{ type: 'text', text: `User ${userId} deleted.` }] };\n  }\n}\n```\n\n#### Tool Annotations\n\nThe `annotations` field allows you to provide protocol-level hints about the tool's behavior, such as whether it is destructive, read-only, idempotent, or has other special properties. These hints can be used by clients, UIs, or the protocol itself to display warnings, optimize calls, or enforce policies.\n\n**Common annotation keys:**\n\n- `destructiveHint` (boolean): Indicates the tool performs a destructive action (e.g., deletes data).\n- `readOnlyHint` (boolean): Indicates the tool does not modify any data.\n- `idempotentHint` (boolean): Indicates the tool can be safely called multiple times with the same effect.\n- `openWorldHint` (boolean): Indicates the tool may have side effects outside the current system.\n\n**Example:**\n\n```ts\n@Tool({\n  name: 'reset_password',\n  paramsSchema: { userId: z.string() },\n  annotations: { destructiveHint: true, idempotentHint: false }\n})\nresetPassword({ userId }: { userId: string }): CallToolResult {\n  // ...\n}\n```\n\n#### ToolOptions Variants\n\n| Variant                                          | Required Fields                              |\n| ------------------------------------------------ | -------------------------------------------- |\n| ToolBaseOptions                                  | name                                         |\n| ToolWithDescriptionOptions                       | name, description                            |\n| ToolWithParamOrAnnotationsOptions                | name, paramsSchemaOrAnnotations              |\n| ToolWithParamOrAnnotationsAndDescriptionOptions  | name, paramsSchemaOrAnnotations, description |\n| ToolWithParamAndAnnotationsOptions               | name, paramsSchema, annotations              |\n| ToolWithParamAndAnnotationsAndDescriptionOptions | name, paramsSchema, annotations, description |\n\n- `paramsSchema` and `paramsSchemaOrAnnotations` can be a Zod schema for input validation.\n- `annotations` is an object with protocol-level hints as described above.\n\n### RequestHandlerExtra Argument\n\nAll MCP capability methods (`@Prompt`, `@Resource`, `@Tool`) always receive a `RequestHandlerExtra` object as their last parameter. This object extends the original type from `@modelcontextprotocol/sdk` and provides essential context about the current MCP request.\n\n**Properties from SDK:**\n\n- `signal`: An `AbortSignal` used to communicate if the request was cancelled\n- `authInfo`: Optional information about a validated access token\n- `sessionId`: The session ID from the transport, if available\n- `sendNotification`: Function to send a notification related to the current request\n- `sendRequest`: Function to send a request related to the current request\n\n**Extended Properties:**\n\n- `headers`: HTTP headers from the original request (added by @nestjs-mcp/server)\n\n**Usage Example:**\n\n```ts\nimport { Tool, Resolver, SessionManager } from '@nestjs-mcp/server';\nimport { RequestHandlerExtra } from '@nestjs-mcp/server';\nimport { CallToolResult } from '@modelcontextprotocol/sdk/types';\n\n@Resolver('auth')\nexport class AuthResolver {\n  @Tool({\n    name: 'authenticate_user',\n    description: 'Authenticates a user with credentials',\n    // ...other options\n  })\n  authenticateUser(\n    params: { username: string; password: string },\n    extra: RequestHandlerExtra, // Always the last parameter\n  ): CallToolResult {\n    // Access the session ID\n    console.log(`Request received in session: ${extra.sessionId}`);\n\n    // Access request headers (extended property)\n    const authHeader = extra.headers.authorization;\n    const userAgent = extra.headers['user-agent'];\n    console.log(`Request from: ${userAgent}`);\n\n    // Check if request was cancelled\n    if (extra.signal.aborted) {\n      return {\n        content: [{ type: 'text', text: 'Request was cancelled' }],\n      };\n    }\n\n    // Implement authentication logic\n    return {\n      content: [{ type: 'text', text: 'Authentication successful' }],\n    };\n  }\n}\n```\n\n**Important Notes:**\n\n- `extra` is always the last parameter in any method decorated with `@Resource`, `@Prompt`, or `@Tool`\n- The `headers` property is an extension added by @nestjs-mcp/server to access HTTP headers directly\n\n---\n\n## Guards\n\nApply one or more guards to a Resolver, to individual methods, or globally. Guards must implement the NestJS `CanActivate` interface.\n\n### Global-level guards\n\nThis approach uses the standard NestJS global guard system (`APP_GUARD`). A global guard will protect **all** NestJS routes, including the MCP transport endpoints (like `/mcp` or `/sse`). Use this for broad authentication or checks that apply before any MCP-specific logic runs.\n\n```ts\n// src/guards/global-auth.guard.ts\nimport { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';\nimport { Request } from 'express';\n\n@Injectable()\nexport class GlobalAuthGuard implements CanActivate {\n  canActivate(context: ExecutionContext): boolean {\n    const request = context.switchToHttp().getRequest<Request>();\n    const apiKey = request.headers['x-api-key'];\n    // Example: Check for a valid API key\n    return !!apiKey && apiKey === 'EXPECTED_KEY';\n  }\n}\n```\n\nRegister the guard globally in your main module:\n\n```ts\n// src/app.module.ts\nimport { Module } from '@nestjs/common';\nimport { APP_GUARD } from '@nestjs/core';\nimport { McpModule } from '@nestjs-mcp/server';\nimport { GlobalAuthGuard } from './guards/global-auth.guard';\n\n@Module({\n  imports: [McpModule.forRoot(/*...*/)],\n  providers: [\n    {\n      provide: APP_GUARD,\n      useClass: GlobalAuthGuard,\n    },\n  ],\n})\nexport class AppModule {}\n```\n\n### Resolver-level guards\n\nThis is a custom feature of this library. Resolver-level guards are applied using the `@UseGuards()` decorator (exported from `@nestjs-mcp/server`) on a Resolver class. All MCP methods (`@Prompt`, `@Resource`, `@Tool`) **within that specific resolver** will be protected by these guards. Use this to enforce logic (e.g., role checks) for a group of related capabilities.\n\n```ts\nimport { UseGuards, Resolver, Prompt } from '@nestjs-mcp/server';\nimport { RoleGuard } from './guards/role.guard';\n\n@UseGuards(RoleGuard)\n@Resolver('admin')\nexport class AdminResolver {\n  @Prompt({ name: 'admin_action' })\n  adminAction(/*...*/) {\n    /* ... */\n  }\n  // ... other admin capabilities\n}\n```\n\n### Method-level guards\n\nThis is a custom feature of this library. Method-level guards are applied using the `@UseGuards()` decorator directly on an MCP capability method (`@Prompt`, `@Resource`, `@Tool`). Only the decorated method will be protected by these guards. Use this for fine-grained access control on specific capabilities.\n\n```ts\nimport { UseGuards, Resolver, Prompt, Tool } from '@nestjs-mcp/server';\nimport { SpecificCheckGuard } from './guards/specific-check.guard';\n\n@Resolver('mixed')\nexport class MixedResolver {\n  @Prompt({ name: 'public_prompt' })\n  publicPrompt() {\n    /* Publicly accessible */\n  }\n\n  @UseGuards(SpecificCheckGuard)\n  @Tool({ name: 'protected_tool' })\n  protectedTool(/*...*/) {\n    /* Requires SpecificCheckGuard to pass */\n  }\n}\n```\n\n**Important:** Resolver and Method-level guards **only run for MCP capability invocations**, not for the initial connection establishment handled by global guards. They use the custom `McpExecutionContext`.\n\n### Guard Example\n\nA guard for Resolver or Method-level protection:\n\n```ts\n// src/guards/my-mcp.guard.ts\nimport { CanActivate, Injectable } from '@nestjs/common';\nimport { McpExecutionContext, SessionManager } from '@nestjs-mcp/server';\n\n@Injectable()\nexport class MyMcpGuard implements CanActivate {\n  constructor(private readonly sessionManager: SessionManager) {}\n\n  canActivate(context: McpExecutionContext): boolean {\n    const sessionId = context.getSessionId();\n    if (!sessionId) return false;\n\n    const handlerArgs = context.getArgs();\n\n    const session = this.sessionManager.getSession(sessionId);\n    const request = session?.request;\n    const userAgent = request?.headers['user-agent'];\n\n    console.log(`Guard activated for session ${sessionId} from ${userAgent}`);\n    console.log('Handler args:', handlerArgs);\n\n    return true;\n  }\n}\n```\n\n### MCP Execution Context\n\nWhen implementing **Resolver-level** or **Method-level** guards using `@UseGuards()` from this library, your `canActivate` method receives an `McpExecutionContext` instance. This context provides access to MCP-specific information:\n\n```typescript\nimport { CanActivate, ExecutionContext, Injectable } from '@nestjs/common';\nimport { McpExecutionContext, SessionManager } from '@nestjs-mcp/server';\nimport { Request } from 'express';\n\n@Injectable()\nexport class McpAuthGuard implements CanActivate {\n  constructor(private readonly sessionManager: SessionManager) {}\n\n  canActivate(context: McpExecutionContext): boolean {\n    const sessionId = context.getSessionId();\n    if (!sessionId) {\n      console.error('Guard Error: MCP Session ID not found in context.');\n      return false;\n    }\n\n    const handlerArgs = context.getArgs<any>();\n    console.log('MCP Handler Arguments:', handlerArgs);\n\n    const session = this.sessionManager.getSession(sessionId);\n    if (!session) {\n      console.error(`Guard Error: Session not found for ID: ${sessionId}`);\n      return false;\n    }\n    const request = session.request as Request;\n\n    const authHeader = request.headers.authorization;\n    if (!authHeader || !authHeader.startsWith('Bearer ')) {\n      console.log('Guard Denied: Missing or invalid Bearer token.');\n      return false;\n    }\n    const token = authHeader.split(' ')[1];\n    const isValidToken = token === 'VALID_TOKEN';\n\n    if (isValidToken) {\n      console.log(`Guard Passed for session ${sessionId} with token.`);\n      return true;\n    } else {\n      console.log(`Guard Denied: Invalid token for session ${sessionId}.`);\n      return false;\n    }\n  }\n}\n```\n\n**Key points for `McpExecutionContext`:**\n\n- `getSessionId()`: Retrieves the unique ID for the current MCP session. **Crucial** for relating the guard check to the session state stored by `SessionManager`.\n- Arguments (`handlerArgs`): Provides the arguments passed specifically to the MCP handler method (`@Tool`, `@Prompt`, `@Resource`) being invoked. The structure of these arguments depends on the capability type and its definition (e.g., `params` for tools, `query`/`params` for resources). You access these via `context.getArgs()`, but be mindful of the actual structure based on the capability.\n- Request Data: Use the `SessionManager` injected into your guard to fetch the session details (including the original `Request`) based on the `sessionId` obtained from the context.\n- `switchToHttp().getResponse()` / `switchToHttp().getNext()`: These will throw errors as the Response object is not directly available or relevant in this context.\n\nUse `SessionManager` injected into your guard to fetch the session details (including the original `Request`) based on the `sessionId` obtained from the context.\n\n### Guards with Dependency Injection\n\nGuards can inject NestJS providers like `SessionManager`. Use `@Injectable()` and register the guard as a provider:\n\n```typescript\n@Injectable()\nexport class AuthGuard implements CanActivate {\n  constructor(private readonly sessionManager: SessionManager) {}\n\n  canActivate(context: McpExecutionContext): boolean {\n    const session = this.sessionManager.getSession(context.getSessionId());\n    return !!session?.request.headers.authorization;\n  }\n}\n\n@Module({\n  imports: [McpModule.forRoot({ name: 'my-server', version: '1.0.0' })],\n  providers: [AuthGuard, MyResolver],\n})\nexport class AppModule {}\n```\n\n> Guards without `@Injectable()` still work but won't receive injected dependencies.\n\n---\n\n## Session Management\n\nThis library includes a `SessionManager` service responsible for tracking active MCP sessions. Each incoming MCP connection establishes a session, identified by a unique `sessionId`. The `SessionManager` typically stores the associated initial `Request` object for each session.\n\n**Why is it important?**\n\n- **Accessing Request Data:** Since MCP operations (tool calls, prompt executions) might happen independently of the initial HTTP connection (especially with streaming transports like SSE), the `SessionManager` provides a way to retrieve the original `Request` context associated with a specific `sessionId`. This is essential for guards or capability methods (within Resolvers) that need access to request headers, parameters, or other connection-specific details from the original request.\n- **State Management:** While currently focused on storing the request, the `SessionManager` could be extended to store additional session-specific state if needed by your application.\n\n**Usage Example (in a Resolver):**\n\nResolvers might need access to the original request, for example, to get user information or API keys passed in headers during the initial connection.\n\n```typescript\nimport { Tool, Resolver, SessionManager } from '@nestjs-mcp/server';\nimport { RequestHandlerExtra } from '@nestjs-mcp/server'; // Provides sessionId\nimport { Request } from 'express';\nimport { CallToolResult } from '@modelcontextprotocol/sdk/types';\nimport { z } from 'zod';\n\nconst UserToolParams = z.object({\n  user_id: z.string().optional(),\n});\n\n@Resolver('user_tools') // No @Injectable() needed\nexport class UserToolsResolver {\n  // Inject SessionManager\n  constructor(private readonly sessionManager: SessionManager) {}\n\n  @Tool({\n    name: 'get_user_agent',\n    description:\n      'Gets the user agent from the original request for the session.',\n    paramSchema: UserToolParams,\n  })\n  getUserAgent(\n    params: z.infer<typeof UserToolParams>,\n    extra: RequestHandlerExtra, // Get extra info, including sessionId\n  ): CallToolResult {\n    const sessionId = extra.sessionId;\n    if (!sessionId) {\n      return {\n        content: [{ type: 'text', text: 'Error: Session ID missing.' }],\n      };\n    }\n\n    // Use sessionId to get the session from the manager\n    const session = this.sessionManager.getSession(sessionId);\n    if (!session) {\n      return {\n        content: [\n          {\n            type: 'text',\n            text: `Error: Session not found for ID: ${sessionId}`,\n          },\n        ],\n      };\n    }\n\n    // Access the original request stored in the session\n    const request = session.request as Request;\n    const userAgent = request.headers['user-agent'] || 'Unknown';\n\n    return {\n      content: [\n        { type: 'text', text: `Session ${sessionId} User Agent: ${userAgent}` },\n      ],\n    };\n  }\n}\n```\n\nIn this example:\n\n1. The `@Tool` method receives `extra: RequestHandlerExtra`, which contains the `sessionId`.\n2. The `SessionManager` is injected into the `UserToolsResolver`.\n3. The `sessionId` is used with `sessionManager.getSession()` to retrieve the session data.\n4. The original `request` object is accessed from the retrieved session data.\n\nThe `SessionManager` is automatically registered as a provider when you use `McpModule.forRoot` or `McpModule.forRootAsync` and can be injected like any other NestJS provider.\n\n---\n\n## Transport Options\n\nThe MCP server can communicate over different transport mechanisms. This library includes built-in support for:\n\n1.  **Streamable (`/mcp` endpoint):** A common transport using standard HTTP POST requests and responses. Suitable for most request/response interactions. Enabled by default.\n2.  **SSE (Server-Sent Events) (`/sse` endpoint):** A transport mechanism allowing the server to push updates to the client over a single HTTP connection. Useful for streaming responses or long-running operations. **Note:** This is considered a legacy transport but remains supported for compatibility. Enabled by default.\n\nYou can configure which transports are enabled globally using the `transports` option in `McpModule.forRoot` or `McpModule.forRootAsync`.\n\n**Configuration:**\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { McpModule } from '@nestjs-mcp/server';\n\n@Module({\n  imports: [\n    McpModule.forRoot({\n      name: 'My Server',\n      version: '1.0.0',\n      transports: {\n        streamable: { enabled: true }, // Keep streamable enabled (default)\n        sse: { enabled: false }, // Disable legacy SSE transport\n      },\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n**Default Configuration:**\n\nIf the `transports` option is omitted, both `streamable` (`/mcp`) and `sse` (`/sse`) are enabled by default.\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { McpModule } from '@nestjs-mcp/server';\n\n@Module({\n  imports: [\n    McpModule.forRoot({\n      name: 'My Server',\n      version: '1.0.0',\n      // Both streamable and sse will be enabled\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\nDisabling unused transports can slightly reduce the application's surface area and resource usage.\n\n---\n\n## Session Management Options\n\nConfigure session timeouts, cleanup intervals, and resource limits to optimize your server for production workloads.\n\n**Configuration:**\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { McpModule } from '@nestjs-mcp/server';\n\n@Module({\n  imports: [\n    McpModule.forRoot({\n      name: 'My Server',\n      version: '1.0.0',\n      session: {\n        sessionTimeoutMs: 1800000, // 30 minutes (default)\n        cleanupIntervalMs: 300000, // 5 minutes (default)\n        maxConcurrentSessions: 1000, // Max sessions (default)\n      },\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n**Configuration Options:**\n\n| Option                    | Type     | Default               | Description                                          |\n| ------------------------- | -------- | --------------------- | ---------------------------------------------------- |\n| `sessionTimeoutMs`        | `number` | `1800000` (30 min)    | Maximum inactivity time before session cleanup      |\n| `cleanupIntervalMs`       | `number` | `300000` (5 min)      | Frequency of cleanup job execution                   |\n| `maxConcurrentSessions`   | `number` | `1000`                | Maximum concurrent sessions allowed                  |\n\n**How It Works:**\n\n- **Activity Tracking**: Each session's `lastActivity` timestamp updates on every request\n- **Cleanup Job**: Runs every `cleanupIntervalMs` to close and remove inactive sessions\n- **Session Limit**: New connections are rejected (503) when `maxConcurrentSessions` is reached\n\n**Production Recommendations:**\n\n- **High-traffic servers**: Increase `maxConcurrentSessions` (2000-5000) and decrease `cleanupIntervalMs` (2-3 min)\n- **Low-memory environments**: Decrease `maxConcurrentSessions` (100-500) and `sessionTimeoutMs` (10-15 min)\n- **Long-running workflows**: Increase `sessionTimeoutMs` (60-90 min)\n\n**Example with Environment Variables:**\n\n```typescript\nimport { Module } from '@nestjs/common';\nimport { ConfigModule, ConfigService } from '@nestjs/config';\nimport { McpModule } from '@nestjs-mcp/server';\n\n@Module({\n  imports: [\n    ConfigModule.forRoot(),\n    McpModule.forRootAsync({\n      imports: [ConfigModule],\n      inject: [ConfigService],\n      useFactory: (config: ConfigService) => ({\n        name: 'My Server',\n        version: '1.0.0',\n        session: {\n          sessionTimeoutMs: config.get('MCP_SESSION_TIMEOUT', 1800000),\n          cleanupIntervalMs: config.get('MCP_CLEANUP_INTERVAL', 300000),\n          maxConcurrentSessions: config.get('MCP_MAX_SESSIONS', 1000),\n        },\n      }),\n    }),\n  ],\n})\nexport class AppModule {}\n```\n\n---\n\n## Inspector Playground\n\nUse the Inspector Playground to interactively test and debug your MCP server endpoints in a browser UI. This tool, powered by [`@modelcontextprotocol/inspector`](https://www.npmjs.com/package/@modelcontextprotocol/inspector), allows you to:\n\n- Explore available resources, tools, and prompts\n- Invoke endpoints and view responses in real time\n- Validate your server implementation against the MCP specification\n\nTo launch the Inspector Playground (make sure your NestJS MCP server is running):\n\n```sh\nnpx @modelcontextprotocol/inspector\n```\n\nIt will typically connect to `http://localhost:3000` by default, or you can specify a different target URL.\n\n---\n\n## Examples\n\nThe [`examples/`](./examples/) directory contains ready-to-use scenarios demonstrating how to register and expose MCP capabilities.\n\nEach example is self-contained and follows best practices. For advanced usage, see the code and documentation in each example.\n\n---\n\n## Changelog\n\nSee [CHANGELOG.md](./CHANGELOG.md) for release notes.\n\n---\n\n## License\n\nMIT — see [LICENSE](./LICENSE) for details.\n\n---\n\n## Contributions\n\nContributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines, reporting issues, and pull request rules.\n\nBefore contributing, please read our [Code of Conduct](./CODE_OF_CONDUCT.md) to understand the expectations for behavior in our community.\n","readmeFilename":"README.md"}