kipris_get_patent_detail
Retrieve detailed Korean patent information by application number using the KIPRIS API. Get comprehensive patent data in markdown or JSON format for analysis and research purposes.
Instructions
출원번호로 특허의 상세 정보를 조회합니다.
Args:
application_number: 출원번호 (필수, 예: '1020200123456')
response_format: 응답 형식 ('markdown' 또는 'json')
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| application_number | Yes | ||
| response_format | No | markdown |
Implementation Reference
- src/korean_patent_mcp/server.py:207-239 (handler)The primary MCP tool handler function for 'kipris_get_patent_detail'. It handles input parameters, initializes the KiprisAPIClient if necessary, calls the API client's get_patent_detail method, and formats the output as Markdown or JSON.@mcp.tool(name="kipris_get_patent_detail") async def kipris_get_patent_detail( application_number: str, response_format: str = "markdown" ) -> str: """출원번호로 특허의 상세 정보를 조회합니다. Args: application_number: 출원번호 (필수, 예: '1020200123456') response_format: 응답 형식 ('markdown' 또는 'json') """ # Get API key from session config or environment api_key = get_config_value("kiprisApiKey") or os.getenv("KIPRIS_API_KEY", "") if api_key: init_client_with_key(api_key) client = get_kipris_client() if client is None: return f"❌ 오류: {get_init_error() or 'API 클라이언트 초기화 실패'}" app_num = application_number.replace("-", "") try: result = await client.get_patent_detail(app_num) if result is None: return f"❌ 출원번호 `{application_number}`에 해당하는 특허를 찾을 수 없습니다." if response_format == "json": return json.dumps(result, ensure_ascii=False, indent=2) return format_patent_markdown(result, detailed=True) except Exception as e: return f"❌ 조회 오류: {str(e)}"
- The core helper method in KiprisAPIClient that performs the actual HTTP request to the KIPRIS API for patent details, parses the XML response, and extracts the detailed patent information using _parse_patent_info.async def get_patent_detail( self, application_number: str ) -> Optional[Dict[str, Any]]: """ 출원번호로 특허 상세 정보 조회 Args: application_number: 출원번호 (예: "1020200123456") Returns: 특허 상세 정보 딕셔너리 """ params = { "applicationNumber": application_number, "docsStart": "1" } root = await self._make_request( self.ENDPOINTS["patent_info"], params ) if root is None: return None item = root.find(".//PatentUtilityInfo") if item is None: return None return self._parse_patent_info(item, detailed=True)
- Helper function to format the patent detail data into a readable Markdown string, used by the tool handler when response_format is 'markdown'.def format_patent_markdown(patent: dict, detailed: bool = False) -> str: lines = [] lines.append(f"### {patent.get('title', '제목 없음')}") lines.append("") lines.append(f"- **출원번호**: {patent.get('application_number', '-')}") lines.append(f"- **출원일**: {patent.get('application_date', '-')}") lines.append(f"- **출원인**: {patent.get('applicant', '-')}") lines.append(f"- **등록상태**: {patent.get('registration_status', '-')}") if patent.get('opening_number'): lines.append(f"- **공개번호**: {patent.get('opening_number')} ({patent.get('opening_date', '-')})") if patent.get('registration_number'): lines.append(f"- **등록번호**: {patent.get('registration_number')} ({patent.get('registration_date', '-')})") if detailed: if patent.get('ipc_number'): lines.append(f"- **IPC 분류**: {patent.get('ipc_number')}") if patent.get('abstract'): lines.append("") lines.append("**초록**:") lines.append(f"> {patent.get('abstract')[:500]}...") return "\n".join(lines)