Senechal MCP Server

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Supports environment variable configuration through .env files for storing API keys and base URLs required to connect to the Senechal health data API.

  • Uses Python for implementing the server, with specific instructions for creating virtual environments and running the server through Python commands.

Senechal MCP 服务器

模型上下文协议 (MCP) 服务器作为 Senechal 项目的配套服务器,将 Senechal API 的健康数据提供给 LLM 应用程序。

概述

该服务器为 LLM 提供了一个标准化接口,用于从 Senechal API 访问健康数据。它公开:

  • 资源:可以加载到 LLM 上下文中的健康数据
  • 工具:LLM 可以调用以获取健康数据的函数
  • 提示:用于分析健康数据的可重复使用模板

安装

  1. 克隆此存储库
  2. 创建虚拟环境:
    python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
  3. 安装依赖项:
    pip install -r requirements.txt

配置

.env.example文件复制到.env并添加您的 Senechal API 密钥和 URL:

# Required: Senechal API Key SENECHAL_API_KEY=your_api_key_here # Required: API base URL SENECHAL_API_BASE_URL=https://your-api-host/api/senechal

服务器要运行,就需要 API 密钥和 API URL。

Windows 配置

在 Windows 上运行时,请确保:

  1. 在配置中使用反斜杠或正确转义的路径
  2. 在 claude-desktop-config.json 中使用 Python 虚拟环境的完整路径:
{ "mcpServers": { "senechal-health": { "command": "C:\\path\\to\\venv\\Scripts\\python.exe", "args": [ "C:\\path\\to\\senechal_mcp_server.py" ], "env": { "SENECHAL_API_KEY": "your_api_key_here" } } } }

请注意,MCP 配置中的环境变量不使用.env文件,因此您需要在配置中明确设置它们。

用法

测试客户端/服务器设置

测试设置的最简单方法是运行示例客户端:

# In one terminal, start the server python senechal_mcp_server.py # In another terminal, run the example client python example_client.py

启动服务器

python senechal_mcp_server.py

使用 MCP Inspector 的开发模式

mcp dev senechal_mcp_server.py

在 Claude Desktop 中安装

该服务器包含 Claude Desktop 的配置文件:

mcp install senechal_mcp_server.py

然后,您可以从 Claude Desktop 的工具菜单中选择“Senechal Health”。

可用资源

  • senechal://health/summary/{period} - 获取每日、每周、每月或每年的健康摘要
    • 例如: senechal://health/summary/day?span=7&metrics=all
    • 参数:
      • period :日、周、月、年
      • span :周期数(默认值:1)
      • metrics :逗号分隔列表或“全部”(默认)
      • offset :从现在开始偏移的周期数(默认值:0)
  • senechal://health/profile - 获取用户的健康档案
    • 包含人口统计数据、药物、补充剂
  • senechal://health/current - 获取当前健康测量数据
    • 例如: senechal://health/current?types=1,2,3
    • 参数:
      • types :可选的以逗号分隔的测量类型 ID 列表
  • senechal://health/trends - 获取随时间推移的健康趋势
    • 例如: senechal://health/trends?days=30&types=1,2,3&interval=day
    • 参数:
      • days :分析的天数(默认值:30)
      • types :可选的以逗号分隔的测量类型 ID 列表
      • interval :分组间隔 - 天、周、月(默认值:天)
  • senechal://health/stats - 获取健康指标的统计分析
    • 例如: senechal://health/stats?days=30&types=1,2,3
    • 参数:
      • days :分析周期(天数)(默认值:30)
      • types :可选的以逗号分隔的测量类型 ID 列表

可用工具

  • fetch_health_summary - 获取特定时期的健康摘要
    • 参数:
      • period (必填):日、周、月、年
      • metrics (可选):逗号分隔的指标或“全部”(默认)
      • span (可选):返回的周期数(默认值:1)
      • offset (可选):偏移的周期数(默认值:0)
  • fetch_health_profile - 获取用户的健康资料
    • 无需参数
  • fetch_current_health - 获取最新的健康测量数据
    • 参数:
      • types (可选):要过滤的测量类型 ID 列表
  • fetch_health_trends - 获取健康趋势数据
    • 参数:
      • days (可选):分析的天数(默认值:30)
      • types (可选):要过滤的测量类型 ID 列表
      • interval (可选):分组间隔 - 天、周、月(默认值:天)
  • fetch_health_stats - 获取健康指标的统计分析
    • 参数:
      • days (可选):分析期(天)(默认值:30)
      • types (可选):要过滤的测量类型 ID 列表

可用提示

  • analyze_health_summary - 提示分析健康摘要
    • 提供用于识别异常指标、趋势和建议行动的模板
    • 旨在与senechal://health/summary/day?span=7数据一起使用
  • compare_health_trends - 提示比较不同时间段的健康趋势
    • 提供用于比较不同时间范围(7、30、90 天)趋势的模板
    • 旨在与健康趋势端点的数据一起使用

交互示例

正在加载健康摘要数据

# In an LLM application, load a week of health summaries content, mime_type = await session.read_resource("senechal://health/summary/day?span=7")

调用健康数据工具

# In an LLM conversation result = await session.call_tool( "fetch_health_trends", arguments={ "days": 30, "interval": "day" } ) # More complex example combining tools and resources profile = await session.call_tool("fetch_health_profile") trends = await session.call_tool( "fetch_health_trends", arguments={"days": 90, "interval": "week"} )

使用健康分析提示

# Get a prompt for analyzing health data prompt_result = await session.get_prompt("analyze_health_summary") for message in prompt_result.messages: print(f"[{message.role}]: {message.content.text}")

请参阅example_client.py文件以获取完整的工作示例。

API 端点

Senechal MCP 服务器与以下 Senechal API 端点通信:

  • /health/summary/{period} - 获取健康摘要
  • /health/profile - 获取健康状况
  • /health/current – 获取当前测量值
  • /health/trends - 获取健康趋势
  • /health/stats - 获取健康统计数据
-
security - not tested
A
license - permissive license
-
quality - not tested

模型上下文协议服务器将 Senechal API 中的健康数据提供给 LLM 应用程序,使 AI 助手能够访问、分析和响应个人健康信息。

  1. Overview
    1. Installation
      1. Configuration
        1. Windows Configuration
      2. Usage
        1. Testing the Client/Server Setup
        2. Start the Server
        3. Development Mode with MCP Inspector
        4. Install in Claude Desktop
      3. Available Resources
        1. Available Tools
          1. Available Prompts
            1. Example Interactions
              1. Loading Health Summary Data
              2. Calling Health Data Tools
              3. Using Health Analysis Prompts
            2. API Endpoints
              ID: u1e97fslpi