Skip to main content
Glama
josh747jr

Doctor Appointment MCP Server

by josh747jr

医生预约 MCP 服务器

一个基于 Python 的 模型上下文协议(MCP)服务器,用于通过外部预约 REST API 管理医生预约。

该服务器将预约管理操作作为 MCP 工具公开,以便兼容 MCP 的 AI 代理或客户端可以创建、查找、检索、取消和重新安排预约。

功能简介

该服务器提供五个 MCP 工具:

工具

描述

create_appointment

创建新的医生预约。

find_appointments

按患者姓名、医生姓名和/或预约日期查找预约。

check_appointment_status

按预约 ID 检索预约详细信息和状态。

cancel_appointment

通过将状态更改为 cancelled 来取消预约。

reschedule_appointment

更改现有预约的日期和时间。

该服务器还包括:

  • 位于 /mcp 的可流式 HTTP MCP 端点

  • 位于 //health 的健康检查端点

  • 可选的自定义 HTTP 标头身份验证

  • 通过 APPOINTMENTS_API 配置的外部 REST API 后端

  • 使用 httpx 的异步 HTTP 请求

Related MCP server: MCP Appointment Booking Server

架构

AI Agent / MCP Client
          |
          | Model Context Protocol
          v
      /mcp endpoint
          |
          v
       Uvicorn
          |
          v
      Starlette
          |
          v
       FastMCP
          |
   +------+------+------+------+------+
   |      |      |      |      |
   v      v      v      v      v
 Create  Find   Check  Cancel Reschedule
   |      |      |      |      |
   +------+------+------+------+------+
                 |
                 v
            HTTPX Client
                 |
                 | REST API
                 v
        Appointment Backend
         (MockAPI by default)

项目结构

doctor-appointment-mcp/
├── server.py
├── requirements.txt
├── start.sh
├── run.sh
├── README.md
├── .gitignore
└── .gitattributes

系统要求

  • 建议使用 Python 3.11 或更高版本

  • pip

  • 一个预约 REST API 端点

Python 依赖项定义在 requirements.txt 中:

fastmcp>=3.0
uvicorn[standard]>=0.30
httpx>=0.27

本地设置

1. 克隆仓库

git clone https://github.com/josh747jr/doctor-appointment-mcp.git
cd doctor-appointment-mcp

2. 创建虚拟环境

Windows PowerShell:

python -m venv .venv
.\.venv\Scripts\Activate.ps1

Linux/macOS/WSL:

python3 -m venv .venv
source .venv/bin/activate

3. 安装依赖项

pip install -r requirements.txt

4. 配置预约 API

APPOINTMENTS_API 设置为存储预约记录的 REST 端点。

Windows PowerShell:

$env:APPOINTMENTS_API="https://YOUR-API-ENDPOINT/appointments"

Linux/macOS/WSL:

export APPOINTMENTS_API="https://YOUR-API-ENDPOINT/appointments"

如果未设置 APPOINTMENTS_API,当前的 server.py 将使用其配置的 MockAPI 端点。

请勿将 API 密钥、凭据或其他机密提交到仓库中。

在本地运行服务器

启动 Uvicorn:

python -m uvicorn server:app --host 127.0.0.1 --port 8000

MCP 端点将是:

http://127.0.0.1:8000/mcp

健康检查端点将是:

http://127.0.0.1:8000/health

成功的健康检查返回:

ok

MCP 工具

1. create_appointment

创建新的医生预约。

输入:

  • patient_name

  • doctor_name

  • appointment_date

  • appointment_time

  • reason — 可选

示例工具参数:

{
  "patient_name": "John Doe",
  "doctor_name": "Dr. Mike",
  "appointment_date": "2026-09-18",
  "appointment_time": "2:00 PM",
  "reason": "Annual physical"
}

新预约以 scheduled 状态存储。

示例用户请求:

Schedule an appointment for John Doe with Dr. Mike on September 18, 2026
at 2:00 PM for an annual physical.

2. find_appointments

在不知道预约 ID 时,查找一个或多个现有预约。

搜索输入:

  • patient_name — 可选

  • doctor_name — 可选

  • appointment_date — 可选

  • include_cancelled — 可选布尔值,默认为 false

必须至少提供 patient_namedoctor_nameappointment_date 中的一个。

查找患者的预约:

{
  "patient_name": "John Doe"
}

查找患者和医生的预约:

{
  "patient_name": "John Doe",
  "doctor_name": "Dr. Mike"
}

查找特定日期的预约:

{
  "appointment_date": "2026-09-18"
}

该工具将提供的搜索字段作为查询参数发送到预约 REST API,并返回匹配的预约记录。

成功的结果包括:

{
  "success": true,
  "message": "Found 1 matching appointment(s).",
  "count": 1,
  "appointments": [
    {
      "id": "12",
      "patientName": "John Doe",
      "doctorName": "Dr. Mike",
      "appointmentDate": "2026-09-18",
      "appointmentTime": "2:00 PM",
      "reason": "Annual physical",
      "status": "scheduled"
    }
  ]
}

如果没有匹配的记录,该工具将返回成功响应,其中 count 设置为 0appointments 数组为空。

示例用户请求:

Find my appointment with Dr. Mike.
What appointments does John Doe have?
Find John Doe's appointment on September 18, 2026.

3. check_appointment_status

按 ID 检索预约。

输入:

  • appointment_id

示例:

{
  "appointment_id": "12"
}

成功响应包括患者、医生、预约日期、预约时间、原因和状态。

示例用户请求:

What is the status of appointment 12?

4. cancel_appointment

取消现有预约。

输入:

  • appointment_id

示例:

{
  "appointment_id": "12"
}

取消操作不会删除预约记录。服务器会将其状态更改为:

cancelled

保留记录可保留预约历史记录。

