Skip to main content
Glama
BACH-AI-Tools

Clinical Trials MCP Server

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
NameRequiredDescriptionDefault
countryNoCountry name
stateNoState or province
cityNoCity name
facilityNameNoName of medical facility or institution
distanceNoSearch radius in miles (when using city)
pageSizeNoNumber of results to return (default 10, max 100)

Implementation Reference

  • 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,
          },
        },
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral information. It doesn't disclose whether this is a read-only operation, what authentication might be required, rate limits, pagination behavior (beyond the pageSize parameter), or what format results will be returned in. 'Find' implies a search/read operation but lacks specifics about system behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's appropriately sized for a search tool and front-loads the essential information. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with 6 parameters and no output schema, the description is insufficient. It doesn't explain what results look like, how pagination works (despite having a pageSize parameter), or any constraints on geographic searching. With no annotations and no output schema, the agent lacks crucial information about system behavior and response format.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 6 parameters. The description adds no parameter-specific information beyond what's in the schema. The baseline score of 3 reflects adequate parameter documentation coming entirely from the schema rather than the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Find' and resource 'clinical trials' with the geographic location constraint. It distinguishes itself from many sibling tools that search by other criteria (condition, intervention, date range, etc.), but doesn't explicitly contrast with 'search_international_studies' or 'search_studies' which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'search_studies' or 'search_international_studies'. It doesn't mention prerequisites, limitations, or typical use cases. The agent must infer usage from the name and description alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/BACH-AI-Tools/ClinicalTrials-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server