Sponsored by Deepsite.site

FastMCP - Model Context Protocol Server

Created By
ryuichi12089 months ago
Content

FastMCP - Model Context Protocol Server

A lightweight Model Context Protocol (MCP) server implemented with FastMCP, a fast and Pythonic framework for building MCP servers and clients.

Features

  • Create, retrieve, update, and delete model contexts
  • Query execution against specific contexts
  • Filtering by model name and tags
  • In-memory storage (for development)
  • FastMCP integration for easy MCP server development
  • Datadog integration for metrics and monitoring

Requirements

  • Python 3.7+
  • FastMCP
  • uv (recommended for environment management)
  • Datadog account (optional, for metrics)

Installation

The simplest way to install is using the provided scripts:

Unix/Linux/macOS

# Clone the repository
git clone https://github.com/yourusername/datadog-mcp-server.git
cd datadog-mcp-server

# Make the install script executable
chmod +x install.sh

# Run the installer
./install.sh

Windows

# Clone the repository
git clone https://github.com/yourusername/datadog-mcp-server.git
cd datadog-mcp-server

# Run the installer
.\install.ps1

Manual Installation

# Clone the repository
git clone https://github.com/yourusername/datadog-mcp-server.git
cd datadog-mcp-server

# Create and activate a virtual environment with uv
uv venv
# On Unix/Linux/macOS:
source .venv/bin/activate
# On Windows:
.\.venv\Scripts\activate

# Install dependencies
uv pip install -r requirements.txt

Datadog Configuration

The server integrates with Datadog for metrics and monitoring. You can configure Datadog API credentials in several ways:

1. Environment Variables

Set these environment variables before starting the server:

# Unix/Linux/macOS
export DATADOG_API_KEY=your_api_key
export DATADOG_APP_KEY=your_app_key  # Optional
export DATADOG_SITE=datadoghq.com    # Optional, default: datadoghq.com

# Windows PowerShell
$env:DATADOG_API_KEY = 'your_api_key'
$env:DATADOG_APP_KEY = 'your_app_key'  # Optional
$env:DATADOG_SITE = 'datadoghq.com'    # Optional

2. .env File

Create a .env file in the project directory:

DATADOG_API_KEY=your_api_key
DATADOG_APP_KEY=your_app_key
DATADOG_SITE=datadoghq.com

3. FastMCP CLI Installation

When installing as a Claude Desktop tool, you can pass environment variables:

fastmcp install mcp_server.py --name "Model Context Server" -v DATADOG_API_KEY=your_api_key

4. Runtime Configuration

Use the configure_datadog tool at runtime:

result = await client.call_tool("configure_datadog", {
    "api_key": "your_api_key",
    "app_key": "your_app_key",  # Optional
    "site": "datadoghq.com"     # Optional
})

Usage

Starting the Server

# Start directly from activated environment
python mcp_server.py

# Or use uv run (no activation needed)
uv run python mcp_server.py

# Use FastMCP CLI for development (if in activated environment)
fastmcp dev mcp_server.py

# Use FastMCP CLI with uv (no activation needed)
uv run -m fastmcp dev mcp_server.py

Installing as a Claude Desktop Tool

# From activated environment
fastmcp install mcp_server.py --name "Model Context Server"

# Using uv directly
uv run python -m fastmcp install mcp_server.py --name "Model Context Server"

# With Datadog API key
fastmcp install mcp_server.py --name "Model Context Server" -v DATADOG_API_KEY=your_api_key

Using the Tools

The server provides the following tools:

  • create_context - Create a new context
  • get_context - Retrieve a specific context
  • update_context - Update an existing context
  • delete_context - Delete a context
  • list_contexts - List all contexts (with optional filtering)
  • query_model - Execute a query against a specific context
  • health_check - Server health check
  • configure_datadog - Configure Datadog integration at runtime

Example Requests

Creating a Context

result = await client.call_tool("create_context", {
    "context_id": "model-123",
    "model_name": "gpt-3.5",
    "data": {
        "parameters": {
            "temperature": 0.7
        }
    },
    "tags": ["production", "nlp"]
})

Executing a Query

result = await client.call_tool("query_model", {
    "context_id": "model-123",
    "query_data": {
        "prompt": "Hello, world!"
    }
})

Configuring Datadog

result = await client.call_tool("configure_datadog", {
    "api_key": "your_datadog_api_key",
    "app_key": "your_datadog_app_key",  # Optional
    "site": "datadoghq.com"             # Optional
})

Datadog Metrics

The server reports the following metrics to Datadog:

  • mcp.contexts.created - Context creation events
  • mcp.contexts.updated - Context update events
  • mcp.contexts.deleted - Context deletion events
  • mcp.contexts.accessed - Context access events
  • mcp.contexts.total - Total number of contexts
  • mcp.contexts.listed - List contexts operation events
  • mcp.queries.executed - Query execution events
  • mcp.server.startup - Server startup events
  • mcp.server.shutdown - Server shutdown events

Development

See the included mcp_example.py for a client implementation example:

# Run the example client (with activated environment)
python mcp_example.py

# Run with uv (no activation needed)
uv run python mcp_example.py

License

MIT

Resources

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Playwright McpPlaywright MCP server
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.
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.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Serper MCP ServerA Serper MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
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"
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
WindsurfThe new purpose-built IDE to harness magic
DeepChatYour AI Partner on Desktop
CursorThe AI Code Editor
Tavily Mcp
Amap Maps高德地图官方 MCP Server
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.
ChatWiseThe second fastest AI chatbot™
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code