This project is based on the Web Dev Simplified tutorial: The Ultimate MCP Crash Course - Build From Scratch.
MCP Server is a Node.js/TypeScript project implementing a server compatible with the Model Context Protocol (MCP), designed for AI and automation applications. The project includes both the server logic and a sample client CLI.
- MCP Server: Implements the MCP protocol for handling AI requests.
- Sample Client CLI: A command-line interface to test and interact with the server, built using
@inquirer/promptsfor interactive prompts and input. - Gemini API Support: Integration with Google Gemini via
@ai-sdk/google. - Data Validation: Uses Zod for input validation.
- Configuration Management: Supports environment variables via
dotenv.
├── src/
│ ├── server.ts # MCP server entry point
│ ├── client.ts # Sample client
│ └── data/
│ └── users.json # Sample user data
├── build/ # TypeScript build output
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── .env.example # Example environment configuration
- Node.js >= 18
- npm >= 9
- Clone the repository:
git clone <repo-url> cd mcp-server
- Install dependencies:
npm install
- Configure environment variables:
- Copy
.env.exampleto.envand add your Gemini API key.
- Copy
- Start server in development:
npm run server:dev
- Build the server:
npm run server:build
- Run sample client:
npm run client:dev
- MCP Inspector (debug):
npm run server:inspect
@modelcontextprotocol/sdk: MCP SDK for protocol implementation@ai-sdk/google: Gemini integration for AI requestszod: Data validation for input and outputdotenv: Environment variable managementtsx: TypeScript execution@inquirer/prompts: Used to build the interactive CLI client, providing user-friendly command-line prompts and input handling
Create a .env file based on .env.example:
GEMINI_API_KEY=your_gemini_api_key
Get your key from Google Gemini API.
- The sample client is a CLI application located in
src/client.ts, using@inquirer/promptsfor interactive command-line functionality. - Sample user data is in
src/data/users.json. - Server and client are written in TypeScript and compiled to
build/. - To customize logic, edit
src/server.tsandsrc/client.ts. - To stop the application, use the key combination
Ctrl+Cin the terminal.
