|
1 | | -<!--suppress HtmlDeprecatedAttribute --> |
2 | 1 | <div align="center"> |
3 | 2 | <h1 align="center"> |
4 | 3 | <br> |
5 | 4 | <a href="#"><img src="assets/COVER.png" alt="MCPStack Tool" width="100%"></a> |
6 | 5 | <br> |
7 | | - MCPStack Tool Builder |
| 6 | + MCPStack MIMIC MCP |
8 | 7 | <br> |
9 | 8 | </h1> |
10 | | - <h4 align="center">A Template To Fasten The Creation of MCP-Stack MCP Tools</h4> |
| 9 | + <h4 align="center">Let Your Favourite LLM Dealing With The SQLs!</h4> |
11 | 10 | </div> |
12 | 11 |
|
13 | 12 | <div align="center"> |
|
17 | 16 | </a> |
18 | 17 | <img alt="ruff" src="https://img.shields.io/badge/Ruff-lint%2Fformat-9C27B0?style=for-the-badge&logo=ruff&logoColor=white"> |
19 | 18 | <img alt="python" src="https://img.shields.io/badge/Python-3.9%2B-3776AB?style=for-the-badge&logo=python&logoColor=white"> |
| 19 | +<img alt="pytest coverage" src="https://img.shields.io/badge/Coverage-65%25-brightgreen?style=for-the-badge&logo=pytest"> |
20 | 20 | <img alt="license" src="https://img.shields.io/badge/License-MIT-success?style=for-the-badge"> |
21 | 21 |
|
22 | 22 | </div> |
23 | 23 |
|
24 | 24 | > [!IMPORTANT] |
25 | 25 | > If you have not been across the MCPStack main orchestrator repository, please start |
26 | | -> there: [View Org](https://github.com/MCP-Pipeline) |
| 26 | +> there: [View MCPStack](https://github.com/MCP-Pipeline/MCPStack) |
27 | 27 |
|
28 | | -## <a id="about-the-project"></a>💡 About The Project |
| 28 | +## <a id="about-the-project"></a>💡 About The MCPStack MIMIC Tool |
29 | 29 |
|
30 | | -`MCPStack Tool Builder` is a template repository designed to streamline the creation of `MCPStack` MCP Tools. |
31 | | -As in, you are using the `MCPStack` main orchestrator repository and wish to create a new MCP tool to pipeline with. |
32 | | -You can always start from scratch, but certainly, our `MCPStack Tool Builder` will help you get started quickly with a |
33 | | -solid foundational skeleton builder. |
| 30 | +`MCPStack MIMIC` is an MCP tool that connects the **MIMIC-IV clinical database** (with either SQLite or BigQuery backends) |
| 31 | +into your **MCPStack pipelines**. |
34 | 32 |
|
35 | | -**Wait, what is a Model Context Protocol (MCP) & `MCPStack` — In layman's terms ?** |
| 33 | +In layman's terms: |
| 34 | +* MIMIC-IV is a large, de-identified database of ICU patient records, commonly used for healthcare research. |
| 35 | +* This tool makes that dataset accessible to an LLM in a controlled way. |
| 36 | +* It provides actions like *listing available tables*, *showing table structure with sample data*, and *running queries*; all exposed through MCP so your model can reason with healthcare data securely. |
36 | 37 |
|
37 | | -The Model Context Protocol (MCP) standardises interactions with machine learning (Large Language) models, |
38 | | -enabling tools and libraries to communicate successfully with a uniform workflow. |
| 38 | +### What is MCPStack, in layman's terms? |
39 | 39 |
|
40 | | -On the other hand, `MCPStack` is a framework that implements the protocol, and most importantly, allowing |
41 | | -developers to create pipelines by stacking MCP tools of interest and launching them all in Claude Desktop. |
42 | | -This allows the LLM to use all the tools stacked, and of course, if a tool is not of interest, do not include it in the |
43 | | -pipeline and the LLM won't have access to it. |
| 40 | +The **Model Context Protocol (MCP)** standardises how tools talk to large language models. |
| 41 | +`MCPStack` is the orchestrator: it lets you **stack multiple MCP tools together** into a pipeline and then expose them |
| 42 | +inside an LLM environment (like Claude Desktop). |
44 | 43 |
|
45 | | -## Installation |
| 44 | +Think of it like **scikit-learn pipelines, but for LLMs**: |
46 | 45 |
|
47 | | -> [!NOTE] |
48 | | -> As this repository is a template, you can always create a new repository from this template. Use |
49 | | -> the "Use this template" button on the top right of the GitHub UI to create a new repository based on this template. |
| 46 | +* In scikit-learn: you chain `preprocessors`, `transformers`, `estimators`. |
| 47 | +* In MCPStack: you chain MCP tools (like MIMIC, Jupyter Notebook MCP, etc). |
50 | 48 |
|
51 | | -Meanwhile, you may alos clone this repository and install it locally to start building your own `MStack` MCP tool. |
52 | 49 |
|
53 | | -### Clone the repository |
| 50 | +>[!IMPORTANT] |
| 51 | +> This MCP has been made possible thanks to the `M3` original work by @rafiattrach, @rajna-fani, @MoreiraP12 |
| 52 | +> Under Dr. Leo Celi's supervision at MIT Lab for Computational Physiology. Following a first pull request of |
| 53 | +> MCPStack to `M3`, we realised that we needed to externalise MCPStack to make it more modular and reusable |
| 54 | +> across different use-cases. As such, MCPStack MIMIC is a copy of the original `M3` codebase, with adjustments |
| 55 | +> only based on how how MCPStack works, and how it is structured. |
54 | 56 |
|
55 | | -```bash |
56 | | -git clone https://github.com/MCP-Pipeline/MCPStack-Tool-Builder.git |
57 | | -cd MCPStack-Tool-Builder |
58 | | -``` |
| 57 | +--- |
| 58 | + |
| 59 | +## Installation |
59 | 60 |
|
60 | | -### Install dependencies |
| 61 | +You can install the MIMIC tool as a standalone package. Thanks to `pyproject.toml` entry points, MCPStack |
| 62 | +will auto-discover it. |
61 | 63 |
|
62 | | -Using `UV` (recommended —— See official [UV documentation for installation of UV](https://uv.dev/docs/)): |
| 64 | +### PyPI Installation Via `UV` |
63 | 65 |
|
64 | 66 | ```bash |
65 | | -uv sync |
| 67 | +uv add mcpstack_mimic |
66 | 68 | ``` |
67 | 69 |
|
68 | | -Using `pip`: |
| 70 | +### PyPI Installation Via `pip` |
69 | 71 |
|
70 | 72 | ```bash |
71 | | -pip install -e .[dev] |
| 73 | +pip install mcpstack-mimic |
72 | 74 | ``` |
73 | 75 |
|
74 | | -### Install pre-commit hooks |
75 | | - |
76 | | -Via `UV`: |
| 76 | +### Install pre-commit hooks (optional, for development) |
77 | 77 |
|
78 | | -```bash |
| 78 | +```bash |
79 | 79 | uv run pre-commit install |
80 | | -``` |
| 80 | +# or pip install pre-commit |
| 81 | +``` |
81 | 82 |
|
82 | | -Via `pip`: |
| 83 | +### Run Unit Tests (optional, for development) |
83 | 84 |
|
84 | 85 | ```bash |
85 | | -pre-commit install |
| 86 | +uv run pytest |
86 | 87 | ``` |
87 | 88 |
|
88 | | -## Create Your Tool's Skeleton |
| 89 | +--- |
89 | 90 |
|
90 | | -Once dependencies are installed, you can use the `mcpstack_tool` CLI to bootstrap and customise your tool’s skeleton. |
91 | | -Every commands is run with `uv run mcpstack_tool.py` or `python mcpstack_tool.py` if you are not using `UV`, followed by the command you want to run; as follows: |
| 91 | +## 🔌 Using With MCPStack |
92 | 92 |
|
93 | | -<img src="assets/readme/help.gif" width="61.8%" align="left" style="border-radius: 10px;"/> |
| 93 | +The `MIMIC` tool is auto-registered in MCPStack through its entry points: |
94 | 94 |
|
95 | | -### `Help` Banner |
96 | | - |
97 | | -Run with `--help` or `-h` to display the banner and see all available commands. |
98 | | - |
99 | | -```bash |
100 | | -uv run mcpstack_tool.py --help |
| 95 | +```toml |
| 96 | +[project.entry-points."mcpstack.tools"] |
| 97 | +mimic = "mcpstack_mimic.tools.mimic.mimic:MIMIC" |
101 | 98 | ``` |
102 | 99 |
|
103 | | -<br clear="left"> |
104 | | - |
105 | | -<br /> |
| 100 | +That means MCPStack will “see” it without any extra configuration. |
106 | 101 |
|
107 | | -<img src="assets/readme/init.gif" width="61.8%" align="right" style="border-radius: 10px;"/> |
| 102 | +### Initialise the database |
108 | 103 |
|
109 | | -### `Init` |
| 104 | +For SQLite (demo dataset by default): |
110 | 105 |
|
111 | | -init starts an interactive prompt command-line-based process to generate your tool configuration. |
112 | | -It will ask you for values like `tool_slug`, `class_name`, and `env_prefix`. |
113 | | - |
114 | | - |
115 | | -<br clear="right"> |
116 | | - |
117 | | -<br /> |
| 106 | +```bash |
| 107 | +uv run mcpstack tools mimic init --dataset mimic-iv-demo |
| 108 | +``` |
118 | 109 |
|
119 | | -<img src="assets/readme/preview.gif" width="61.8%" align="left" style="border-radius: 10px;"/> |
| 110 | +This downloads and prepares the dataset locally. |
120 | 111 |
|
121 | | -### `Preview` |
| 112 | +### Configure the tool |
122 | 113 |
|
123 | | -preview shows you the replacements that would be applied across the codebase and displays an example diff. |
124 | | -Note this could be also run from the `init`. |
| 114 | +Pick a backend (SQLite or BigQuery): |
125 | 115 |
|
126 | | -<br clear="left"> |
| 116 | +```bash |
| 117 | +uv run mcpstack tools mimic configure --backend sqlite --db-path ./mimic.db |
| 118 | +``` |
127 | 119 |
|
128 | | -<br /> |
| 120 | +or |
129 | 121 |
|
130 | | -<img src="assets/readme/apply.gif" width="61.8%" align="right" style="border-radius: 10px;"/> |
| 122 | +```bash |
| 123 | +uv run mcpstack tools mimic configure --backend bigquery --project-id <YOUR_GCP_PROJECT> |
| 124 | +``` |
131 | 125 |
|
132 | | -### `Apply` |
| 126 | +This generates a `mimic_config.json` you can later feed into pipelines. |
133 | 127 |
|
134 | | -Once happy, use apply to perform replacements and rename the package directory. Note this could be also run from the `init`. |
| 128 | +### Check status |
135 | 129 |
|
136 | | -<br clear="right"> |
| 130 | +```python |
| 131 | +uv run mcpstack tools mimic status |
| 132 | +``` |
137 | 133 |
|
138 | | -<br /> |
| 134 | +>[!NOTE] |
| 135 | +> We favourite `uv` for running MCPStack commands, but you can also use `mcpstack` directly if installed globally |
| 136 | +> with `pip install mcpstack`. |
139 | 137 |
|
140 | | -<img src="assets/readme/validate.gif" width="61.8%" align="left" style="border-radius: 10px;"/> |
| 138 | +--- |
141 | 139 |
|
142 | | -### `Validate` |
| 140 | +## 🖇️ Build A Pipeline With MIMIC |
143 | 141 |
|
144 | | -Run validate to ensure placeholders were replaced correctly (or to check if any remain). |
| 142 | +Now that the tool is installed and configured, add it to your pipeline: |
145 | 143 |
|
146 | | -<br clear="left"> |
| 144 | +### Default MIMIC Pipeline (Runs with demo MIMIC dataset) |
147 | 145 |
|
148 | | -<br /> |
| 146 | +```bash |
| 147 | +uv run mcpstack pipeline mimic --new-pipeline my_pipeline.json |
| 148 | +``` |
149 | 149 |
|
150 | | -<img src="assets/readme/reset.gif" width="61.8%" align="right" style="border-radius: 10px;"/> |
| 150 | +### Create a new pipeline and add MIMIC previously custom-configured |
151 | 151 |
|
152 | | -### `Reset` (Optional) |
| 152 | +```bash |
| 153 | +uv run mcpstack pipeline mimic --new-pipeline my_pipeline.json --tool-config mimic_config.json |
| 154 | +``` |
153 | 155 |
|
154 | | -Need to start fresh? Restore everything back from the scaffold with reset. |
| 156 | +Or append to an existing pipeline |
155 | 157 |
|
156 | | -> [!CAUTION] |
157 | | -> ⚠️ Use --hard to overwrite files directly. |
| 158 | +```bash |
| 159 | +uv run mcpstack pipeline mimic --to-pipeline existing_pipeline.json --tool-config mimic_config.json |
| 160 | +``` |
158 | 161 |
|
159 | | -<br clear="right"> |
| 162 | +### Run it inside Claude Desktop |
160 | 163 |
|
161 | | -<br /> |
| 164 | +```bash |
| 165 | +uv run mcpstack build --pipeline my_pipeline.json |
| 166 | +``` |
162 | 167 |
|
163 | | -<img src="assets/readme/doctor.gif" width="61.8%" align="left" style="border-radius: 10px;"/> |
| 168 | +Your LLM can now use the MIMIC tool in conversation, with secure access to the clinical dataset. |
| 169 | +Open Claude Desktop, and tada! |
| 170 | + |
| 171 | +--- |
| 172 | + |
| 173 | +## 📖 Programmatic API |
| 174 | + |
| 175 | +```python |
| 176 | +from mcpstack_mimic.tools.mimic.mimic import MIMIC |
| 177 | +from mcpstack_mimic.tools.mimic.backend.backends.sqlite import SQLiteBackend |
| 178 | +from mcpstack.stack import MCPStackCore |
| 179 | + |
| 180 | +pipeline = ( |
| 181 | + MCPStackCore() #define =config if needed |
| 182 | + .with_tool(MIMIC( |
| 183 | + backends=[ |
| 184 | + SQLiteBackend("<path_to_your_mimic.db>") # SQLite backend with local MIMIC-IV database |
| 185 | + ]) |
| 186 | + # Here you can add as many as new `.with_tool(.)` of interest to play with. |
| 187 | + ).build( |
| 188 | + type="fastmcp", |
| 189 | + save_path="my_mimic_pipeline.json", |
| 190 | + ).run() |
| 191 | +) |
| 192 | +``` |
164 | 193 |
|
165 | | -### `Doctor` |
| 194 | +>[!IMPORTANT] |
| 195 | +> The current repository has (1) technical debts, as in it would benefit from a refactor to make it maybe less messy; for instance, organising the actions into specific files. (2) a lack of documentation, the readme could deserve more in depth exploration of all the possible configurations, explore the code if you are a developer ; it is a little codebase. |
| 196 | +> Pull Requests are more than welcome to minimise the tech debts and improve the documentation. |
166 | 197 |
|
167 | | -Finally, check the health of your repository with doctor. |
168 | | -It reports `package dirs`, `entry points`, and `placeholder` status. |
| 198 | +--- |
169 | 199 |
|
170 | | -<br /> |
171 | | -<br /> |
172 | | -<br /> |
| 200 | +## 📽️ Video Demo |
173 | 201 |
|
174 | | -Here you go! 🎉 You now have a working `MCPStack` tool skeleton ready to customise. |
175 | | -From here, edit `src/mcpstack_<your_tool_name>/tool.py` with the actions your MCP is aimed to be doing, |
176 | | -and `cli.py` to implement your configurability logic. Remove a couple of files and folders not necessary as per the template |
177 | | -and you may be good to go to submit this to the org or to play with it yourself! |
| 202 | +![configuration_wizard][] |
178 | 203 |
|
179 | | -Refer to the `MCPStack` documentation for more details on how to implement your tool logic. |
| 204 | +--- |
180 | 205 |
|
181 | | -## 🔐 License |
| 206 | +🔐 License |
182 | 207 |
|
183 | 208 | MIT — see **[LICENSE](LICENSE)**. |
| 209 | + |
| 210 | +[configuration_wizard]: https://github.com/MCP-Pipeline/mcpstack-mimic/blob/main/assets/readme/pres.mp4 |
0 commit comments