A bash script to quickly scaffold new MCP (Model Context Protocol) server projects based on the memgraphdb-mcp-server template.
Download and run the script directly:
curl -fsSL https://raw.githubusercontent.com/playground/scaffold-mcp-server/main/scaffold-mcp-server.sh | bash -s -- my-mcp-server
Replace my-mcp-server with your desired server name.
Or download first, then run:
# Download the script
curl -fsSL https://raw.githubusercontent.com/YOUR_USERNAME/YOUR_REPO/main/scaffold-mcp-server.sh -o scaffold-mcp-server.sh
# Make it executable
chmod +x scaffold-mcp-server.sh
# Run it
./scaffold-mcp-server.sh my-mcp-server
If you already have the script locally:
chmod +x scaffold-mcp-server.sh
./scaffold-mcp-server.sh <server-name>
./scaffold-mcp-server.sh <server-name>
./scaffold-mcp-server.sh my-mcp-server
This will create a new directory my-mcp-server/ with the complete project structure.
Create and start a new MCP server in one command:
curl -fsSL https://raw.githubusercontent.com/YOUR_USERNAME/YOUR_REPO/main/scaffold-mcp-server.sh | bash -s -- my-mcp-server && cd my-mcp-server && npm install && cp .env.example .env && npm run dev
my-mcp-server, api-connector-mcp, database-query-serveryour-server-name/
βββ src/
β βββ tools/ # MCP tools (functions callable by AI)
β β βββ exampleTool.ts # Example tool implementation
β βββ services/ # Business logic and utilities
β β βββ common.ts # Common utility functions
β βββ models/ # TypeScript interfaces and types
β β βββ model.ts # Data models and session types
β βββ prompts/ # MCP prompts (pre-defined interactions)
β β βββ example-prompts.ts
β βββ scripts/ # Utility scripts
β βββ mcp-server.ts # MCP server configuration
β βββ server.ts # HTTP server entry point
βββ docs/
β βββ GETTING_STARTED.md # Quick start guide
βββ package.json # Node.js dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ Dockerfile # Docker container configuration
βββ .dockerignore # Docker ignore patterns
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore patterns
βββ README.md # Project documentation
Navigate to your project:
cd your-server-name
Install dependencies:
npm install
Configure environment:
cp .env.example .env
# Edit .env with your configuration
Run in development mode:
npm run dev
Test the server:
curl http://localhost:3000/mcp/health
The generated project includes these scripts:
npm run dev - Run in development mode with hot reloadnpm run build - Build TypeScript to JavaScriptnpm start - Build and run in production modenpm run dev:port - Run on custom port: npm run dev:port --port=3001npm run inspector - Run MCP inspector for debuggingnpm run build:docker:arm64 - Build Docker image for ARM64 (Apple Silicon)npm run build:docker:amd64 - Build Docker image for AMD64 (Intel/AMD)Create new tool files in src/tools/:
// src/tools/myTool.ts
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { z } from 'zod';
export function registerMyTool(server: McpServer) {
server.tool(
'my-tool',
'Description of what this tool does',
{
param1: z.string().describe('Parameter description')
},
async (params: any) => {
// Your tool logic here
return {
content: [{ type: 'text', text: 'Result' }]
};
}
);
}
Then register it in src/mcp-server.ts:
import { registerMyTool } from './tools/myTool';
// ...
registerMyTool(server);
Create prompt files in src/prompts/:
// src/prompts/my-prompts.ts
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
export function registerMyPrompts(server: McpServer) {
server.prompt(
'my-prompt',
'Description of this prompt',
async (args: any) => {
return {
messages: [
{
role: 'user',
content: {
type: 'text',
text: 'Your prompt content'
}
}
]
};
}
);
}
Create service files in src/services/ for business logic, API clients, database connections, etc.
.env for environment-specific settingspackage.json with your project detailsREADME.md with your documentation# For ARM64 (Apple Silicon)
npm run build:docker:arm64
# For AMD64 (Intel/AMD)
npm run build:docker:amd64
docker run -p 3000:8080 --env-file .env your-image-name
The generated server follows the MCP (Model Context Protocol) specification:
The .env.example file includes:
PORT=3000 # Server port
# Add your service-specific variables here
The server includes a health check endpoint:
curl http://localhost:3000/mcp/health
# Response: {"status":"healthy"}
chmod +x scaffold-mcp-server.shnpm installtsconfig.json configuration.env or use npm run dev:port --port=3001./scaffold-mcp-server.sh postgres-mcp-server
cd postgres-mcp-server
npm install
# Add pg dependency
npm install pg @types/pg
# Implement your database tools
./scaffold-mcp-server.sh github-api-mcp-server
cd github-api-mcp-server
npm install
# Add axios dependency
npm install axios
# Implement your API tools
./scaffold-mcp-server.sh filesystem-mcp-server
cd filesystem-mcp-server
npm install
# Implement file system tools
This scaffolding script is based on the memgraphdb-mcp-server template, which includes:
To improve the scaffolding script:
scaffold-mcp-server.sh./scaffold-mcp-server.sh test-serverrm -rf test-serverISC
This scaffolding script was created to streamline MCP server development and follows best practices from the Model Context Protocol specification.