NestJS MCP Server
by LiusDev
This repository demonstrates a NestJS implementation of the Model Context Protocol (MCP) with a microservice architecture. It includes an MCP server and a client that integrates with LangChain.js.
Last updated: N/A
What is NestJS MCP Server?
This is a NestJS-based implementation of the Model Context Protocol (MCP) showcasing a microservice architecture. It provides an MCP server that exposes tools, such as a function to get the current time, and an MCP backend that connects to the server using LangChain.js to process user queries.
How to use NestJS MCP Server?
- Clone the repository. 2. Install dependencies using
npm install
. 3. Rename.env.example
to.env
and add your OpenAI API key. 4. Start the MCP server usingnpm run start:dev mcp-server
. 5. Start the MCP backend usingnpm run start:dev mcp-backend
. 6. Send POST requests to the backend (e.g.,http://localhost:3001
) with a JSON payload like{"message": "What time is it in Viet Nam?"}
.
Key features of NestJS MCP Server
Model Context Protocol (MCP) implementation
Microservice architecture with NestJS
Integration with LangChain.js
Ability to connect to multiple MCP servers
Example tool for retrieving current time
Use cases of NestJS MCP Server
Providing contextual information to LLMs
Building AI applications that require real-time data
Demonstrating the use of MCP with LangChain.js
Creating modular and scalable AI services
FAQ from NestJS MCP Server
What is the Model Context Protocol (MCP)?
What is the Model Context Protocol (MCP)?
MCP is a protocol for providing contextual information to large language models (LLMs).
What is NestJS?
What is NestJS?
NestJS is a framework for building efficient, scalable Node.js server-side applications.
What is LangChain.js?
What is LangChain.js?
LangChain.js is a framework for developing applications powered by language models.
How do I add more tools to the MCP server?
How do I add more tools to the MCP server?
You can add more tools by implementing them in the mcp-server
application and exposing them via the MCP protocol.
How do I connect to multiple MCP servers?
How do I connect to multiple MCP servers?
You can configure multiple MCP servers in the McpClientModule.register
configuration in apps/mcp-backend/src/mcp-backend.module.ts
.