{
  "markdown": "<div align=\"center\">\n  <h1>clinicaltrialsgov-mcp-server</h1>\n  <p><b>Search ClinicalTrials.gov trials, retrieve study details and results, and match patients to eligible trials via MCP. STDIO or Streamable HTTP.</b>\n  <div>7 Tools • 1 Resource • 1 Prompt</div>\n  </p>\n</div>\n\n<div align=\"center\">\n\n[![npm](https://img.shields.io/npm/v/clinicaltrialsgov-mcp-server?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/clinicaltrialsgov-mcp-server) [![Docker](https://img.shields.io/badge/Docker-ghcr.io-2496ED?style=flat-square&logo=docker&logoColor=white)](https://github.com/users/cyanheads/packages/container/package/clinicaltrialsgov-mcp-server) [![Version](https://img.shields.io/badge/Version-2.9.3-blue.svg?style=flat-square)](./CHANGELOG.md) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^2.0.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![TypeScript](https://img.shields.io/badge/TypeScript-^7.0-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-v1.4.0-blueviolet.svg?style=flat-square)](https://bun.sh/)\n\n</div>\n\n<div align=\"center\">\n\n[![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge&logo=anthropic&logoColor=white)](https://github.com/cyanheads/clinicaltrialsgov-mcp-server/releases/latest/download/clinicaltrialsgov-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=clinicaltrialsgov-mcp-server&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImNsaW5pY2FsdHJpYWxzZ292LW1jcC1zZXJ2ZXIiXX0=) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22clinicaltrialsgov-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22clinicaltrialsgov-mcp-server%22%5D%7D)\n\n[![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)\n\n</div>\n\n<div align=\"center\">\n\n**Public Hosted Server:** [https://clinicaltrials.caseyjhand.com/mcp](https://clinicaltrials.caseyjhand.com/mcp)\n\n</div>\n\n---\n\n## Overview\n\nSeven tools for searching, discovering, analyzing, and matching clinical trials:\n\n| Tool Name                              | Description                                                                                      |\n| :------------------------------------- | :----------------------------------------------------------------------------------------------- |\n| `clinicaltrials_search_studies`        | Search studies with full-text queries, filters, pagination, sorting, and field selection.        |\n| `clinicaltrials_get_study_record`      | Fetch a single study by NCT ID. Returns the full record: protocol, eligibility, outcomes, arms, interventions, contacts, and locations. |\n| `clinicaltrials_get_study_count`       | Get total study count for a query without fetching data. Fast statistics and breakdowns.         |\n| `clinicaltrials_get_field_values`      | Discover valid values for API fields (status, phase, study type, etc.) with per-value counts.    |\n| `clinicaltrials_get_field_definitions` | Browse the study data model field tree — piece names, types, nesting. Supports subtree navigation and keyword search. |\n| `clinicaltrials_get_study_results`     | Extract outcomes, adverse events, participant flow, and baseline from completed studies. Optional summary mode reduces ~200KB payloads to ~5KB; `outcomeLimit` / `adverseEventLimit` cap full mode without leaving it. |\n| `clinicaltrials_find_eligible`         | Match patient demographics and conditions to eligible recruiting trials. Provide age, sex, conditions, and location to find studies with matching eligibility criteria, contacts, and recruiting locations. |\n\n| Resource                   | Description                                         |\n| :------------------------- | :-------------------------------------------------- |\n| `clinicaltrials://{nctId}` | Fetch a single clinical trial study by NCT ID. Protocol JSON with capped locations/outcomes/references and results replaced by counts; omissions reported with the tool that retrieves them. |\n\n| Prompt                    | Description                                                                        |\n| :------------------------ | :--------------------------------------------------------------------------------- |\n| `analyze_trial_landscape` | Adaptable workflow for data-driven trial landscape analysis using count + search tools. |\n\n## Tools\n\n### `clinicaltrials_search_studies`\n\nPrimary search tool with full ClinicalTrials.gov query capabilities.\n\n- Full-text and field-specific queries (condition, intervention, sponsor, location, title, outcome)\n- Status and phase filters with typed enum values\n- Geographic proximity filtering by coordinates and distance\n- Advanced AREA[] Essie expression support for complex queries\n- Compact index results by default; pass `fields` for a full-fidelity projection of specific leaves (a full single record is ~70KB — fetch one with `get_study_record`)\n- Pagination with cursor tokens, sorting by any field\n\n---\n\n### `clinicaltrials_get_study_results`\n\nFetch posted results data for completed studies.\n\n- Outcome measures with statistics, adverse events, participant flow, baseline characteristics\n- Section-level filtering (request only the data you need)\n- Optional summary mode condenses full results (~200KB) to essential metadata (~5KB per study)\n- Batch multiple NCT IDs per call with partial-success reporting\n- Separate tracking of studies without results and fetch errors\n\n---\n\n### `clinicaltrials_find_eligible`\n\nMatch a patient profile to eligible recruiting trials.\n\n- Takes age, sex, conditions, and location as patient demographics\n- Builds optimized API queries with demographic filters (age range, sex, healthy volunteers)\n- Re-ranks results so studies whose own condition matches a requested condition surface above tangential matches from the upstream fuzzy condition search\n- Returns studies with eligibility and location fields for the caller to evaluate\n- Bounds each candidate to the sites matching the requested location (capped by `locationLimit`) rather than every site the study registers worldwide, adds the nearest recruiting site when none of the matched ones is open, and discloses what was omitted\n- Provides actionable hints when no studies match (broaden conditions, adjust filters)\n\n## Features\n\nBuilt on [`@cyanheads/mcp-ts-core`](https://github.com/cyanheads/mcp-ts-core):\n\n- Declarative tool/resource/prompt definitions with Zod schemas and format functions\n- Unified error handling — handlers throw, framework catches and classifies\n- Dual transport: stdio and Streamable HTTP from the same codebase\n- Pluggable auth (`none`, `jwt`, `oauth`) for HTTP transport\n- Structured logging with optional OpenTelemetry tracing\n\nClinicalTrials.gov-specific:\n\n- Type-safe client for the [ClinicalTrials.gov REST API v2](https://clinicaltrials.gov/data-api/api)\n- Public API — no authentication or API keys required\n- Retry with exponential backoff (3 attempts) and rate limiting (~1 req/sec)\n- HTML error detection and structured error factories\n\n## Getting Started\n\n### Public Hosted Instance\n\nA public instance is available at `https://clinicaltrials.caseyjhand.com/mcp` — no installation required. Point any MCP client at it via Streamable HTTP:\n\n```json\n{\n  \"mcpServers\": {\n    \"clinicaltrialsgov-mcp-server\": {\n      \"type\": \"streamable-http\",\n      \"url\": \"https://clinicaltrials.caseyjhand.com/mcp\"\n    }\n  }\n}\n```\n\n### Self-Hosted / Local\n\nAdd to your MCP client config (e.g., `claude_desktop_config.json`):\n\n```json\n{\n  \"mcpServers\": {\n    \"clinicaltrialsgov-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"bunx\",\n      \"args\": [\"clinicaltrialsgov-mcp-server@latest\"],\n      \"env\": {\n        \"MCP_TRANSPORT_TYPE\": \"stdio\"\n      }\n    }\n  }\n}\n```\n\nOr for Streamable HTTP:\n\n```sh\nMCP_TRANSPORT_TYPE=http\nMCP_HTTP_PORT=3010\n```\n\n### Prerequisites\n\n- [Bun v1.3.0](https://bun.sh/) or higher (or Node.js >= 24.0.0)\n\n### Installation\n\n1. **Clone the repository:**\n\n   ```sh\n   git clone https://github.com/cyanheads/clinicaltrialsgov-mcp-server.git\n   ```\n\n2. **Navigate into the directory:**\n\n   ```sh\n   cd clinicaltrialsgov-mcp-server\n   ```\n\n3. **Install dependencies:**\n   ```sh\n   bun install\n   ```\n\n## Configuration\n\nAll configuration is optional — the server works with defaults and no API keys.\n\n| Variable                     | Description                                 | Default                             |\n| :--------------------------- | :------------------------------------------ | :---------------------------------- |\n| `CT_API_BASE_URL`            | ClinicalTrials.gov API base URL.            | `https://clinicaltrials.gov/api/v2` |\n| `CT_REQUEST_TIMEOUT_MS`      | Per-request timeout in milliseconds.        | `30000`                             |\n| `CT_MAX_PAGE_SIZE`           | Maximum page size cap.                      | `200`                               |\n| `MCP_TRANSPORT_TYPE`         | Transport: `stdio` or `http`.               | `stdio`                             |\n| `MCP_HTTP_PORT`              | Port for HTTP server.                       | `3010`                              |\n| `MCP_AUTH_MODE`              | Auth mode: `none`, `jwt`, or `oauth`.       | `none`                              |\n| `MCP_LOG_LEVEL`              | Log level (RFC 5424).                       | `info`                              |\n| `LOGS_DIR`                   | Directory for log files (Node.js only).     | `<project-root>/logs`               |\n| `OTEL_ENABLED`               | Enable OpenTelemetry tracing.               | `false`                             |\n\n## Running the Server\n\n### Local Development\n\n- **Build and run the production version:**\n\n  ```sh\n  bun run build\n  bun run start:http   # or start:stdio\n  ```\n\n- **Run checks and tests:**\n  ```sh\n  bun run devcheck     # Lints, formats, type-checks\n  bun run test         # Runs test suite\n  ```\n\n### Docker\n\n```sh\ndocker build -t clinicaltrialsgov-mcp-server .\ndocker run -p 3010:3010 clinicaltrialsgov-mcp-server\n```\n\n## Project Structure\n\n| Directory                       | Purpose                                               |\n| :------------------------------ | :---------------------------------------------------- |\n| `src/mcp-server/tools/`         | Tool definitions (`*.tool.ts`).                       |\n| `src/mcp-server/resources/`     | Resource definitions (`*.resource.ts`).               |\n| `src/mcp-server/prompts/`       | Prompt definitions (`*.prompt.ts`).                   |\n| `src/services/clinical-trials/` | ClinicalTrials.gov API client and types.              |\n| `src/config/`                   | Environment variable parsing and validation with Zod. |\n| `tests/`                        | Unit and integration tests.                           |\n\n## Development Guide\n\nSee [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:\n\n- Handlers throw, framework catches — no `try/catch` in tool logic\n- Use `ctx.log` for request-scoped logging, no `console` calls\n- Register new tools and resources in the `index.ts` barrel files\n\n## Contributing\n\nIssues and pull requests are welcome. Run checks before submitting:\n\n```sh\nbun run devcheck\nbun run test\n```\n\n## License\n\nApache-2.0 — see [LICENSE](LICENSE) for details.\n",
  "bytes": 11743,
  "sha": "f966b6d2ad07953ba73631bc2884a694042ea55cea9da3917c189143c1f42775",
  "repo_slug": "cyanheads/clinicaltrialsgov-mcp-server",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_cyanheads_clinicaltrialsgov_mc_c67c6842/readme"
}