OSCAR MCP Server
The OSCAR MCP Server provides read-only, local access to your CPAP/BiPAP therapy data stored in OSCAR's SQLite database (oscar.db). It enables LLM assistants to analyze, summarize, and track sleep therapy metrics through a suite of MCP tools, resources, and prompts, without data ever leaving your machine.
Key Capabilities:
Profile & Device Discovery: List profiles, devices, and date ranges (
list_profiles,get_device_info).Therapy Summaries: Night-by-night tables of usage, AHI, events, pressure, and leak (
get_daily_summaries); aggregate statistics and trends (get_statistics).Deep-Dive Analysis: Single-night sessions, settings, and event counts (
get_daily_detail); individual respiratory events (apneas, hypopneas, RERAs) with hourly clustering (get_respiratory_events); per-session channel statistics (get_session_details).Settings Tracking: Machine setting changes over time (
get_therapy_settings).Custom Queries: Guarded read-only SQL (
run_sql) with automatic setting-code decoding, warnings for common pitfalls, and timeouts; database schema exploration (describe_database).Data Context: Channel name mapping (
list_channels); resources with AHI/RDI formulas, interpretation caveats, and a glossary.Guided Workflows: Predefined prompts for common tasks like therapy review, leak investigation, period comparison, and appointment preparation.
Privacy & Safety: All tools are read-only; personal identifiers are stripped by default (can be enabled with
OSCAR_MCP_INCLUDE_PII=1).
This allows you to identify issues (high leaks, clustered apneas), evaluate setting changes, and get contextualized data with units and clinical reference bands—all from your local OSCAR database.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@OSCAR MCP Server Summarise my last 30 nights of CPAP therapy."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
OSCAR MCP Server
A read-only Model Context Protocol server that lets an LLM assistant — Claude Desktop, ChatGPT Codex, GitHub Copilot CLI, VS Code, or anything else that speaks MCP — analyse your own CPAP/BiPAP therapy data from OSCAR.
It talks directly to the SQLite database that OSCAR 2.x writes (oscar.db), so no export
step is needed and OSCAR can stay open while you use it.
Claude / Copilot ──stdio──► oscar-mcp ──read-only──► oscar.dbYour data never leaves your machine. The server opens the database read-only, withholds personal identifiers by default, and cannot write to it even if asked.
Not medical advice. This is an informational tool for reviewing your own data. It is not a medical device, and it is not affiliated with or endorsed by the OSCAR project.
What you can ask
Once connected, questions like these work:
"Summarise my last 30 nights of CPAP therapy."
"Is my AHI trending up or down?"
"Which nights had the worst leaks, and did the mask setting change on those nights?"
"Show me when apneas clustered during the night of 12 March."
"Did changing my minimum pressure make a difference?"
Related MCP server: HealthLedger MCP
Requirements
Python 3.10+
OSCAR 2.x, which stores data in
oscar.db(OSCAR 1.x uses a different on-disk format and is not supported)
Install
git clone https://github.com/Barbaroso/oscar-mcp.git
cd oscar-mcp
pip install -e .Check that it can find your data:
python -c "from oscar_mcp import discover; print(discover().as_dict())"Expected output:
{'data_dir': 'C:\\Users\\you\\Documents\\OSCAR20_Data',
'db_path': 'C:\\Users\\you\\Documents\\OSCAR20_Data\\oscar.db',
'discovered_via': 'registry:HKCU\\Software\\OSCAR_Team\\OSCAR 2.0\\Settings'}The data folder is resolved in this order: OSCAR_DATA_DIR → the path OSCAR recorded in the
Windows registry → common documents folders (including OneDrive-redirected ones). If none of
those work, set OSCAR_DATA_DIR explicitly.
Auto-detection runs only when you have not said where the data is. If OSCAR_DATA_DIR is set
but holds no oscar.db, the server refuses to start rather than searching on — a typo should
not quietly open a backup, a second profile, or another household member's therapy data.
Connect it
Claude Desktop
Edit claude_desktop_config.json:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"oscar": {
"command": "python",
"args": ["-m", "oscar_mcp"],
"env": {
"OSCAR_DATA_DIR": "C:\\Users\\you\\Documents\\OSCAR20_Data"
}
}
}
}Restart Claude Desktop. The OSCAR tools appear in the tools menu.
ChatGPT Codex
Edit ~/.codex/config.toml:
[mcp_servers.oscar]
command = "python"
args = ["-m", "oscar_mcp"]
default_tools_approval_mode = "writes"
[mcp_servers.oscar.env]
OSCAR_DATA_DIR = "C:\\Users\\you\\Documents\\OSCAR20_Data"Restart Codex. See Approvals for what the approval mode does.
GitHub Copilot CLI / VS Code
Add to mcp.json:
{
"servers": {
"oscar": {
"type": "stdio",
"command": "python",
"args": ["-m", "oscar_mcp"],
"env": {
"OSCAR_DATA_DIR": "C:\\Users\\you\\Documents\\OSCAR20_Data"
}
}
}
}Not installed with pip?
Point at the source directory instead:
{
"command": "python",
"args": ["-m", "oscar_mcp"],
"cwd": "C:\\path\\to\\oscar-mcp"
}On Windows, use the full interpreter path (for example C:\\Python314\\python.exe) if
python is not on the PATH seen by the client application.
Approvals
Every tool here is declared read-only in its MCP metadata (readOnlyHint), and the
declaration is true: the database is opened with SQLite's mode=ro and run_sql
accepts nothing but a single SELECT. Nothing this server exposes can change your
therapy data.
Clients use that declaration to decide when to interrupt you. Codex reads it through
default_tools_approval_mode, which takes four values:
Value | Meaning |
| Ask before every call. |
| Decide from what each tool declares about itself. |
| Ask only for tools that are not declared read-only. |
| Pre-approve everything this server exposes. |
writes is recommended. Every tool here declares itself read-only, so nothing prompts
today; but if a future tool ever stops making that promise, it still stops to ask.
approve gives up that protection, so prefer it only for a server you have read.
If a sandboxed, non-interactive run reports user cancelled MCP tool call, that is an
approval nobody was present to answer -- not a crash, and not a failure of the server.
Tools
Tool | Purpose |
| Profiles, devices and the date range that has data. Start here. |
| Therapy devices, model and last import time. |
| Night-by-night table: usage, AHI, events, pressure, leak. |
| Aggregates for a period: compliance, AHI distribution, trends. |
| One night in full: sessions, settings, per-channel statistics. |
| Individual apneas/hypopneas/RERAs and when they clustered. |
| Machine settings over time, and what changed on which night. |
| Per-channel statistics for a single session. |
| Maps numeric channel ids to names such as AHI or Leak Rate. |
| Tables, columns, foreign keys and the rules for writing a correct query. |
| A single read-only |
run_sql guardrails
This schema reuses column names across tables, so the natural guess — join the columns whose
names match — returns zero rows or a plausible but wrong answer rather than an error. The
traps are real: sessions.session_id is not the primary key, channels.id is not the
channel identifier, and session_settings.value is a device-specific code where 1 means
Nasal on MaskType but Full Face on RMS9_Mask.
run_sql therefore does four things beyond running the query:
Warns on query shapes known to return silently wrong results — wrong join key, a date taken from
start_timewithout the noon shift, or readingrespiratory_events.event_typeas though it were the event kind.Decodes setting codes automatically, adding a
value_labelcolumn resolved throughchannel_options, so a raw number is never left to be guessed.Points to
get_therapy_settingsfor categorical settings, which applies the mapping itself.Cancels a query that overruns its time budget (10 s by default), rather than hanging. The row limit cannot prevent this on its own: producing the first row of an unintended cross join already requires scanning every combination, so a missing join condition runs forever no matter how few rows you asked for. The cancellation message says so, because that is nearly always the cause.
describe_database returns the foreign keys and the same rules, because guidance that lives
only in a passive resource is not read by the caller who needs it.
Responses carry their units and reference bands (AHI < 5 normal, 5–15 mild, 15–30 moderate, ≥ 30 severe; 4 h/night compliance; 24 L/min large-leak threshold) so the assistant reads the numbers in context rather than guessing.
Resources: what the numbers mean
Tools return values. Resources return the domain model needed to read those values correctly, so the assistant is not left inferring clinical meaning from column names. They are static, cheap to read, and cost no tool call.
Resource | Contents |
| Exact AHI and RDI formulas, which events count toward each, and the source in OSCAR's code. |
| The caveats that turn a correct number into a wrong conclusion. |
| Tables as real-world concepts, with the join keys and the traps in them. |
| Apnea, hypopnea, clear airway, RERA, CSR, leak — as OSCAR itself defines them. |
| All of the above in one document. |
Every clinical or arithmetic claim cites a primary source in the OSCAR project — its own
help/help_en/glossary.html or its C++ implementation in SleepLib/ — rather than restating
received wisdom. The AHI and RDI formulas are taken from SleepLib/day.h and reproduce
OSCAR's own stored values exactly. A test enforces that no claim ships without a citation.
This matters because the raw numbers invite specific wrong readings, for example:
Large leak invalidates a night. Leak severe enough to compromise therapy also degrades event detection, so that night's AHI is not comparable with a well-sealed night's.
RDI already contains AHI. They are two views of one night, separated by RERAs, and must never be summed.
Clear-airway events are not treated by more pressure, unlike obstructive ones.
Cross-brand AHI is not comparable: ResMed flags hypopnea at ~50% flow reduction, Respironics at ~40%.
A device AHI is not a sleep study. The machine cannot tell sleep from wakefulness.
Prompts: how to run a review
Reusable workflows that encode the order of questions producing a sound reading, so the analysis does not depend on knowing which tool to ask for first.
Prompt | Purpose |
| Review recent nights, checking leak before drawing conclusions from AHI. |
| Find which nights leaked, how badly, and what changed around them. |
| Test whether something really changed between two date ranges. |
| A factual summary to bring to a clinician, with questions to ask. |
Nights, not calendar days
A session that starts after midnight belongs to the previous night, matching how OSCAR itself reports data. A session starting at 02:00 on 12 March is part of the night of 11 March. The cut-off is noon.
Where the numbers come from
OSCAR computes daily_summaries lazily, so the most recent night is often missing from it.
Those nights are recomputed from the underlying sessions. Every night carries a source
field: oscar for values OSCAR itself calculated, computed for values derived here.
Privacy
Your therapy data is medical data. This server is built to keep the exposure minimal:
Read-only. The database is opened with SQLite's
mode=roURI, so writes fail at the driver level.run_sqladditionally accepts only a singleSELECT/WITHstatement and rejectsPRAGMA,ATTACHand every write keyword.No identifiers by default.
first_name,last_name,dob,address,phone,email,password_hashand deviceserial_numberare stripped from every response, and theuser_info/doctor_infotables are not reachable at all — including through renamed expressions inrun_sql.Local only. The server runs on your machine and speaks stdio to the client next to it. It opens no network connections of its own.
OSCAR is untouched. The database uses WAL journalling, so reading while OSCAR is running is safe and changes nothing.
Set OSCAR_MCP_INCLUDE_PII=1 to lift the identifier filtering. Only do that if you
understand that the data then leaves your machine as part of the conversation with whatever
model your client is using.
Configuration
Variable | Effect |
| Path to the folder containing |
| Seconds a |
|
|
Development
pip install -e ".[dev]"
python -m pytest
python -m ruff check .Tests run against a synthetic database built by tests/fixture.py. No real therapy data is
used or committed. The fixture derives AHI and RDI from its own event counts using OSCAR's
formulas, so the semantic layer's documented arithmetic is verified rather than asserted, and
it reproduces the schema's join and enum hazards so the guardrails can be tested against them.
Contributions are welcome. Two rules matter more than style here:
No unsourced clinical claims. Anything the server asserts about therapy must cite a primary source in the OSCAR project, and a test enforces this.
Read-only, always. The database is someone's medical record. No code path may open it writable or widen what
run_sqlaccepts.
Credits
Built for OSCAR (Open Source CPAP Analysis Reporter),
whose developers did the hard work of decoding CPAP device formats. The clinical definitions
and the AHI/RDI formulas used here come from OSCAR's own help glossary and source code, cited
inline in oscar_mcp/knowledge.py.
This project is an independent companion tool. It is not affiliated with, endorsed by, or supported by the OSCAR project or by any device manufacturer.
License
GPL-3.0-or-later, matching OSCAR, from which the clinical reference material is derived. See LICENSE.
Disclaimer
This is an informational tool for reviewing your own data. It is not a medical device and does not provide medical advice. Discuss any therapy change with your clinician.
Available Tools
11 toolsdescribe_databaseA
Describe the OSCAR database: tables, columns, foreign keys, and the join and decoding rules that make a query correct. Read this before writing run_sql.
Inputs: no named parameters.
get_daily_detailB
Everything recorded for one night: each session, machine settings in effect, event counts and per-channel statistics. Date must be ISO format.
Inputs: date (required), profile.
get_daily_summariesB
Return a night-by-night table of therapy results (usage hours, AHI, event counts, pressure and leak). Dates are ISO format; omit them for all data.
Inputs: limit, profile, end_date, start_date.
get_device_infoB
Get the therapy devices recorded for a profile, including model and last import time.
Inputs: profile.
get_respiratory_eventsB
Individual respiratory events (apneas, hypopneas, RERAs) for one night, with counts by type and an hourly histogram showing when they clustered. Large leak spans are reported separately from respiratory events.
Inputs: date (required), profile, include_events.
get_session_detailsB
Per-channel statistics for a single session, identified by its session_db_id.
Inputs: session_db_id (required), profile.
get_statisticsC
Aggregate statistics for a period: usage and compliance, AHI distribution and severity band, event totals, pressure and leak summaries, plus simple trends.
Inputs: profile, end_date, start_date.
get_therapy_settingsC
Machine settings over time (pressure limits, EPR, mode, ramp, humidity). Set changes_only to report just the nights where a setting changed.
Inputs: profile, end_date, start_date, changes_only.
list_channelsA
List the data channels OSCAR recorded, mapping numeric channel ids to human readable names such as AHI, Pressure, Leak Rate or Flow Limitation.
Inputs: profile, only_used.
list_profilesA
List OSCAR profiles with their data coverage. Call this first when you do not know which profile or date range is available.
Inputs: no named parameters.
run_sqlA
Run a read-only SELECT against the OSCAR database for analysis the other tools do not cover. Only SELECT/WITH statements are permitted, and a query is cancelled if it exceeds its time budget. Call describe_database first: this schema reuses column names across tables, so a wrong join key returns zero rows instead of an error. For mask, mode and other categorical settings prefer get_therapy_settings, because raw values are device-specific codes whose meaning depends on the channel.
Inputs: sql (required), limit.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Each tool targets a distinct resource or action: metadata (describe_database, list_profiles, list_channels), device info, summaries, statistics, nightly details, events, settings, and session details. Even run_sql is clearly scoped as a fallback for analyses not covered by the specialized tools, and descriptions clarify boundaries between similar tools like get_daily_detail vs get_session_details.
All tool names follow a consistent verb_noun snake_case pattern (run_sql, list_profiles, get_device_info, list_channels, describe_database, get_daily_summaries, etc.). The verbs are predictable (list/get/describe/run) and nouns are clear, making the API easy to navigate.
With 11 tools, the server is well-scoped for the domain of OSCAR CPAP data analysis. Each tool covers a necessary part of the workflow (profiles, schema, raw queries, summaries, statistics, details, events, settings, sessions) without redundancy or bloat.
The tool surface provides comprehensive coverage for reading and analyzing therapy data: profile discovery, device info, channel mapping, database schema, nightly summaries, period statistics, per-night detail, event-level data, settings history, and session-level stats. The inclusion of run_sql fills any potential ad-hoc analysis gaps, leaving no obvious dead ends.
Maintenance
Related MCP Connectors
Hosted MCP server exposing US hospital procedure cost data to AI assistants
MCP server that lets AI assistants use all OneSchema features exposed via the public API.
Hosted Apple Health MCP for Claude and ChatGPT, works outside the US. iPhone app, no local server.
The HubSpot MCP Server acts as a bridge that enables AI assistants and Large Language Models to securely interact with HubSpot CRM data through natural conversation, without requiring users to understand complex API structures. It provides read-only access to standard CRM objects (contacts, companies, deals, tickets, products, invoices, and more) and their associations, secured via OAuth 2.0, allowing AI agents to perform tasks like summarizing deals, fetching company updates, and looking up record changes.
Related MCP Servers
- AlicenseAqualityDmaintenanceA zero-config MCP server that enables AI to access, analyze, and manage local SQLite databases with secure read-only querying and automatic schema discovery.836 PyPIMIT
- AlicenseCqualityDmaintenanceA local-first, model-agnostic MCP server that stores personal health data in a SQLite file and provides analysis-ready views for any AI client to log, retrieve, and reason over health records.79MIT
- AlicenseNot gradedqualityDmaintenanceRead-only MCP server that exposes Garmin Connect health data from a local SQLite database to AI assistants, enabling queries for recent days, sleep, weekly trends, and a guarded SQL query surface.MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that exposes health metrics from the Sapphire Wellness App to AI assistants, enabling natural language queries for activity, blood pressure, glucose, heart rate, sleep, and SpO2 data.-