Skip to main content
Glama
antegral
by antegral

get_drug_detail_by_id

Retrieve comprehensive pharmaceutical details using a drug code from the Korea Pharmaceutical Information Center. Access ingredients, usage instructions, precautions, and storage information for specific medications.

Instructions

약학정보원의 의약품 코드로 의약품의 상세정보를 가져옵니다. search_drugs_by_name()로 조회한 정보가 부족할 때 사용할 수 있습니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
drugcodeYessearch_drugs_by_name()의 결과 값에 기재된 의약품의 drug_code 값

Implementation Reference

  • Core handler function that performs the API fetch to KPIC for drug details by ID, parses the response, validates it, and returns formatted JSON string.
    export async function get_drug_detail_by_id(drugcode: string): Promise<string> {
      if (!drugcode || drugcode.trim().length === 0) {
        throw new KPICApiError('Drug code cannot be empty');
      }
    
      const now = Date.now();
      const url = `https://www.health.kr/searchDrug/ajax/ajax_result_drug2.asp?drug_cd=${encodeURIComponent(drugcode)}&_=${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',
            'cache-control': 'no-cache',
            pragma: 'no-cache',
            Referer: `https://www.health.kr/searchDrug/result_drug.asp?drug_cd=${encodeURIComponent(drugcode)}`,
          },
        });
    
        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 DrugDetailResult[];
    
          if (!Array.isArray(parsed)) {
            throw new KPICApiError('Invalid response format: expected array');
          }
    
          if (parsed.length === 0) {
            throw new KPICApiError(`No drug found with code: ${drugcode}`);
          }
    
          // 결과를 보기 좋게 포맷팅하여 반환
          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:39-54 (registration)
    MCP tool registration defining the tool name, description, and input schema for get_drug_detail_by_id.
    {
      name: 'get_drug_detail_by_id',
      description:
        '약학정보원의 의약품 코드로 의약품의 상세정보를 가져옵니다. ' +
        'search_drugs_by_name()로 조회한 정보가 부족할 때 사용할 수 있습니다.',
      inputSchema: {
        type: 'object',
        properties: {
          drugcode: {
            type: 'string',
            description: 'search_drugs_by_name()의 결과 값에 기재된 의약품의 drug_code 값',
          },
        },
        required: ['drugcode'],
      },
    },
  • TypeScript interface defining the structure of the drug detail result used by the get_drug_detail_by_id handler for type safety.
     * 약품 상세 정보 타입 (get_drug_detail_by_id)
     */
    export interface DrugDetailResult {
      idx: number;
      drug_code: string;
      drug_name: string;
      drug_enm: string;
      noins: string | null;
      narcotic_kind_code: string;
      list_sunb_name: string;
      cls_code_num: string;
      sunb: string;
      drug_cls: string;
      sunb_count: number;
      upso_name: string;
      upso1: string;
      drug_form: string;
      dosage_route: string;
      charact: string;
      charact_new: string;
      cls_code: string;
      atc_cd: string;
      boh_history: string;
      boh_hiracode: string;
      item_permit_date: string;
      cancel_date: string;
      newdrug_class_code: string;
      bioeq_prodt_yn: string;
      comp_drug_yn_biology: string;
      comp_drug_yn_effect: string;
      comp_drug_yn: string;
      comp_drug_yn_physicochemical: string;
      kpic_atc: string;
      kpic_atc_cd: string;
      insertpaper: string;
      paper_dt: string;
      dur_age: string;
      dur_contra: string;
      dur_preg: string;
      dur_senior: string;
      dur_dose: string;
      dur_period: string;
      dur_donate: string;
      dur_form: string;
      fdacode: string;
      fdacontent: string;
      sunbcontent: string;
      drug_box: string;
      stmt: string;
      drug_pic: string;
      pack_img: string;
      picto_img: string;
      medititle: string;
      mediguide: string;
      effect: string;
      dosage: string;
      caution: string;
      idfylength: string;
      boh: string;
      etc: string;
      idfyidx: number;
      reexam: string | null;
      reexam_start_date: string;
      reexam_end_date: string;
      item_ingr_type: string;
      additives: string;
    }
  • MCP request handler dispatch case that extracts arguments, validates input, calls the core handler, and formats the MCP response.
    case 'get_drug_detail_by_id': {
      const { drugcode } = args as { drugcode: string };
      
      if (!drugcode) {
        throw new Error('drugcode parameter is required');
      }
    
      const result = await get_drug_detail_by_id(drugcode);
      
      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 indicates this is a read operation (fetching information) but doesn't specify authentication requirements, rate limits, error conditions, or what constitutes 'detailed information' beyond what search_drugs_by_name provides. The description adds some context about the data source but lacks comprehensive behavioral details.

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 consists of just two sentences that are perfectly front-loaded and efficient. The first sentence establishes the core purpose, and the second provides crucial usage guidance. Every word earns its place with no redundancy or unnecessary elaboration.

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 read tool with no annotations and no output schema, the description provides adequate purpose and usage guidance but lacks details about what 'detailed information' includes, error handling, or response format. The description compensates somewhat by linking to the sibling tool, but more behavioral context would be helpful given the absence of structured metadata.

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

Parameters4/5

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

With 100% schema description coverage, the schema already fully documents the single parameter. The description adds valuable context by explaining the relationship between this parameter and the sibling tool: 'search_drugs_by_name()의 결과 값에 기재된 의약품의 drug_code 값' (drug_code value from search_drugs_by_name() results). This provides practical guidance on parameter sourcing beyond what the schema alone offers.

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

Purpose5/5

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

The description clearly states the specific action ('가져옵니다' - fetches/retrieves), resource ('의약품의 상세정보' - detailed drug information), and source ('약학정보원의 의약품 코드로' - using drug code from Pharmaceutical Information Service). It explicitly distinguishes from its sibling tool search_drugs_by_name by mentioning when this tool should be used instead.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool versus alternatives: 'search_drugs_by_name()로 조회한 정보가 부족할 때 사용할 수 있습니다' (can be used when information retrieved from search_drugs_by_name() is insufficient). This clearly establishes the relationship between the two tools and provides specific context for tool selection.

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