Simple MCP Server

Simple MCP Server

A self-contained, dependency-free MCP server that provides utility tools for time, date, mathematical calculations, and shell command execution. It supports remote connectivity through SSE and is designed for easy deployment via Docker.

Category
访问服务器

README

Simple MCP Server

A simple, self-contained MCP (Model Context Protocol) server with basic utility functions. No API keys, no credit cards, no external dependencies required!

Features

  • Get Current Time - UTC and local time
  • Get Current Date - Multiple date formats
  • Calculate - Basic mathematical operations
  • Timezone Info - Get timezone information
  • Generate Random Numbers - Generate random numbers in a range
  • Execute Shell Commands - Run shell commands and get output
  • Comprehensive Logging - All requests logged to local file for monitoring

Complete Setup Guide

Step 1: Start the Server

  1. Navigate to the project directory:

    cd mcp
    
  2. Build and start the Docker container:

    docker compose up --build
    

    This will:

    • Build the Docker image
    • Start the container
    • Expose the server on port 8000
  3. Verify the server is running:

    # Check container status
    docker compose ps
    
    # Check logs (in another terminal)
    docker compose logs -f mcp-server
    
    # Test health endpoint (replace <remote-server-ip> with your server IP)
    curl -H "X-API-Key: your-secure-api-key-here" http://<remote-server-ip>:8000/health
    

    You should see:

    • Container status: Up
    • Logs showing: Uvicorn running on http://0.0.0.0:8000
    • Health check returning: {"status": "healthy"}

Step 2: Configure Cursor IDE

  1. Open Cursor IDE

  2. Open Command Palette:

    • Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac)
    • Type: MCP Settings or MCP: Configure
  3. Add New MCP Server:

    • Click "Add New" or "+" button
    • You'll be prompted to add server configuration
  4. Enter Server Configuration:

    Option A: Manual Entry

    • Name: simple-utils-server
    • URL: http://<remote-server-ip>:8000/sse
      • Replace <remote-server-ip> with your actual server IP address
      • Example: http://192.168.1.100:8000/sse or http://example.com:8000/sse
    • Transport: sse or SSE
    • Headers: Add X-API-Key: your-secure-api-key-here

    Option B: Import from mcp.json

    • Open the mcp.json file in this repository
    • Copy the entire contents
    • Paste it into the MCP settings configuration
    • Important: Replace <remote-server-ip> with your actual server IP address
    • The configuration should look like:
      {
        "mcpServers": {
          "simple-utils-server": {
            "url": "http://<remote-server-ip>:8000/sse",
            "transport": "sse",
            "headers": {
              "X-API-Key": "your-secure-api-key-here"
            }
          }
        }
      }
      
  5. Save the Configuration:

    • Click "Save" or press Enter
    • Cursor will automatically connect to the server
  6. Verify Connection:

    • Look for the MCP server status in Cursor's status bar
    • It should show: simple-utils-server: Connected
    • You should see 6 tools loaded

Step 3: Test the Connection

  1. In Cursor's chat, try asking:

    "What time is it right now?"
    
  2. The AI should:

    • Automatically use the get_current_time tool
    • Return the current time information
  3. Try other commands:

    "Calculate sqrt(144) + 5"
    "Run the command 'echo hello world'"
    "Get today's date"
    

Troubleshooting Connection Issues

  • Server not connecting?

    • Verify server is running: docker compose ps
    • Check server logs: docker compose logs mcp-server
    • Test server directly: curl http://<remote-server-ip>:8000/health
  • Connection refused?

    • Check firewall allows port 8000
    • Verify the IP address is correct
    • Ensure server is listening on 0.0.0.0 (it is by default)
  • Tools not loading?

    • Restart Cursor completely
    • Check MCP settings configuration is correct
    • Verify the URL includes /sse at the end

Security

The MCP server requires API key authentication for all requests.

API Key Authentication

Set the MCP_API_KEY environment variable:

export MCP_API_KEY="your-secure-api-key-here"

All requests must include the API key in the X-API-Key header:

curl -H "X-API-Key: your-secure-api-key-here" http://your-server:8000/health

Quick Start (Summary)

# 1. Start server
docker compose up --build

# 2. In Cursor: Ctrl+Shift+P -> MCP Settings -> Add New
#    URL: http://<remote-server-ip>:8000/sse
#    Transport: sse

# 3. Test: Ask "What time is it?"

Available Tools

1. get_current_time

Get the current time in UTC and local timezone.

Example:

{
  "tool": "get_current_time",
  "arguments": {}
}

2. get_current_date

Get the current date in various formats.

Example:

{
  "tool": "get_current_date",
  "arguments": {
    "format": "iso"
  }
}

Formats: iso, us, european, unix

3. calculate

Perform basic mathematical calculations.

Example:

