Sponsored by Deepsite.site

MCP Test Server

Created By
nabadeep257 months ago
streamable http MCP Server using Nodejs
Content

MCP Test Server

A Model Context Protocol (MCP) server implementation with multiple tools for testing and demonstration purposes.

Overview

This server provides three main tools:

  • BMI Calculator: Calculate Body Mass Index from weight and height
  • Weather Service: Get weather information for any city (with API key support)
  • Echo Tool: Simple echo functionality for testing

Features

  • Built with TypeScript and Express.js
  • Streamable HTTP transport for MCP
  • Environment-based configuration
  • Hot reload development support
  • Modular tool architecture

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn package manager

Installation

  1. Clone or download this repository

  2. Install dependencies:

    npm install
    
  3. Copy the environment example file:

    cp .env.example .env
    
  4. (Optional) Add your weather API key to .env:

    WEATHER_API_KEY=your_openweathermap_api_key_here
    

Build and Run

Development Mode

# Build and start with hot reload
npm run dev

Production Mode

# Build the project
npm run build

# Start the server
npm start

The server will start on http://localhost:3000 (or the port specified in your PORT environment variable).

API Endpoint

The MCP server is accessible at:

POST http://localhost:3000/mcp

Available Tools

1. BMI Calculator (calculate-bmi)

Calculate Body Mass Index from weight and height.

Parameters:

  • weightKg (number): Weight in kilograms
  • heightM (number): Height in meters

2. Weather Service (get-weather)

Get current weather information for a city.

Parameters:

  • city (string): City name
  • country (string, optional): Country code (e.g., "IN", "US")

3. Echo Tool (echo)

Simple echo functionality for testing purposes.

Parameters:

  • message (string): Message to echo back

Testing the Server

Using MCP Inspector

For a GUI interface to test MCP server:

  1. Start server:

    npm start
    
  2. In another terminal, run the MCP inspector:

    npm run inspector
    

VS Code Integration

If you're using VS Code with MCP support, add this server to your settings:

{
  "mcp": {
    "servers": {
      "mcp-test-server": {
        "url": "http://localhost:3000/mcp"
      }
    }
  }
}

Project Structure

├── src/
│   ├── index.ts          # Main server file
│   └── tools/            # Tool implementations
│       ├── bmi.ts        # BMI calculator tool
│       ├── weather.ts    # Weather service tool
│       └── echo.ts       # Echo tool
├── build/                # Compiled JavaScript files
├── package.json          # Project configuration
├── tsconfig.json         # TypeScript configuration
├── .env.example          # Environment variables example
└── README.md             # This file

Development

Adding New Tools

  1. Create a new tool file in src/tools/:

    import { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
    import { z } from 'zod';
    
    export const myTool = {
      name: 'my-tool',
      schema: {
        param1: z.string(),
        param2: z.number(),
      },
      handler: async ({ param1, param2 }: { param1: string; param2: number }): Promise<CallToolResult> => {
        return {
          content: [
            {
              type: 'text',
              text: `Result: ${param1} - ${param2}`,
            },
          ],
        };
      },
    };
    
  2. Import and register it in src/index.ts:

    import { myTool } from './tools/my-tool.js';
    
    // In the getServer() function:
    server.tool(
      myTool.name,
      'Description of my tool',
      myTool.schema,
      myTool.handler
    );
    

Available Scripts

  • npm run build - Compile TypeScript to JavaScript
  • npm run watch - Watch for changes and recompile
  • npm run dev - Development mode with hot reload
  • npm start - Start the compiled server
  • npm run inspector - Launch MCP inspector
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Playwright McpPlaywright MCP server
Serper MCP ServerA Serper MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
DeepChatYour AI Partner on Desktop
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
CursorThe AI Code Editor
Tavily Mcp
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Amap Maps高德地图官方 MCP Server
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
ChatWiseThe second fastest AI chatbot™
WindsurfThe new purpose-built IDE to harness magic