@masuratech/redcap-mcp-server
v1.0.0
Published
MCP server for REDCap — manage projects, records, instruments, surveys, users, and run data quality audits through AI assistants
Maintainers
Readme
REDCap has 5,900+ partner institutions, 2.1 million users, and zero MCP servers. I fixed that. Now my AI assistant exports records, audits data quality, and generates codebooks while I drink coffee. — Allan Mugarura, creator
Why This Exists
REDCap is the backbone of clinical and translational research worldwide. But every interaction — exporting records, checking completeness, generating codebooks, managing surveys — requires clicking through the web UI. This MCP server lets AI assistants do it programmatically.
What makes this different from a REST wrapper:
- Data quality audit — completeness per field, blank required fields, statistical outliers (z-score), duplicate detection, all in one call
- Auto-generated codebook — human-readable data dictionary with choices, branching logic, validation rules
- Enrollment dashboard — breakdown by arm, event, DAG, completion status, with timeline
- Descriptive statistics — mean/median/SD/IQR for numeric fields, frequency tables for categorical
- Cross-tabulation — contingency tables between any two fields
- Event comparison — compare a field across longitudinal timepoints
- Smart search — REDCap filter logic through natural language
Tools (38)
| Category | Tools |
|----------|-------|
| Project | get_project_info, create_project |
| Data Dictionary | get_metadata, import_metadata |
| Records | export_records, import_records, delete_records, next_record_id, search_records, record_count |
| Instruments | list_instruments, get_instrument_event_mappings, get_field_names |
| Events | list_events, import_events |
| Arms | list_arms, import_arms |
| Users | list_users, import_users, list_user_roles, list_user_role_assignments |
| DAGs | list_dags, import_dags |
| Reports | get_report |
| Surveys | get_survey_link, get_survey_queue_link, get_survey_return_code, list_survey_participants |
| Files | export_file, delete_file |
| Repeating | list_repeating_instruments |
| Audit | get_audit_log |
| Analytics | data_quality_audit, enrollment_stats, generate_codebook, describe_field, compare_events, cross_tabulate |
Quick Start
1. Get Your REDCap API Token
In your REDCap project: API → Request API Token (or ask your REDCap admin).
You also need your institution's REDCap API URL, which looks like:
https://redcap.youruni.edu/api/2. Install
npm install -g @masuratech/redcap-mcp-server3. Register with Claude Code
claude mcp add redcap \
--env REDCAP_API_URL=https://redcap.youruni.edu/api/ \
--env REDCAP_API_TOKEN=YOUR_API_TOKEN_HERE \
-- npx @masuratech/redcap-mcp-server4. Use
Start a Claude Code session and ask things like:
- "Show me the data dictionary for my REDCap project"
- "Export all records where age > 18"
- "Run a data quality audit on the demographics form"
- "Generate a codebook for the project"
- "How many participants have completed the baseline survey?"
- "Cross-tabulate sex by treatment arm"
- "Compare depression scores across timepoints"
- "Get the audit log for record 101"
- "Generate a survey link for record 205"
Configuration
| Environment Variable | Required | Default | Description |
|---------------------|----------|---------|-------------|
| REDCAP_API_URL | Yes | — | Your REDCap instance API endpoint |
| REDCAP_API_TOKEN | Yes | — | Project-level API token |
Alternative variable names REDCAP_URL and REDCAP_TOKEN are also accepted.
Multiple Projects
Register multiple MCP servers with different tokens:
claude mcp add redcap-study1 \
--env REDCAP_API_URL=https://redcap.youruni.edu/api/ \
--env REDCAP_API_TOKEN=TOKEN_FOR_STUDY_1 \
-- npx @masuratech/redcap-mcp-server
claude mcp add redcap-study2 \
--env REDCAP_API_URL=https://redcap.youruni.edu/api/ \
--env REDCAP_API_TOKEN=TOKEN_FOR_STUDY_2 \
-- npx @masuratech/redcap-mcp-serverAnalytics Tools
Data Quality Audit
The data_quality_audit tool runs a comprehensive check in one call:
- Completeness: % filled per field, worst fields highlighted
- Required fields: identifies blank required-field entries
- Outliers: z-score based detection on numeric fields (configurable threshold)
- Duplicates: detects records with matching name/email/DOB/phone fields
Codebook Generation
The generate_codebook tool produces a structured, human-readable data dictionary:
- All forms with their labels
- Every field: name, label (HTML stripped), type, validation, choices, branching logic, notes
- Required field markers
- Choice code-label pairs for dropdowns/radios/checkboxes
Cross-Tabulation
The cross_tabulate tool generates contingency tables between any two categorical fields with row totals, column totals, and grand total.
Development
git clone https://github.com/masuratech/redcap-mcp-server.git
cd redcap-mcp-server
npm install
npm run dev # watch mode
npm run build # one-shot compile
npm start # run the serverSecurity
- API tokens are passed via environment variables, never hardcoded
- All communication uses your institution's existing REDCap HTTPS endpoint
- No data is sent to third-party services — everything stays between you and your REDCap instance
- The server runs locally on your machine
License
MIT — Masura Tech Ltd
Built with mass-produced coffee in Kampala by Masura Tech.
