sample-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@sample-mcpping hello"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
sample-mcp
NestJS + TypeScript MCP (Model Context Protocol) server boilerplate.
This project is intentionally small. Use it as a starting point when you want to add your own MCP tools and serve them through either stdio or Streamable HTTP.
Features
NestJS dependency injection for MCP tools
MCP SDK
Serverintegrationstdio transport for MCP clients such as Claude Desktop and Cursor
Streamable HTTP transport for local HTTP testing
Zod-based input validation
ESLint + Prettier setup for TypeScript
Related MCP server: MCP Server TypeScript Template
Project Structure
src/
main.ts # Transport bootstrap: stdio or HTTP
app.module.ts # Root Nest module
config/
app.config.ts # Environment config
mcp/
mcp.module.ts # MCP Nest module
mcp.service.ts # MCP server and request handlers
http/
mcp-http.controller.ts # POST /mcp Streamable HTTP endpoint
tools/
base.tool.ts # Base class for tools
tool.registry.ts # Tool list and execution registry
tools.module.ts # Nest providers for tools
ping/
ping.dto.ts # Zod schema and output type
ping.tool.ts # Example tool implementationSetup
pnpm installCopy .env.example to .env if you want local overrides.
MCP_SERVER_NAME=sample-mcp
MCP_SERVER_VERSION=1.0.0
LOG_LEVEL=log
NODE_ENV=development
TRANSPORT=stdio
PORT=3000Run
stdio mode
pnpm startUse stdio mode when another MCP client launches this server process.
HTTP mode
pnpm run start:httpThe MCP endpoint is:
POST http://localhost:3000/mcpHTTP requests must include:
Accept: application/json, text/event-stream
Content-Type: application/jsonTest With HTTP
List tools:
$body = @{
jsonrpc = "2.0"
id = 1
method = "tools/list"
params = @{}
} | ConvertTo-Json -Depth 10
Invoke-RestMethod `
-Method Post `
-Uri "http://localhost:3000/mcp" `
-ContentType "application/json" `
-Headers @{ Accept = "application/json, text/event-stream" } `
-Body $bodyCall the sample ping tool:
$body = @{
jsonrpc = "2.0"
id = 2
method = "tools/call"
params = @{
name = "ping"
arguments = @{
message = "hello"
}
}
} | ConvertTo-Json -Depth 10
Invoke-RestMethod `
-Method Post `
-Uri "http://localhost:3000/mcp" `
-ContentType "application/json" `
-Headers @{ Accept = "application/json, text/event-stream" } `
-Body $bodyAdd A New MCP Tool
Create a folder under
src/mcp/tools/<tool-name>/.Create a Zod schema file, for example
<tool-name>.dto.ts.Create a tool class that extends
BaseTool.Add the tool class to
ToolsModule.providers.Inject it into
ToolRegistryand add it toregisterTools([...]).
Minimal tool shape:
import { Injectable } from '@nestjs/common';
import type { CallToolResult, Tool } from '@modelcontextprotocol/sdk/types.js';
import { BaseTool } from '../base.tool';
@Injectable()
export class MyTool extends BaseTool {
get definition(): Tool {
return {
name: 'my-tool',
description: 'Describe what this tool does.',
inputSchema: {
type: 'object',
properties: {
input: { type: 'string' },
},
required: ['input'],
},
};
}
execute(args: Record<string, unknown>): Promise<CallToolResult> {
return Promise.resolve(this.success({ args }));
}
}Quality Checks
This boilerplate uses ESLint 8 with .eslintrc.cjs for broad editor and CLI compatibility.
pnpm lint
pnpm run lint:fix
pnpm exec tsc --noEmit
pnpm run buildThis server cannot be deployed
Maintenance
Related MCP Connectors
A simple Typescript MCP server built using the official MCP Typescript SDK and smithery/cli. This…
The official MCP Server for the Mux API
A TypeScript MCP server for Home Assistant, enabling programmatic management of entities, automati…
An MCP server that let you interact with Cycloid.io Internal Development Portal and Platform
Related MCP Servers
- AlicenseAqualityFmaintenanceA TypeScript-based MCP server that enables testing of REST APIs through Cline. This tool allows you to test and interact with any REST API endpoints directly from your development environment.1103 npm101MIT
- FlicenseNot gradedqualityDmaintenanceA demonstration MCP server built in TypeScript that shows how to implement stdio-based communication for integration with MCP clients. Serves as a template for building custom MCP servers with strong typing and maintainability.-
- FlicenseBqualityDmaintenanceA TypeScript MCP server boilerplate providing example tools and resources for rapid development of custom Model Context Protocol servers.8-
- AlicenseNot gradedqualityBmaintenanceA minimal NestJS MCP server skeleton for experimenting with the Model Context Protocol. Currently a placeholder with no implemented tools or resources.6 npmMIT