search_by_location
Find clinical trials by geographic location using country, state, city, or facility name to identify nearby research studies for patient participation or medical research.
Instructions
Find clinical trials by geographic location
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| country | No | Country name | |
| state | No | State or province | |
| city | No | City name | |
| facilityName | No | Name of medical facility or institution | |
| distance | No | Search radius in miles (when using city) | |
| pageSize | No | Number of results to return (default 10, max 100) |
Implementation Reference
- src/index.ts:942-1011 (handler)Implementation of the handleSearchByLocation tool handler.
private async handleSearchByLocation(args: any) { const params: any = { format: "json", pageSize: args?.pageSize || 10, }; // Build location query let locationQuery = ""; if (args?.country) locationQuery += args.country; if (args?.state) locationQuery += (locationQuery ? ", " : "") + args.state; if (args?.city) locationQuery += (locationQuery ? ", " : "") + args.city; if (args?.facilityName) locationQuery += (locationQuery ? ", " : "") + args.facilityName; if (locationQuery) { params["query.locn"] = locationQuery; } if (args?.distance && args?.city) { params["filter.distance"] = args.distance; } try { const response: AxiosResponse<StudySearchResponse> = await this.axiosInstance.get("/studies", { params }); const studies = response.data.studies || []; const results = studies.map((study) => ({ ...this.formatStudySummary(study), locations: study.protocolSection.contactsLocationsModule?.locations?.slice( 0, 3 ) || [], })); return { content: [ { type: "text", text: JSON.stringify( { searchCriteria: { locationQuery, distance: args?.distance }, totalCount: response.data.totalCount || 0, resultsShown: results.length, studies: results, }, null, 2 ), }, ], }; } catch (error) { if (axios.isAxiosError(error)) { return { content: [ { type: "text", text: `Clinical Trials API error: ${ error.response?.data?.message || error.message }`, }, ], isError: true, }; } throw error; } } - src/index.ts:202-238 (registration)Definition/registration of the search_by_location tool.
name: "search_by_location", description: "Find clinical trials by geographic location", inputSchema: { type: "object", properties: { country: { type: "string", description: "Country name", }, state: { type: "string", description: "State or province", }, city: { type: "string", description: "City name", }, facilityName: { type: "string", description: "Name of medical facility or institution", }, distance: { type: "number", description: "Search radius in miles (when using city)", minimum: 1, maximum: 500, }, pageSize: { type: "number", description: "Number of results to return (default 10, max 100)", minimum: 1, maximum: 100, }, }, }, },