Content
# Tool List
> Real-time Emergency Medical Matching MCP Server — Based on National Medical Center (NEMC) Emergency Medical Information API
[](https://modelcontextprotocol.io)
[](LICENSE)
[](https://www.typescriptlang.org/)
[]()
[](https://emergency-mcp.fly.dev/health)
> ⚠️ **Experimental Release**
>
> This tool is an **experimental project for decision support**. Do not use it as the sole basis for making actual emergency patient transport decisions. Matching results depend on the data quality of NEMC's integrated situation board, and there may be false positives/negatives due to parsing limitations of freely inputted text messages by hospitals.
>
> Use it only as a **reference material** to assist the judgment of 119 situation rooms and medical personnel, and report any issues found to [GitHub Issues](https://github.com/gongdly/Emergency_MCP/issues). This is a beta project for collaborative improvement.
An MCP server that helps find **"an emergency room that can accept this patient now"** in natural language. It integrates real-time available beds, equipment availability, and acceptance information for 28 severe diseases from NEMC's integrated situation board into a single matching engine.
## Why We Created This
A long-standing issue in Korea's emergency medical system is the so-called **"emergency room roundabout"** where patients cannot find an accepting hospital and miss the golden hour. While 119 situation rooms and emergency responders can check hospital information through the integrated situation board, there is a lack of tools that can automatically match hospitals in real-time based on patients' specific conditions (age, weight, gestational age, required treatment).
This MCP automatically matches possible emergency rooms within seconds by contrasting patient conditions with hospital capabilities. If no candidates are found in the primary region, it automatically expands the search to adjacent metropolitan cities. Matching failure reasons (unavailable/ information not provided/ conditions not met) are also displayed to visualize data gaps.
> **v0.2 Verification Note**: We tested various scenarios (preterm birth, acute myocardial infarction, stroke, severe burns, trauma center) using the actual NEMC API to verify the matching logic and message parser. We focused on accurately interpreting freely inputted text formats (e.g., `1500g or more, 30 weeks or more`, `34W 2Kg or more`) and matching them with patient conditions. See [CHANGELOG.md](CHANGELOG.md) for details.
## Key Features
- **Accurate Matching**: Utilizes 70+ fields (`hv*`, `MKioskTy*`) from NEMC API as per the usage guide specifications
- **Message Parsing**: Parses freely inputted text restrictions (gestational age, weight, age) using regular expressions and automatically matches them with patient conditions (supports Korean and English units)
- **Automatic Expansion**: If no matches are found in the primary region, automatically expands to adjacent metropolitan cities → adjacent regions
- **Freshness Display**: Displays elapsed time in minutes based on `hvidate` criteria
- **Error Tracking**: Specifies API call failures that occur during automatic expansion in the results (no silencing)
- **STDIO + HTTP**: Supports both local Claude Desktop and remote deployment (fly.io, Docker) with a single codebase
- **Stateless HTTP**: Creates a new server instance for each request without session management, allowing for simple operation and horizontal scaling
## Provided Tools
### `find_emergency_room`
Matches emergency rooms based on patient conditions and required capabilities.
**Input**:
- `stage1` (required): Metropolitan city (e.g., `"대구광역시"`)
- `stage2`: City or county (optional)
- `categories`: Array of required severe disease acceptance categories. Choose one or more out of 28 categories
- e.g., `["nicu_preemie", "obgyn_delivery", "obgyn_surgery"]` — preterm birth
- e.g., `["mi_reperfusion"]` — acute myocardial infarction
- e.g., `["stroke_reperfusion", "sah_surgery"]` — stroke
- `required_beds`: Required bed field name and minimum count (e.g., `{"hv42": 1}` = 1 delivery room)
- `required_equipment`: Required equipment (`ct`, `mri`, `ecmo`, `incubator`, `ventilator_neonatal`, etc.)
- `gestational_weeks`: Gestational age for pregnant women (for low birth weight baby restrictions)
- `birth_weight_grams`: Newborn birth weight
- `patient_lat`, `patient_lng`: Patient location (for distance calculation)
- `max_radius_km`: Maximum search radius
- `auto_expand`: Automatically expand search to adjacent regions if no matches are found (default `true`)
- `max_results`: Number of returned results (default 10)
**Output**: List of matched hospitals, each hospital's real-time status, distance, and reasons for satisfaction/non-satisfaction
### `get_hospital_detail`
Queries detailed information about a specific emergency medical institution.
**Input**:
- `hpid` (required): Emergency medical institution code (e.g., `"A1300002"` = Kyungpook National University Hospital)
**Output**: Address, contact information, real-time available beds, equipment availability, acceptance status for 28 diseases, and restrictions
## Quick Start — Remote Endpoint (no installation required) 🌐
You can register the public endpoint to your MCP client without any installation. **No Node.js installation, build, or git clone is required**.
**Claude Desktop configuration** (`claude_desktop_config.json`):
```json
{
"mcpServers": {
"emergency-mcp": {
"url": "https://emergency-mcp.fly.dev/mcp",
"headers": {
"x-nemc-api-key": "Enter your NEMC API key here"
}
}
}
}
```
> ⚠️ **User-specific key policy**: This remote endpoint **does not share the operator's NEMC key**. Each user must provide their own API key issued in their name from the [Public Data Portal](https://www.data.go.kr/data/15000563/openapi.do) in the `x-nemc-api-key` header. This policy is for (1) usage tracking and responsibility separation, (2) fair distribution of daily quotas (1,000 requests/day for development accounts), and (3) security.
**Key issuance method** (takes 5 minutes, automatic approval):
1. Access [Public Data Portal](https://www.data.go.kr/data/15000563/openapi.do) → Sign up/login
2. Click "Application for use" → Briefly describe the purpose of use → Apply
3. My page → Open API → Copy the issued **general authentication key (Decoding)**
4. Paste it into the configuration file where it says `Enter your NEMC API key here`
**Server status check**:
- Health check: https://emergency-mcp.fly.dev/health
- MCP endpoint: https://emergency-mcp.fly.dev/mcp
**If the server does not respond**: The free tier on fly.io enters sleep mode if there is no traffic. It may take 5-10 seconds for cold start on the first request. The server responds immediately from the second request onwards.
## Local Installation (self-operation)
If you want to run it directly on your computer:
### Prerequisites
- **Node.js 18+**
- **NEMC API key** (issued in the same way as above)
### Installation + Build
```bash
git clone https://github.com/gongdly/Emergency_MCP.git
cd Emergency_MCP
npm install
npm run build
```
### Claude Desktop configuration (local STDIO)
```json
{
"mcpServers": {
"emergency-mcp": {
"command": "node",
"args": ["C:\\absolute\\path\\Emergency_MCP\\dist\\index.js"],
"env": {
"NEMC_API_KEY": "Enter your NEMC API key here"
}
}
}
}
```
| Client | Configuration file path |
| --- | --- |
| Claude Desktop (macOS) | `~/Library/Application Support/Claude/claude_desktop_config.json` |
| Claude Desktop (Windows) | `%APPDATA%\Claude\claude_desktop_config.json` |
| Cursor | `.cursor/mcp.json` |
| Continue | `~/.continue/config.json` |
Restart the client after saving the configuration.
## Example Usage
Invocation in natural language on Claude Desktop:
```
User: "There's a 28-week preterm pregnant woman in OO region. NICU and delivery room are needed.
Find an accepting emergency room."
Claude: (find_emergency_room call)
stage1: "OO광역시"
stage2: "OO-gu"
categories: ["nicu_preemie", "obgyn_delivery", "obgyn_surgery"]
required_beds: { "hv42": 1 } # delivery room
gestational_weeks: 28
auto_expand: true
→ Primary region search → Automatic expansion to adjacent metropolitan cities if no matches are found
→ "1st priority: ○○ Hospital (XXkm, emergency room ☎ XXX-XXXX)..."
```
```
User: "Provide detailed information about A1300002 hospital."
Claude: (get_hospital_detail call)
→ Returns real-time available beds, equipment, and acceptance status of the hospital
```
## Docker / Self-deployment
```bash
docker build -t emergency-mcp .
docker run -e NEMC_API_KEY=your_key -p 3000:3000 emergency-mcp
```
MCP endpoint: `http://localhost:3000/mcp`
### fly.io deployment
```bash
fly apps create emergency-mcp-yourname
# Modify app name in fly.toml
fly deploy
```
Register `https://emergency-mcp-yourname.fly.dev/mcp` to your MCP client after deployment.
## Environment Variables
| Variable | Required | Default value | Description |
| --- | --- | --- | --- |
| `NEMC_API_KEY` | Required for local operation ◯ | - | NEMC Emergency Medical Information API key. Replaced by header (`x-nemc-api-key`) for remote deployment |
| `PORT` | ✕ | `3000` | HTTP server port |
| `CORS_ORIGIN` | ✕ | `*` | CORS allowed origin |
| `RATE_LIMIT_RPM` | ✕ | `60` | Request limit per minute per IP (0 = disabled) |
| `MCP_HTTP` | ✕ | - | If set to `1`, runs in HTTP mode (using Dockerfile) |
## Data Source
This tool uses only the **National Medical Center Emergency Medical Information Inquiry Service** public data API.
- **Real-time available bed information for emergency rooms** — Real-time bed and equipment availability status with 70+ fields
- **Information on acceptance of severe disease patients** — Real-time acceptance status for 28 severe diseases + age and weight restrictions
- **Basic information on emergency medical institutions** — Address, coordinates, contact information, medical subjects, and static facility possession status
The responses from the three APIs are joined by `hpid` (emergency medical institution code) and normalized into a single `HospitalSnapshot` for matching.
## Precautions
- **Medical decision support**: The output of this tool is a **reference material** for final transport decisions and does not replace legal responsibility. Actual transport decisions should be made by 119 situation rooms and medical personnel.
- **Data freshness**: The NEMC API relies on data directly input by hospitals. While the `hvidate` field indicates the last input time, there may be differences from actual on-site situations.
- **Free text parsing limitations**: Hospital restriction messages do not follow a standardized format. This tool parses general patterns (gestational age, weight, kg/g units) using regular expressions but may not perfectly handle all expressions. Verify suspicious matches directly with the hospital.
- **API traffic limit**: The public data portal development account has a daily limit of 1,000 requests. If you need to expand traffic, apply for traffic increase after registering your usage case.
## License
MIT — Refer to [LICENSE](LICENSE)
## Acknowledgments
- [National Medical Center](https://www.nmc.or.kr) Central Emergency Medical Center Emergency Medical Information Public API
- [Model Context Protocol](https://modelcontextprotocol.io) — Anthropic
- Design inspiration: [korean-law-mcp](https://github.com/chrisryugj/korean-law-mcp) (STDIO + remote HTTP dual transport pattern)
## Contribution
We welcome issue reports, bug reports, and suggestions for new matching scenarios. Please leave them on [GitHub Issues](https://github.com/gongdly/Emergency_MCP/issues).
MCP Config
Below is the configuration for this MCP Server. You can copy it directly to Cursor or other MCP clients.
mcp.json
Connection Info
You Might Also Like
ScienceClaw
🔬🦞 A self-evolving AI research colleague for scientists. 285 skills, 25+...
ScienceClaw
ScienceClaw is a personal research assistant built with LangChain DeepAgents...
garmin-connect-mcp
MCP server for Garmin Connect — access 61 health, fitness and activity tools...
buddy
Your persistent AI coding companion — the /buddy rescue mission. A...
Vera
Local code search combining BM25, vector similarity, and cross-encoder...
agent-base
Agent Base is a source-level research project on coding agents. It compares...