FastMCP

by ryuichi1208
  • Linux
  • Apple

Integrations

  • Allows configuration of the server through .env files, enabling storage of sensitive information like API keys outside of the codebase.

  • Provides metrics and monitoring integration, sending data about context operations (creation, updates, deletions, access), query executions, and server events to Datadog for observability and performance tracking.

FastMCP——模型上下文协议服务器

使用 FastMCP 实现的轻量级模型上下文协议 (MCP) 服务器, FastMCP是一个用于构建 MCP 服务器和客户端的快速 Pythonic 框架。

特征

  • 创建、检索、更新和删除模型上下文
  • 针对特定上下文执行查询
  • 按模型名称和标签过滤
  • 内存存储(用于开发)
  • FastMCP 集成,轻松实现 MCP 服务器开发
  • 用于指标和监控的 Datadog 集成

要求

  • Python 3.7+
  • FastMCP
  • uv(推荐用于环境管理)
  • Datadog 帐户(可选,用于指标)

安装

使用 uv(推荐)

最简单的安装方法是使用提供的脚本:

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
视窗
# Clone the repository git clone https://github.com/yourusername/datadog-mcp-server.git cd datadog-mcp-server # Run the installer .\install.ps1

手动安装

# 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 配置

该服务器与 Datadog 集成,用于指标和监控。您可以通过多种方式配置 Datadog API 凭据:

1.环境变量

启动服务器之前设置这些环境变量:

# 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 文件

在项目目录中创建.env文件:

DATADOG_API_KEY=your_api_key DATADOG_APP_KEY=your_app_key DATADOG_SITE=datadoghq.com

3. FastMCP CLI 安装

当作为 Claude Desktop 工具安装时,您可以传递环境变量:

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

4.运行时配置

在运行时使用configure_datadog工具:

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

用法

启动服务器

# 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

安装为 Claude 桌面工具

# 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

使用工具

该服务器提供以下工具:

  • create_context创建一个新的上下文
  • get_context - 检索特定上下文
  • update_context - 更新现有上下文
  • delete_context - 删除上下文
  • list_contexts - 列出所有上下文(带有可选过滤)
  • query_model - 针对特定上下文执行查询
  • health_check - 服务器健康检查
  • configure_datadog - 在运行时配置 Datadog 集成

示例请求

创建上下文

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

执行查询

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

配置 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 指标

服务器向 Datadog 报告以下指标:

  • mcp.contexts.created - 上下文创建事件
  • mcp.contexts.updated - 上下文更新事件
  • mcp.contexts.deleted - 上下文删除事件
  • mcp.contexts.accessed - 上下文访问事件
  • mcp.contexts.total - 上下文总数
  • mcp.contexts.listed - 列出上下文操作事件
  • mcp.queries.executed - 查询执行事件
  • mcp.server.startup - 服务器启动事件
  • mcp.server.shutdown - 服务器关闭事件

发展

请参阅包含的mcp_example.py以获取客户端实现示例:

# Run the example client (with activated environment) python mcp_example.py # Run with uv (no activation needed) uv run python mcp_example.py

执照

麻省理工学院

资源

Related MCP Servers

  • -
    security
    F
    license
    -
    quality
    A Model Context Protocol server built with mcp-framework that allows users to create and manage custom tools for processing data, integrating with the Claude Desktop via CLI.
    Last updated -
    48
    4
    TypeScript
    • Apple
  • -
    security
    A
    license
    -
    quality
    A Model Context Protocol server that provides file system operations, analysis, and manipulation capabilities through a standardized tool interface.
    Last updated -
    1
    TypeScript
    MIT License
  • -
    security
    F
    license
    -
    quality
    A Model Context Protocol server that provides a comprehensive interface for interacting with the ConnectWise Manage API, simplifying API discovery, execution, and management for both developers and AI assistants.
    Last updated -
    46
    2
    Python
    • Linux
    • Apple
  • -
    security
    A
    license
    -
    quality
    A Model Context Protocol server for data wrangling that provides standardized interfaces for data preprocessing, transformation, and analysis tasks including data aggregation and descriptive statistics.
    Last updated -
    1
    Python
    MIT License
    • Linux
    • Apple

View all related MCP servers

ID: qhguasjdci