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, }, ], }; }
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