MCP Medical Appointments Demo

MCP Medical Appointments Demo

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.

Category
访问服务器

README

MCP Medical Appointments Demo

A working reference for the Model Context Protocol — tools, resources, prompts, elicitation, sampling, and completion — built around a medical appointment scheduling domain.

Built with TypeScript, Hono, MCP SDK, and Zod.

Table of Contents

Features

MCP Server Primitives

Primitive Name Description
Tool search_doctors Search doctors by name or specialty
Tool get_available_slots Get available time slots for a doctor on a date
Tool book_appointment Book an appointment (uses elicitation for confirmation)
Tool cancel_appointment Cancel an appointment (uses elicitation for confirmation)
Tool list_appointments List appointments with filters
Tool recommend_specialist Symptom-based specialist recommendation (uses sampling)
Resource specialties://list Static list of all medical specialties
Resource doctor://{doctorId}/profile Dynamic doctor profile with template
Resource patient://{patientId}/summary Patient info + appointment history
Resource appointment://{appointmentId} Full appointment details
Prompt schedule-appointment Guided appointment scheduling workflow (with completion)
Prompt patient-history Patient history review (with completion)
Prompt triage-symptoms Symptom triage and specialist recommendation

MCP Client Features

Feature How It's Used
Elicitation book_appointment and cancel_appointment ask the user to confirm before proceeding
Sampling recommend_specialist uses LLM sampling to match symptoms to specialties
Roots Server registers a root for the medical appointments workspace
Completion Prompts use completable() for auto-completing specialty names and patient IDs

Quick Start

Prerequisites

  • Node.js >= 22.0.0
  • VS Code with GitHub Copilot (for MCP integration)

1. Install and start the REST API

npm install
npm run dev:service

You should see:

Bootstrapped: 8 specialties, 12 doctors, 5 patients
Medical Appointment Service running on http://localhost:3000

2. Connect the MCP Server in VS Code

The .vscode/mcp.json file is already configured. VS Code will automatically detect and offer to start the MCP server. Alternatively, run it manually:

npm run dev:mcp

3. Try it out

In VS Code's Copilot Chat (Agent mode), try:

  • "Search for cardiologists"
  • "What slots does Dr. Sarah Chen have available next Monday?"
  • "Book an appointment with doc-3 for patient pat-1"
  • "Show me Alice Johnson's appointment history"
  • "I've been having severe headaches and dizziness — what specialist should I see?"

Or use the prompts from the prompt picker:

  • Schedule Appointment — guided scheduling workflow
  • Patient History — review a patient's visits
  • Triage Symptoms — symptom-based specialist matching

Architecture

┌─────────────────┐     stdio      ┌───────────────────┐     HTTP      ┌──────────────────┐
│   VS Code /     │◄──────────────►│   MCP Server      │─────────────►│  Hono REST API   │
│   MCP Client    │                │   (TypeScript)    │  localhost    │  (localhost:3000) │
└─────────────────┘                └───────────────────┘              └──────────────────┘
                                     Tools, Resources,                  In-memory store
                                     Prompts                            + JSON bootstrap

The project uses a two-process design:

  1. Hono REST API — HTTP service with an in-memory data store, bootstrapped from JSON seed files in data/.
  2. MCP Server — Connects via stdio and exposes the REST API through MCP primitives (tools, resources, prompts).

The MCP server never touches the data store directly — it calls the REST API through an HTTP client, keeping the two layers cleanly separated.

REST API Endpoints

Method Endpoint Description
GET /api/specialties List all specialties
GET /api/specialties/:id Get specialty by ID
GET /api/doctors List doctors (filters: ?specialtyId=, ?name=)
GET /api/doctors/:id Get doctor by ID
GET /api/doctors/:id/slots?date=YYYY-MM-DD Get available slots
GET /api/patients List all patients
GET /api/patients/:id Get patient by ID
POST /api/patients Create a patient
GET /api/appointments List appointments (filters: ?patientId=, ?doctorId=, ?status=, ?date=)
GET /api/appointments/:id Get appointment by ID
POST /api/appointments Book an appointment
PATCH /api/appointments/:id/cancel Cancel an appointment
PATCH /api/appointments/:id/complete Complete an appointment

Project Structure

mcp-demo/
├── data/
│   ├── specialties.json      # 8 medical specialties
│   ├── doctors.json           # 12 doctors across specialties
│   └── patients.json          # 5 sample patients
├── src/
│   ├── types.ts               # Shared domain types
│   ├── service/
│   │   ├── store.ts           # In-memory data store
│   │   ├── app.ts             # Hono app composition
│   │   ├── main.ts            # Service entry point
│   │   └── routes/            # REST route handlers
│   └── mcp/
│       ├── api-client.ts      # HTTP client for the REST API
│       ├── tools.ts           # MCP tool registrations
│       ├── resources.ts       # MCP resource registrations
│       ├── prompts.ts         # MCP prompt registrations
│       └── server.ts          # MCP server entry point
├── .vscode/
│   └── mcp.json               # VS Code MCP server config
├── package.json
└── tsconfig.json

Scripts

Command Description
npm run dev:service Start the Hono REST API with hot reload
npm run dev:mcp Start MCP server in stdio mode
npm run build Compile TypeScript to dist/
npm run typecheck Type-check without emitting files

Domain Model

Entity Description
Specialty Medical specialty (Cardiology, Dermatology, etc.)
Doctor Has a specialty, available days, working hours, and slot duration
Patient Name, email, phone, date of birth
Appointment Links a patient to a doctor at a specific date/time with a reason and status
TimeSlot Available or booked time window for a doctor on a given day

Configuration

The REST API listens on port 3000 by default. The MCP server communicates with the API over http://localhost:3000 and connects to VS Code via stdio.

Seed data (specialties, doctors, patients) is loaded from the data/ directory on startup. Edit those JSON files to customize the demo dataset.

Contributing

Contributions are welcome. Fork the repo, create a feature branch, and open a pull request.

License

MIT

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选