Skip to main content
Glama
antegral
by antegral

search_drugs_by_name

Search for pharmaceutical drugs by name using the Korea Pharmaceutical Information Center database to retrieve basic drug information and identify similar medications.

Instructions

약학정보원에서 의약품 이름으로 대략적인 정보들을 가져옵니다. 이름이 유사한 의약품 여러개가 나올 수 있습니다. 더 자세한 정보가 필요하다면 get_drug_detail_by_id()로 조회해야 합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
drugnameYes검색할 의약품의 이름 (영문 또는 한글)

Implementation Reference

  • Core handler function that fetches drug search results from the KPIC API using fetch, validates and formats the JSON response.
    export async function search_drugs_by_name(drugname: string): Promise<string> {
      if (!drugname || drugname.trim().length === 0) {
        throw new KPICApiError('Drug name cannot be empty');
      }
    
      const now = Date.now();
      const url = `https://www.health.kr/searchDrug/ajax/ajax_commonSearch.asp?search_word=${encodeURIComponent(drugname)}&search_flag=all&_=${now}`;
    
      try {
        const response = await fetch(url, {
          method: 'GET',
          headers: {
            accept: 'application/json, text/javascript, */*; q=0.01',
            'accept-language': 'ko,en-US;q=0.9,en;q=0.8,ru;q=0.7',
            'x-requested-with': 'XMLHttpRequest',
            Referer: 'https://www.health.kr/searchDrug/search_total_result.asp',
          },
        });
    
        if (!response.ok) {
          throw new KPICApiError(`API request failed: ${response.statusText}`, response.status);
        }
    
        const data = await response.text();
    
        // 응답 데이터 검증
        try {
          const parsed = JSON.parse(data) as DrugSearchResult[];
    
          if (!Array.isArray(parsed)) {
            throw new KPICApiError('Invalid response format: expected array');
          }
    
          // 결과를 보기 좋게 포맷팅하여 반환
          return JSON.stringify(parsed, null, 2);
        } catch (parseError) {
          if (parseError instanceof KPICApiError) {
            throw parseError;
          }
          throw new KPICApiError(
            `Failed to parse API response: ${parseError instanceof Error ? parseError.message : 'Unknown error'}`,
          );
        }
      } catch (error) {
        if (error instanceof KPICApiError) {
          throw error;
        }
    
        if (error instanceof Error) {
          throw new KPICApiError(`Network error: ${error.message}`);
        }
    
        throw new KPICApiError('Unknown error occurred');
      }
    }
  • src/index.ts:22-38 (registration)
    Tool registration in the TOOLS array, including name, description, and input schema definition.
    {
      name: 'search_drugs_by_name',
      description:
        '약학정보원에서 의약품 이름으로 대략적인 정보들을 가져옵니다. ' +
        '이름이 유사한 의약품 여러개가 나올 수 있습니다. ' +
        '더 자세한 정보가 필요하다면 get_drug_detail_by_id()로 조회해야 합니다.',
      inputSchema: {
        type: 'object',
        properties: {
          drugname: {
            type: 'string',
            description: '검색할 의약품의 이름 (영문 또는 한글)',
          },
        },
        required: ['drugname'],
      },
    },
  • TypeScript interface defining the structure of drug search results returned by the tool.
    export interface DrugSearchResult {
      pack_img: string;
      drug_pic: string;
      drug_name: string;
      drug_enm: string;
      drug_code: string;
      sunb_count: number;
      list_sunb_name: string;
      ingr_mg: string;
      dosage: string;
      effect: string;
      upso_name_kfda: string;
      cls_code: string;
      drug_form: string;
      drug_class: string;
      etc: string;
      produce: string;
      boh_price: string;
      total_cnt: number;
      kfda_code: string;
      confirm_flag: string;
    }
  • MCP server dispatcher case that validates input and calls the search_drugs_by_name handler.
    case 'search_drugs_by_name': {
      const { drugname } = args as { drugname: string };
      
      if (!drugname) {
        throw new Error('drugname parameter is required');
      }
    
      const result = await search_drugs_by_name(drugname);
      
      return {
        content: [
          {
            type: 'text',
            text: result,
          },
        ],
      };
    }
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It usefully adds that '이름이 유사한 의약품 여러개가 나올 수 있습니다' (multiple drugs with similar names may appear), which is important behavioral context about fuzzy matching. However, it doesn't disclose other behavioral traits like rate limits, authentication needs, error conditions, or what '대략적인 정보' (approximate information) specifically entails.

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

Conciseness4/5

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

The description is appropriately concise with two sentences that each serve a clear purpose: the first states the tool's function, and the second provides important behavioral context and alternative guidance. It's front-loaded with the core purpose and wastes no words, though it could be slightly more structured.

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

Completeness3/5

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

For a single-parameter search tool with no annotations and no output schema, the description provides adequate but incomplete context. It covers the purpose, behavioral nuance about fuzzy matching, and alternative tool, but doesn't explain what information is returned or any limitations. Given the complexity is low (one parameter), it's minimally viable but could better address output expectations.

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?

The schema description coverage is 100%, with the single parameter 'drugname' well-documented in the schema as '검색할 의약품의 이름 (영문 또는 한글)' (drug name to search, English or Korean). The description doesn't add any parameter-specific information beyond what the schema provides, so it meets the baseline of 3 for high schema coverage.

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 tool's purpose: '약학정보원에서 의약품 이름으로 대략적인 정보들을 가져옵니다' (retrieves approximate drug information by name from the Pharmaceutical Information Center). It specifies the action (retrieve), resource (drug information), and source (Pharmaceutical Information Center). However, it doesn't explicitly differentiate from its sibling tool beyond mentioning it as an alternative for detailed information.

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

Usage Guidelines4/5

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

The description provides clear context for usage: it's for approximate information retrieval by drug name, with the note that similar-named drugs may appear. It explicitly mentions the alternative tool 'get_drug_detail_by_id()' for detailed information, giving good guidance on when to use each. However, it doesn't specify when NOT to use this tool or any prerequisites.

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/antegral/kpic-mcp'

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