示例用户请求:

Cancel appointment 12.

5. reschedule_appointment

更改现有预约的日期和时间。

输入:

  • appointment_id

  • new_appointment_date

  • new_appointment_time

示例:

{
  "appointment_id": "12",
  "new_appointment_date": "2026-09-21",
  "new_appointment_time": "10:00 AM"
}

当前实现无法重新安排已取消的预约。

示例用户请求:

Move appointment 12 to September 21, 2026 at 10:00 AM.

预约数据模型

REST 后端应存储类似于以下内容的记录:

{
  "id": "12",
  "patientName": "John Doe",
  "doctorName": "Dr. Mike",
  "appointmentDate": "2026-09-18",
  "appointmentTime": "2:00 PM",
  "reason": "Annual physical",
  "status": "scheduled"
}

服务器使用等效于以下内容的 REST 操作:

POST /appointments
GET  /appointments
GET  /appointments/{id}
PUT  /appointments/{id}

find_appointments 使用 GET /appointments 及查询参数,例如:

patientName
doctorName
appointmentDate

示例代理工作流

用户可能首先询问:

Find my appointment with Dr. Mike.

MCP 客户端可以调用:

find_appointments(patient_name="John Doe", doctor_name="Dr. Mike")

找到匹配的记录和预约 ID 后,用户可以这样说:

Move that appointment to September 21 at 10 AM.

然后 MCP 客户端可以调用:

reschedule_appointment(
    appointment_id="12",
    new_appointment_date="2026-09-21",
    new_appointment_time="10:00 AM"
)

这允许 AI 代理首先定位预约,而无需用户知道预约 ID。

可选的 MCP 标头身份验证

服务器支持通过 MCP_REQUEST_HEADERS 环境变量进行可选的自定义标头身份验证。

如果未配置该变量,则禁用自定义标头身份验证。

简单标头

Windows PowerShell:

$env:MCP_REQUEST_HEADERS="my-secret"

Linux/macOS/WSL:

export MCP_REQUEST_HEADERS="my-secret"

此配置要求 MCP 请求包含一个名为以下内容的消息头:

MCP_REQUEST_HEADERS

以及配置的值。

自定义标头名称

该变量还可以包含 JSON:

export MCP_REQUEST_HEADERS='{"X-API-Key":"my-secret"}'

然后 MCP 客户端必须发送:

X-API-Key: my-secret

在不使用此自定义身份验证的情况下,//health 端点仍然可用。

安全说明: 此项目是演示/学习实现。在存储真实患者信息之前,真实的医疗保健应用程序需要更强大的身份验证、授权、隐私控制、审计日志记录、机密管理、数据保护和法规审查。

部署

该仓库包含:

start.sh
run.sh

这些脚本可用于基于 Linux 的部署。

start.sh 将所需的 Python 包安装到部署依赖目录中。

run.sh 使用 Uvicorn 启动应用程序,并监听 PORT 环境变量,默认为 8080 端口。

必需的部署环境变量:

APPOINTMENTS_API=https://YOUR-API-ENDPOINT/appointments

可选的身份验证:

MCP_REQUEST_HEADERS=your-secret

部署后,MCP 端点通常是:

https://YOUR-SERVER/mcp

以及健康检查端点:

https://YOUR-SERVER/health

测试服务器

启动应用程序:

python -m uvicorn server:app --host 127.0.0.1 --port 8000

测试健康检查端点:

curl http://127.0.0.1:8000/health

预期响应:

ok

然后配置兼容 MCP 的客户端以连接到:

http://127.0.0.1:8000/mcp

客户端应发现以下五个工具:

create_appointment
find_appointments
check_appointment_status
cancel_appointment
reschedule_appointment

计划改进

有用的后续步骤包括:

  • 添加医生可用性和时间段查询

  • 防止冲突或重复预约

  • 添加更强大的日期和时间验证

  • 添加生产数据库

  • 添加 OAuth 或其他生产级身份验证机制

  • 添加自动化测试

  • 添加结构化审计日志记录

  • 与真实的日历或调度提供商集成

  • 添加生产级患者身份和授权控制

开发状态

此项目旨在作为 MCP 开发和学习的项目。当前的预约后端可以在保留面向 MCP 的工具接口的同时,替换为生产级调度服务或数据库。

安全与医疗数据

请勿将真实患者信息或受保护的健康信息 (PHI) 用于不安全的演示后端。

生产级医疗保健应用程序可能需遵守隐私、安全、合规和数据保留要求,例如美国的 HIPAA。

仓库

https://github.com/josh747jr/doctor-appointment-mcp

许可证

此仓库尚未指定许可证。在以特定许可条款分发或重用项目之前,请添加 LICENSE 文件。

F
license - not found
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that enables interaction with OnSched's consumer-facing appointment scheduling API through natural language, allowing users to manage bookings, appointments, and scheduling operations.
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server that enables users to book, cancel, reschedule, and list appointments through natural language interactions. It uses YAML configurations for agent behavior and function logic to manage appointment data and availability.
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables users to manage medical appointments by searching for doctors, checking availability, and booking sessions through a natural language interface. It serves as a reference implementation for advanced MCP features like symptom-based specialist recommendations and multi-step scheduling workflows.
    15
    MIT
  • F
    license
    Not graded
    quality
    C
    maintenance
    Simulates a third-party appointment booking agent, enabling your AI platform to check availability and book appointments via MCP interoperability.

View all related MCP servers

Related MCP Connectors

  • Hosted Google Calendar MCP server for AI agents. No self-hosting or Google Cloud setup.

  • Self-hosted MCP gateway: turn any API, database or MCP server into AI connectors — no code.

  • An AI concierge that turns static forms into adaptive AI conversations. From any MCP client.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/josh747jr/doctor-appointment-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server