
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
@orbit-codes/nestjs-mcp
Advanced tools
A NestJS integration for the Model Context Protocol (MCP), allowing you to easily create MCP servers with NestJS's dependency injection and decorator-based architecture.
npm i @orbit-codes/nestjs-mcp @modelcontextprotocol/sdk zod
import { Module } from '@nestjs/common';
import { MCPModule } from 'nestjs-mcp';
@Module({
imports: [
MCPModule.register({
name: 'MyMCPServer',
version: '1.0.0',
// Optional configuration
sseEndpoint: '/mcp/sse',
messagesEndpoint: '/mcp/messages',
globalApiPrefix: '/api',
capabilities: {
// Your server capabilities
},
}),
],
})
export class AppModule {}
import { Injectable } from '@nestjs/common';
import { Resource } from 'nestjs-mcp';
@Injectable()
export class UsersService {
private users = [
{ id: '1', name: 'John Doe', email: 'john@example.com' },
{ id: '2', name: 'Jane Smith', email: 'jane@example.com' },
];
@Resource({
name: 'users',
description: 'Access user information',
parameters: {
id: 'string',
},
})
async getUser(uri, params) {
const { id } = params;
const user = this.users.find(u => u.id === id);
if (!user) {
throw new Error(`User with ID ${id} not found`);
}
return {
uri: uri.href,
text: JSON.stringify(user),
};
}
}
import { Injectable } from '@nestjs/common';
import { Tool } from 'nestjs-mcp';
@Injectable()
export class CalculatorService {
@Tool({
name: 'add',
description: 'Add two numbers together',
parameters: {
a: 'number',
b: 'number',
},
})
async add(params) {
const { a, b } = params;
const result = a + b;
return result.toString();
}
}
import { Injectable } from '@nestjs/common';
import { Prompt } from 'nestjs-mcp';
@Injectable()
export class PromptService {
@Prompt({
name: 'greeting',
description: 'Generate a personalized greeting',
template: 'Hello, {{name}}! Welcome to {{application}}.',
parameters: {
name: 'string',
application: 'string',
},
})
async greetingParameters(params) {
// You can modify or add to the parameters here
return {
currentTime: new Date().toLocaleTimeString(),
};
}
}
You can also configure the MCP module asynchronously:
import { Module } from '@nestjs/common';
import { MCPModule } from 'nestjs-mcp';
import { ConfigModule, ConfigService } from '@nestjs/config';
@Module({
imports: [
ConfigModule.forRoot(),
MCPModule.registerAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => ({
name: configService.get('MCP_SERVER_NAME'),
version: configService.get('MCP_SERVER_VERSION'),
sseEndpoint: configService.get('MCP_SSE_ENDPOINT', '/mcp/sse'),
messagesEndpoint: configService.get('MCP_MESSAGES_ENDPOINT', '/mcp/messages'),
}),
inject: [ConfigService],
}),
],
})
export class AppModule {}
Marks a method as an MCP resource handler.
name
: The name of the resourcedescription
: Description of the resourceparameters
: Parameter schema definitionMarks a method as an MCP tool handler.
name
: The name of the tooldescription
: Description of the toolparameters
: Parameter schema definitionMarks a method as an MCP prompt handler.
name
: The name of the promptdescription
: Description of the prompttemplate
: The prompt template with placeholdersparameters
: Parameter schema definitionname
: The name of the MCP serverversion
: The version of the MCP serversseEndpoint
: The endpoint for SSE (default: '/mcp/sse')messagesEndpoint
: The endpoint for messages (default: '/mcp/messages')globalApiPrefix
: Optional API prefix for all endpointscapabilities
: Optional capabilities object# Format the codebase
yarn format
# Check formatting
yarn format:check
# Lint the codebase
yarn lint
# Run all checks
yarn check
MIT
FAQs
A NestJS package to integrate MCP
The npm package @orbit-codes/nestjs-mcp receives a total of 1 weekly downloads. As such, @orbit-codes/nestjs-mcp popularity was classified as not popular.
We found that @orbit-codes/nestjs-mcp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.