{
  "tool": "calculate",
  "arguments": {
    "expression": "sqrt(16) + 2 * 3"
  }
}

Supported functions: sqrt, sin, cos, tan, log, log10, exp, pow, abs, round, floor, ceil, min, max, sum Constants: pi, e

4. get_timezone_info

Get information about a timezone.

Example:

{
  "tool": "get_timezone_info",
  "arguments": {
    "timezone": "America/New_York"
  }
}

5. generate_random_number

Generate random numbers within a specified range.

Example:

{
  "tool": "generate_random_number",
  "arguments": {
    "min_value": 1,
    "max_value": 100,
    "count": 5
  }
}

Parameters:

  • min_value (optional): Minimum value (default: 1)
  • max_value (optional): Maximum value (default: 100)
  • count (optional): Number of random numbers to generate (default: 1, max: 100)

Returns: Random number(s) with range information

6. execute_command

Execute a shell command and return the output. WARNING: Use with caution as this can execute arbitrary commands.

Example:

{
  "tool": "execute_command",
  "arguments": {
    "command": "ls -la",
    "working_directory": "/tmp",
    "timeout": 30
  }
}

Parameters:

  • command (required): Shell command to execute
  • working_directory (optional): Working directory for the command
  • timeout (optional): Timeout in seconds (default: 30)

Example commands:

  • "ls -la" - List files
  • "echo hello world" - Print text
  • "python --version" - Check Python version
  • "pwd" - Print working directory
  • "date" - Get current date

Testing

Test with curl:

# Health check (replace <remote-server-ip> with your server IP)
curl http://<remote-server-ip>:8000/health

# Root endpoint
curl http://<remote-server-ip>:8000/

Test MCP Tools (using HTTP directly):

The server uses SSE for MCP protocol, but you can test the basic endpoints.

Firewall Configuration

If accessing from outside your VPS, open port 8000:

# Ubuntu/Debian
sudo ufw allow 8000/tcp

# CentOS/RHEL
sudo firewall-cmd --add-port=8000/tcp --permanent
sudo firewall-cmd --reload

Development

Run Locally (without Docker):

# Install dependencies
pip install -r requirements.txt

# Run the server
python server.py

The server will be available at http://<remote-server-ip>:8000

Project Structure

mcp/
├── server.py          # HTTP/SSE MCP server (for remote use)
├── requirements.txt   # Python dependencies
├── Dockerfile         # Docker image definition
├── docker-compose.yml # Docker compose configuration
└── README.md          # This file

Troubleshooting

  1. Container won't start: Check logs with docker compose logs mcp-server

  2. Port already in use: Change port in docker-compose.yml:

    ports:
      - "8001:8000"  # Use 8001 instead
    
  3. Can't connect from Cursor:

    • Verify firewall allows port 8000
    • Check that container is running: docker compose ps
    • Verify the URL is correct: http://<remote-server-ip>:8000/sse
  4. Connection refused:

    • Ensure the server is listening on 0.0.0.0 (it is by default)
    • Check VPS firewall rules

Security Notes

  • The server has CORS enabled for all origins (for testing)
  • For production, consider:
    • Restricting CORS origins
    • Adding authentication
    • Using HTTPS with a reverse proxy (nginx/traefik)
    • Restricting firewall access to trusted IPs

Useful Commands

# View logs
docker compose logs -f mcp-server

# Restart the server
docker compose restart mcp-server

# Stop the server
docker compose down

# Rebuild and restart
docker compose up -d --build

# Check container status
docker compose ps

No External Dependencies!

This server uses only:

  • Python standard library (datetime, math, json)
  • MCP SDK (for protocol)
  • FastAPI/Uvicorn (for HTTP server)

Logging

The server automatically logs all requests to a local text file (requests_log.txt) with comprehensive information including:

  • Client Information: IP address, User-Agent, headers, etc.
  • Request Details: Tool called, arguments, timestamps
  • Response Data: Full response content, success/failure status
  • Server Info: Request ID, server version, processing time

Log File Format

Each log entry includes:

  • Unique request ID
  • UTC timestamp
  • Complete request/response data in JSON format
  • Success/failure indicators

Viewing Logs

# View recent logs (on host machine)
tail -f logs/requests_log.txt

# Search for specific tool calls
grep "tool_name" logs/requests_log.txt

# Count total requests
grep "REQUEST LOG ENTRY" logs/requests_log.txt | wc -l

Note: The log file is automatically persisted on the host machine in the ./logs/ directory using Docker volumes. This means logs survive container restarts and can be accessed even after the container is stopped. The logs contain sensitive information - monitor them for security and debugging purposes.

No External Dependencies!

This server uses only:

  • Python standard library (datetime, math, json, random, os, sys, uuid)
  • MCP SDK (for protocol)
  • FastAPI/Uvicorn (for HTTP server)

No API keys, no credit cards, no external services required!

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选