MCP ExplorerExplorer

Mcp Server Templates

@gupta-ujjwalon 12 days ago
1 Apache-2.0
FreeCommunity
AI Systems
This repository provides a template for setting up Model Context Protocol (MCP) servers for local development.

Overview

What is Mcp Server Templates

mcp-server-templates is a repository that provides templates for setting up Model Context Protocol (MCP) servers for local development, including various server implementations like Weather API, Calculator, and Notes.

Use cases

Use cases include developing and testing weather applications, creating calculators for educational purposes, and building note-taking applications for personal or organizational use.

How to use

To use mcp-server-templates, clone the repository, set up a virtual environment, install the UV package manager, and install the required dependencies. Each server can be run using the MCP dev server command.

Key features

Key features include multiple server implementations, easy setup with a virtual environment, and support for Python 3.10 or higher. The repository also includes documentation for each server.

Where to use

mcp-server-templates can be used in software development environments where local testing of MCP servers is required, particularly in applications involving weather data, mathematical calculations, and note-taking functionalities.

Content

MCP Servers Template

This repository provides a template for setting up Model Context Protocol (MCP) servers for local development. It includes examples of different MCP server implementations:

  1. Weather API - Provides weather alerts and forecasts
  2. Calculator - Basic and advanced mathematical operations
  3. Notes - Simple note-taking functionality with local file storage

Note: This project requires Python 3.10 or higher. See footnotes for instructions on using the correct Python version.

Project Structure

├── servers/          # MCP server implementations
│   ├── calculator.py # Calculator server implementation
│   ├── notes.py      # Notes server implementation
│   └── weather.py    # Weather API server implementation
├── docs/             # Documentation for the servers
├── requirements.txt  # Python dependencies
└── README.md         # This file

Requirements

  • Python 3.10+
  • FastMCP library
  • Other dependencies as listed in requirements.txt
  • UV package manager (recommended for faster installations)

Setup

  1. Clone the repository:

    git clone <repository-url>
    cd mcp-server-templates
    
  2. Set up a virtual environment (recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install UV package manager (if not already installed):

    pip install uv
    
  4. Install dependencies with UV:

    uv pip install -r requirements.txt
    

Usage

Running the MCP Servers

Each MCP server can be run using the MCP dev server command:

Weather API Server

mcp dev servers/weather.py

The Weather API provides the following tools:

  • get_alerts: Get weather alerts for a US state
  • get_forecast: Get weather forecast for a location based on latitude and longitude

Calculator Server

mcp dev servers/calculator.py

The Calculator provides mathematical operations including:

  • Basic operations: add, subtract, multiply, divide
  • Advanced operations: power, sqrt, cbrt, factorial, log, etc.
  • Trigonometric functions: sin, cos, tan

Notes Server

mcp dev servers/notes.py

The Notes server provides note management functionality including:

  • add_note: Create a new note with title and content
  • list_notes: Get all saved notes
  • get_note: Retrieve a specific note by ID
  • delete_note: Remove a note by ID
  • search_notes: Find notes containing a specific keyword
  • update_note: Modify an existing note’s title or content

VS Code Integration

These MCP servers can be integrated with Visual Studio Code for use with AI assistants. Configure your settings.json to include:

{
  "mcp": {
    "servers": {
      "weather": {
        "command": "bash",
        "args": [
          "-c",
          "source {AbsolutePathToTheFolder}/venv/bin/activate && uv --directory {AbsolutePathToTheFolder} run servers/weather.py"
        ]
      },
      "calculator": {
        "command": "bash",
        "args": [
          "-c",
          "source {AbsolutePathToTheFolder}/venv/bin/activate && uv --directory {AbsolutePathToTheFolder} run servers/calculator.py"
        ]
      },
      "notes": {
        "command": "bash",
        "args": [
          "-c",
          "source {AbsolutePathToTheFolder}/venv/bin/activate && uv --directory {AbsolutePathToTheFolder} run servers/notes.py"
        ]
      }
    }
  }
}

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.


Footnotes

Using Python 3.10+

  1. Check your Python version:

    python --version
    
  2. Install Python 3.10 or higher if needed:

    • macOS (using Homebrew):
      brew install [email protected]
      
    • Linux:
      sudo apt-get update
      sudo apt-get install python3.10
      
    • Windows: Download installer from python.org
  3. Use pyenv for managing multiple Python versions (recommended):

    # Install pyenv
    brew install pyenv  # macOS
    
    # Install Python version
    pyenv install 3.10.0
    
    # Set local Python version
    pyenv local 3.10.0
    
  4. Using UV with pyenv:

    # After setting up pyenv and activating your environment
    pip install uv
    uv pip install -r requirements.txt
    

References and Further Reading

Tools

No tools

Comments