---
name: iblai-connect-clinicaltrials-gov
description: "Read ClinicalTrials.gov data through the ClinicalTrials.gov REST API v2 and expose it to an ibl.ai agent as an MCP tool. Use when the user asks an agent to work with ClinicalTrials.gov data, or to set up a ClinicalTrials.gov MCP connection on ibl.ai."
metadata:
  kind: guide
---

# ClinicalTrials.gov connector for AI agents

> A starting point maintained on ibl.ai at https://ibl.ai/developer/connectors/clinicaltrials-gov — not part of the iblai/base repository. Checked against National Library of Medicine (NIH)'s documentation on October 20, 2026; test it against your own ClinicalTrials.gov setup before you rely on it.

ClinicalTrials.gov is the NIH registry of clinical studies, holding each study's protocol, conditions, interventions, eligibility, locations, status and, where posted, results.

## Auth & conventions

- **API:** ClinicalTrials.gov REST API v2 (REST (JSON or CSV, OpenAPI 3.0)). Search studies with query, filter and sort parameters, fetch a study by NCT ID, read the data model metadata, search areas and enums, and get field statistics. Read-only.
- **Base URL:** https://clinicaltrials.gov/api/v2/
- **Access:** Public, self-serve. Open to anyone with no key or account. The OpenAPI specification is published at https://clinicaltrials.gov/api/oas/v2.
- **Auth:** None (anonymous). The OpenAPI specification defines no security scheme; requests need no credentials.
- **Limits:** pageSize defaults to 10 and is capped at 1,000 studies; page with nextPageToken, keeping the other parameters unchanged between pages.
- Keep ClinicalTrials.gov credentials in environment variables or the ibl.ai credential store. Never print a token in chat and never commit one to a file.
- Destructive or outward-facing calls are marked **Confirm with the user first** — do.

## Reads

- **Studies** — GET /studies searches with query.* (Essie syntax) and filter.* parameters; JSON or CSV.
- **Single study** — GET /studies/{nctId} returns one study record.
- **Data model** — GET /studies/metadata, /studies/search-areas and /studies/enums describe fields and values.
- **Statistics** — GET /stats/size and /stats/field/values report record sizes and field value counts.
- **Version** — GET /version returns the API version and data timestamp.

## Writes

- None. This skill only reads ClinicalTrials.gov data.

## Expose it to an ibl.ai agent (MCP)

We found no MCP server published by ClinicalTrials.gov or NLM as of December 2026. Host a small MCP server that wraps the calls above, then register it below.

First install the ibl.ai platform skills and connect your organization (writes `IBLAI_ORG`, `IBLAI_USERNAME` and `IBLAI_API_KEY` to `.env`):

```bash
npx skills add iblai/base --all
# then, in your coding agent:
/iblai-api-login
```

Every call below sends `Authorization: Api-Token $IBLAI_API_KEY`.

1. **Register the server** — `POST https://api.iblai.app/dm/api/ai-mentor/orgs/$IBLAI_ORG/users/$IBLAI_USERNAME/mcp-servers/` with `name`, `url`, `transport` (`sse` | `websocket` | `streamable_http`) and `auth_type` (`none` | `token` | `oauth2`). Capture the returned `id`.
   - For an API key or service credential use `auth_type=token` with `auth_scope=platform` for one key across the organization, or scope it to a single agent for one key per agent.
2. **Create the connection** — `POST https://api.iblai.app/dm/api/ai-mentor/orgs/$IBLAI_ORG/users/$IBLAI_USERNAME/mcp-server-connections/` with `server`, `scope` (`platform` | `mentor` | `user`), `auth_type`, and either `credentials` + `authorization_scheme` or a `connected_service` id for OAuth. Credentials are masked on read; never send a masked value back.
3. **Enable it on the agent** — `GET https://api.iblai.app/dm/api/ai-mentor/orgs/$IBLAI_ORG/users/$IBLAI_USERNAME/mentors/{agent_id}/settings/`, add `mcp-tool` to `tool_slugs` and the server id to `mcp_servers`, then `PATCH` the full lists back. They are replaced, not merged.

Full reference: https://ibl.ai/developer/platform/mcp/mcp-connections and the `/iblai-api-agent-mcp` skill.

## Example prompts

- "List recruiting Phase 3 trials for HER2-positive breast cancer in Germany"
- "Show the primary endpoints and enrollment for this NCT ID"
- "Which sponsors registered obesity trials with GLP-1 drugs in the past year?"
- "Export completed trials with posted results for this condition as CSV"

## Guardrails

- Registry data is public, but an agent combining it with internal pipeline or competitive plans handles confidential business information.
- Request the narrowest ClinicalTrials.gov scopes or role the task needs, and prefer a read-only credential for agents that only answer questions.
- Return the fields the user asked for, not whole records; do not paste personal data into chat that the user did not request.
- Before any write, show the user exactly what will change and wait for a yes.
- Respect the documented limits above: page through results and back off on rate-limit responses instead of retrying in a loop.

## References

- ClinicalTrials.gov API: https://clinicaltrials.gov/data-api/api
- About the ClinicalTrials.gov API: https://clinicaltrials.gov/data-api/about-api
- OpenAPI specification (v2): https://clinicaltrials.gov/api/oas/v2
- This connector on ibl.ai: https://ibl.ai/developer/connectors/clinicaltrials-gov
- ibl.ai MCP server connections: https://ibl.ai/developer/platform/mcp/mcp-connections
