mcp-server-example

yoshinorin/mcp-server-example

3.1

If you are the rightful owner of mcp-server-example and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

A learning project for implementing Model Context Protocol (MCP) servers.

Tools
3
Resources
0
Prompts
0

MCP Server Sandbox

A learning project for implementing Model Context Protocol (MCP) servers. This project provides a simple MCP server with basic tools to understand MCP fundamentals.

Overview

This project is an educational sample created to learn the basic concepts of MCP servers. It includes the following features:

  • Greeting Tool: Greet with specified names in Japanese or English
  • Calculator Tool: Basic arithmetic operations (addition, subtraction, multiplication, division)
  • Time Tool: Get current date and time in various formats

Prerequisites

  • Node.js 16 or higher
  • npm or yarn

Setup

  1. Install dependencies:

    npm install
    
  2. Build the project:

    npm run build
    
  3. Start the server:

    npm run start
    

Development

Development mode (build → run):

npm run dev

Project Structure

mcp-server-sandbox/
├── src/
│   └── index.ts          # Main MCP server implementation
├── dist/                 # Compiled JavaScript
├── .vscode/
│   └── mcp.json         # VS Code MCP configuration
├── .github/
│   └── copilot-instructions.md
├── package.json
├── tsconfig.json
└── README.md

Implemented Tools

1. greet

Greets with the specified name.

Parameters:

  • name (string): Name of the person to greet
  • language (optional): "japanese" or "english"

2. calculate

Performs basic arithmetic operations.

Parameters:

  • operation: "add", "subtract", "multiply", "divide"
  • a (number): First number
  • b (number): Second number

3. current_time

Gets the current date and time.

Parameters:

  • format (optional): "iso", "japanese", "timestamp"

Usage with VS Code

This server can be integrated with VS Code's MCP functionality. The configuration is included in .vscode/mcp.json and can be used in VS Code's Agent mode.

Learning Points

Through this project, you can learn:

  1. Basic structure of MCP servers
  2. How to define and implement tools
  3. Type-safe argument validation using Zod
  4. Error handling
  5. Using STDIO transport

References