Skip to content

ViorelsS/mcp-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MCP Server

MCP Server Screenshot

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.

Main Features

  • 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/prompts for 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.

Project Structure

├── 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

Prerequisites

  • Node.js >= 18
  • npm >= 9

Installation

  1. Clone the repository:
    git clone <repo-url>
    cd mcp-server
  2. Install dependencies:
    npm install
  3. Configure environment variables:
    • Copy .env.example to .env and add your Gemini API key.

Main Scripts

  • 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

Main Dependencies

  • @modelcontextprotocol/sdk: MCP SDK for protocol implementation
  • @ai-sdk/google: Gemini integration for AI requests
  • zod: Data validation for input and output
  • dotenv: Environment variable management
  • tsx: TypeScript execution
  • @inquirer/prompts: Used to build the interactive CLI client, providing user-friendly command-line prompts and input handling

Environment Configuration

Create a .env file based on .env.example:

GEMINI_API_KEY=your_gemini_api_key

Get your key from Google Gemini API.

Additional Notes

  • The sample client is a CLI application located in src/client.ts, using @inquirer/prompts for 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.ts and src/client.ts.
  • To stop the application, use the key combination Ctrl+Cin the terminal.

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published