๐Ÿ“ฆ yoshinorin / mcp-server-example

โ˜… 0 stars โ‘‚ 0 forks ๐Ÿ‘ 0 watching
๐Ÿ“ฅ Clone https://github.com/yoshinorin/mcp-server-example.git
HTTPS git clone https://github.com/yoshinorin/mcp-server-example.git
SSH git clone git@github.com:yoshinorin/mcp-server-example.git
CLI gh repo clone yoshinorin/mcp-server-example
yoshinorin yoshinorin init b2c00a1 6 months ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ .vscode
๐Ÿ“ src
๐Ÿ“„ .gitignore
๐Ÿ“„ package-lock.json
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ tsconfig.json
๐Ÿ“„ README.md

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

  • Install dependencies:
npm install

  • Build the project:
npm run build

  • 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:

  • Basic structure of MCP servers
  • How to define and implement tools
  • Type-safe argument validation using Zod
  • Error handling
  • Using STDIO transport

References