REDCap MCP Server
for AI Agents
Connect your AI agent to StackOne's REDCap MCP server and give it 55 MCP tools out of the box. Auth, tool execution, and security all managed.
Coverage
55 Agent Actions
Agents can read, write and delete in REDCap. Extend your agent's capabilities with custom actions.
Authentication
Agent Tool Authentication
Per-user OAuth in one call. Your REDCap MCP server gets session-scoped tokens with zero credentials stored on your infra.
Agent Auth →Security
Agent Protection
Every REDCap tool response scanned for prompt injection in about 2.5 ms, with 0.94 F1 on tool-response attacks, all running on a CPU.
Prompt Injection Defense →Performance
Max Agent Context. Min Cost.
Free up to 96% of your agent's context window to enhance reasoning and reduce cost, on every REDCap call.
Tools Discovery →What is the REDCap MCP Server?
A REDCap MCP server lets AI agents read and write REDCap data through the Model Context Protocol, Anthropic's open standard for connecting LLMs to external tools. StackOne's REDCap MCP server ships with 55 pre-built actions, fully extensible via the Connector Builder, plus managed authentication, prompt injection defense, observability, and agent execution runtime. Connect it from MCP clients like Claude Desktop, Claude Code, Cursor, Goose, and VS Code, or from agent frameworks like OpenAI Agents SDK, LangChain, and Vercel AI SDK.
All REDCap MCP Tools
Every StackOne action for REDCap, ready for your agent. Read, write and delete, scoped to exactly what you need.
Arms
- Import Arms
Creates or modifies arms in a longitudinal REDCap project. With `override=0` arms are added or renamed without deleting others; with `override=1` all existing arms (and their events and data) are deleted and replaced with the arms supplied.
- Export Arms
Retrieves the list of arms (study branches) in a longitudinal REDCap project. Each arm is returned with its arm number and name, sorted by arm number.
- Delete Arms
Removes one or more arms from a longitudinal REDCap project by arm number. Deleting an arm also permanently deletes every event in that arm and all data collected under those events.
DAGs
- Import DAGs
Creates new Data Access Groups or updates existing ones. A record with a blank unique_group_name creates a DAG (REDCap generates the unique name from the display name); a record carrying an existing unique_group_name renames that DAG.
- Export DAGs
Returns every Data Access Group defined in the project with its display name, unique group name and numeric group ID. Read-only — it modifies no project data.
- Delete DAGs
Permanently removes one or more Data Access Groups from the project, identified by their unique_group_name values. The DAG definition is deleted; users and records assigned to it are not deleted but lose the DAG association.
User DAG Assignments
- Import User DAG Assignments
Assigns users to Data Access Groups by unique group name, or removes a user from all DAGs by passing an empty group name (which grants all-DAG access). Several users can be assigned in one call.
- Export User DAG Assignments
Returns the mapping of users to Data Access Groups in the project, pairing each username with the unique group name of their assigned DAG. An empty group name means the user is not in any DAG and has all-DAG access.
Events
- Import Events
Creates or modifies events in a longitudinal REDCap project. With `override=0` events are added or modified without deleting others; with `override=1` all existing events (and the record data in them) are deleted and replaced with the events supplied.
- Export Events
Retrieves the list of events (timepoints or phases within an arm) in a longitudinal REDCap project, optionally filtered to specific arms.
- Delete Events
Removes one or more events from a longitudinal REDCap project, identified by their unique event names, together with all data stored in those events.
File Repository Files
- Import File Repository File
Uploads a single file into the project-level File Repository, optionally into an existing sub-folder. Supply the file as base64-encoded content; it is sent to REDCap as multipart form data.
- Export File Repository File
Downloads a single file from the project-level File Repository by its doc_id, returned as base64-encoded content.
- Delete File Repository File
Soft-deletes a single file from the project-level File Repository by its doc_id, moving it to the project File Repository Recycle Bin rather than destroying it immediately.
Files
- Import File
Uploads a file into a record-level file-upload field on an existing record. Supply the file as base64-encoded content; it is sent to REDCap as multipart form data.
- Export File
Downloads a file stored in a record-level file-upload field, returned as base64-encoded content. Also works for Signature fields, whose image comes back as a PNG.
- Delete File
Removes the file stored in a record-level file-upload field, leaving the field empty. Also works for Signature fields (file-upload fields with the signature validation type), including the enhanced signature field type added in REDCap 17.3+.
Instrument Event Mappings
- Import Instrument Event Mappings
Creates or modifies the mapping of instruments (forms) to events in a longitudinal REDCap project, controlling which instruments are presented at each event. The import replaces the entire mapping structure in every arm.
- Export Instrument Event Mappings
Retrieves the mapping of instruments (forms) to events in a longitudinal REDCap project, showing which instruments are presented at each event. Optionally filtered to specific arms.
Metadatas
- Import Metadata
Creates or replaces the data dictionary (metadata) of a REDCap project - adding or updating fields, forms, validation rules and branching logic. The import replaces the whole dictionary, so any field left out is removed from the project.
- Export Metadata
Retrieves the complete data dictionary (metadata) for a REDCap project - all fields, instruments, field types, validation rules, branching logic and other configuration details. Optionally filtered to specific fields and/or instruments.
Project Infos
- Import Project Info
Updates project-level settings on an existing project — title, purpose, PI information, longitudinal and survey flags and more. Supports partial updates; fields omitted from the payload are left unchanged. NOTE - the content value is 'project_settings', NOT 'project'.
- Export Project Info
Retrieves the project's metadata and configuration settings — title, production status, longitudinal and survey flags, PI details and other project-level attributes — without exporting any records or instrument designs. Returns a single item covering all project-level configuration fields.
Records
- Import Records
Writes record data into a REDCap project, creating new records or updating existing ones from a JSON payload. Overwrite behaviour, auto-numbering and synchronous versus background processing are controlled by parameters.
- Export Records
Reads record data from a REDCap project — the primary way to pull entered study data. Returns all or a subset of records, fields, instruments and events as JSON, with raw coded values or choice labels.
- Delete Records
Permanently deletes records or parts of records from a REDCap project. Can remove whole records, a single instrument's data for a record, an event's data in a longitudinal project, a single repeating instance, or records within one arm.
Repeating Instruments And Events
- Import Repeating Instruments And Events
Configures which instruments and events in a project are designated as repeating. It does not import record data — it replaces the project's entire repeating configuration with the set supplied in `data`.
- Export Repeating Instruments And Events
Retrieves the list of instruments and events that are configured as repeating in a project. It returns only the repeating ones, not every instrument, and a blank `form_name` marks a row as a repeating event rather than a repeating instrument.
User Role Assignments
- Import User Role Assignments
Assigns users to existing user roles, or removes them from their current role by passing an empty unique_role_name. A DAG can optionally be set in the same record.
- Export User Role Assignments
Returns the current mapping of users to the user roles they are assigned to. Every project user is listed; users who are not in a role appear with a blank unique_role_name.
User Roles
- Import User Roles
Creates new custom user roles or updates existing ones. A record with a blank unique_role_name creates a role; a record carrying an existing unique_role_name updates that role's label and permissions.
- Export User Roles
Returns every custom user role defined in the project with its system ID, human-readable label and full set of permission flags, including per-instrument form and data export rights. Always returns all roles — there is no filter parameter.
- Delete User Roles
Permanently removes one or more custom user roles from the project, identified by their unique_role_name system IDs. Role deletion cannot be undone.
Users
- Import Users
Adds existing REDCap system users to the project and sets their permissions, or updates the permissions of users already in the project. It does not create REDCap accounts — the username must already exist in the REDCap system.
- Export Users
Returns every user in the project with their profile fields and full set of permission flags, including per-instrument form rights and per-instrument data export rights. There is no filter parameter — the method always returns the whole visible user list.
- Delete Users
Removes one or more users from the project by username. The users' REDCap system accounts are not deleted, only their assignment to this project, along with their project API token, user role assignment and Data Access Group assignment.
Other (19)
- Create File Repository Folder
Creates a new folder in the project-level File Repository and returns its folder_id. The folder can optionally be nested under an existing folder and restricted to a single Data Access Group and/or User Role. It creates directory structure only, never file content.
- Create Project
Creates one new REDCap project from scratch, or from a complete exported project design supplied as CDISC ODM XML in the optional odm parameter.
- List File Repository
Lists everything one level inside a folder of the project File Repository - sub-folders, each with its own folder_id, and files, each with its own doc_id. Without folder_id it lists the top level of the File Repository.
- Export Instrument PDF
Generates a PDF of one or more data collection instruments, blank or populated with a record's data — the same PDF offered by the web interface. Returned as base64-encoded content.
- Export Instruments
Retrieves the list of all instruments (forms) defined in a REDCap project, each with its unique name and display label. A lightweight way to discover a project instrument structure without downloading the full data dictionary.
- Export Logging
Retrieves audit trail entries from a project's activity log - data exports, imports, record edits and deletions, user events and system changes - with optional filters on event type, username, record, DAG and a server-time date range.
- Export Field Names
Returns the export/import-specific version of field names for all fields (or a single field) in a project. Its primary purpose is to handle checkbox fields, whose export names take the form field_name___coded_value.
- Export Project XML
Exports the entire project — records, events, arms, instruments, fields and project attributes — as a single CDISC ODM XML string (ODM version 1.3.1), suitable for cloning the project on the same or another REDCap server or importing into another ODM-compatible system.
- Export REDCap Version
Returns the version number of the REDCap instance as a bare plain-text string (for example 17.6.5). The simplest REDCap API method — it takes no parameters beyond token and content and is useful for verifying connectivity and for version-gating version-specific API calls.
- Export Reports
Runs a saved REDCap report by its report ID and returns its record-level data as JSON, using the field selection, filtering and ordering configured when the report was built.
- Export Survey Access Code
Returns the short alphanumeric survey access code for a specific record and survey instrument, which a participant can type at the REDCap survey login page instead of opening a full survey URL.
- Export Survey Link
Generates the unique, record-specific survey URL for a given record and survey instrument, for distribution by email, SMS or any other channel. The URL is stable, so repeated calls for the same record, instrument, event and repeat instance return the same link.
- Export Survey Participants
Retrieves the survey participant list for one survey-enabled instrument, returning each participant's contact details, invitation status, response status, access code and direct survey link. Useful for tracking invitation delivery, monitoring response rates and pulling per-participant links in bulk.
- Export Survey Queue Link
Returns the unique survey queue URL for a record, which presents every survey whose queue conditions are met in a single guided workflow. There is one non-expiring queue link per record, so repeated calls return the same URL.
- Export Survey Return Code
Returns the unique Save and Return Later code that lets a respondent resume an incomplete survey response from its last saved point. The code can be retrieved before the respondent has started, and is sent to the respondent alongside the survey link rather than embedded in it.
- Switch DAG
Switches the calling API user's own active Data Access Group to another DAG enabled for them in the project's DAG Switcher, or to [No Assignment] (the all-DAGs view). The switch changes their actual DAG assignment in the project, not just the current call.
- Generate Next Record Name
Returns what the next record ID would be if a new record were created right now, by finding the current maximum numerical record ID in the project and incrementing it by one. It does not create or reserve a record.
- Randomize Record
Triggers the randomization of an existing record against a specific randomization definition, performing the same action as randomizing manually in the REDCap UI. Requires the record to exist with all stratification fields filled in.
- Rename Record
Changes the record ID of an existing record while preserving all of its data, history and relationships. Useful when consolidating projects, renumbering records or correcting mistaken IDs.
Set Up Your REDCap MCP Server in Minutes
One endpoint. Any framework. Your agent is talking to REDCap in under 10 lines of code.
Agent Frameworks
{
"mcpServers": {
"stackone": {
"command": "npx",
"args": [
"-y",
"mcp-remote@latest",
"https://api.stackone.com/mcp?x-account-id=<account_id>",
"--header",
"Authorization: Basic <YOUR_BASE64_TOKEN>"
]
}
}
}Platform Resources
Comparing BM25, TF-IDF, and Hybrid Search for MCP Tool Discovery
Benchmarking BM25, TF-IDF, and hybrid search for MCP tool discovery across 916 tools. The 80/20 TF-IDF/BM25 hybrid hits 21% Top-1 accuracy in under 1ms.
10 min
Indirect Prompt Injection Defense for MCP Tools: A Technical Guide
MCP tools that read emails, CRM records, and tickets are indirect prompt injection vectors. Here's how we built a two-tier defense that scans tool results in ~11ms.
12 min
MCP vs A2A: Architecture, Security, and When to Use Each
MCP vs A2A: what each protocol standardizes, how they differ, the security risks they share, and when to use one, both or a hybrid.
12 min
MCP vs API: What Hundreds of Connector Builds Taught Us
MCP wraps APIs, it doesn't replace them. After building hundreds of connectors that serve both, here's when each approach wins.
14 min read
FAQ
REDCap MCP Server FAQ
origin_owner_id.