feat(wikipedia): 위키백과 읽기 서비스 (검색·요약·본문·링크)#28
Merged
Merged
Conversation
위키백과(Wikipedia) 읽기 래퍼 — 무인증으로 전체 읽기가 동작하되 Wikimedia가
요구하는 식별용 User-Agent 헤더를 항상 전송하고(WIKIPEDIA_USER_AGENT로 덮어씀),
(선택) WIKIPEDIA_API_TOKEN Bearer로 레이트리밋을 완화한다. 4개 GET 도구:
- wikipedia_search: per-wiki 클린 REST /w/rest.php/v1/search/page (구식 list=search 아님)
- wikipedia_summary: rest_v1 /api/rest_v1/page/summary/{title} — lead extract +
Wikidata Q-id(wikibase_item)·좌표·동음이의 안내 (path segment 인코딩, 리다이렉트 자동 추적)
- wikipedia_extract: Action API TextExtracts(prop=extracts·explaintext·exintro·exchars)
- wikipedia_links: Action API prop=links|categories(plnamespace=0)
언어판마다 호스트가 다르므로 lang으로 base(https://{lang}.wikipedia.org)를 만들고
형식 검증(소문자+하이픈 변형)으로 호스트 오염을 막는다. Action API는 formatversion=2로
query.pages를 깨끗한 배열로 받고 redirects=1로 리다이렉트를 추적한다.
⚠️ Action API는 잘못된 파라미터에 HTTP 200 + {"error":{code,info}}를 줄 수 있어
본문을 보고 error.info로 매핑한다(403 User-Agent·404 not found·429 스로틀도 매핑).
⚠️ deprecating(2026-07) api.wikimedia.org/core/v1/* 회피 — Action API + per-wiki REST + rest_v1 앵커.
4개 엔드포인트·응답 필드(REST 검색 total 부재·formatversion=2 배열·missing·요약
wikibase_item/coordinates·Action 200+error 봉투)를 라이브(en.wikipedia.org)에서 직접 확인.
테스트 2종(계약 20 + 도구 25 = mock, 네트워크 없음) 전체 통과, ruff 통과.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ArcSolver
added a commit
that referenced
this pull request
Jun 4, 2026
위키백과(Wikipedia) 읽기 래퍼 — 무인증으로 전체 읽기가 동작하되 Wikimedia가
요구하는 식별용 User-Agent 헤더를 항상 전송하고(WIKIPEDIA_USER_AGENT로 덮어씀),
(선택) WIKIPEDIA_API_TOKEN Bearer로 레이트리밋을 완화한다. 4개 GET 도구:
- wikipedia_search: per-wiki 클린 REST /w/rest.php/v1/search/page (구식 list=search 아님)
- wikipedia_summary: rest_v1 /api/rest_v1/page/summary/{title} — lead extract +
Wikidata Q-id(wikibase_item)·좌표·동음이의 안내 (path segment 인코딩, 리다이렉트 자동 추적)
- wikipedia_extract: Action API TextExtracts(prop=extracts·explaintext·exintro·exchars)
- wikipedia_links: Action API prop=links|categories(plnamespace=0)
언어판마다 호스트가 다르므로 lang으로 base(https://{lang}.wikipedia.org)를 만들고
형식 검증(소문자+하이픈 변형)으로 호스트 오염을 막는다. Action API는 formatversion=2로
query.pages를 깨끗한 배열로 받고 redirects=1로 리다이렉트를 추적한다.
⚠️ Action API는 잘못된 파라미터에 HTTP 200 + {"error":{code,info}}를 줄 수 있어
본문을 보고 error.info로 매핑한다(403 User-Agent·404 not found·429 스로틀도 매핑).
⚠️ deprecating(2026-07) api.wikimedia.org/core/v1/* 회피 — Action API + per-wiki REST + rest_v1 앵커.
4개 엔드포인트·응답 필드(REST 검색 total 부재·formatversion=2 배열·missing·요약
wikibase_item/coordinates·Action 200+error 봉투)를 라이브(en.wikipedia.org)에서 직접 확인.
테스트 2종(계약 20 + 도구 25 = mock, 네트워크 없음) 전체 통과, ruff 통과.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
무엇을
무인증·무료 공개 API인 Wikipedia(MediaWiki) 를 감싼 읽기 전용 MCP 서비스. 커뮤니티 수요 조사 결과 "사실 조회/검색"이 공개-API 래퍼 중 가장 반복되는 수요였고, 무료 API를 감싼 벤더 공식 MCP는 부재(Wikimedia Enterprise MCP은 유료 상업 제품)라 빈틈으로 확인됨.
도구 4종 (전부 GET·읽기)
wikipedia_search(query, lang, limit)— REST/w/rest.php/v1/search/pagewikipedia_summary(title, lang)—/api/rest_v1/page/summary/{title}(요약·썸네일 +wikibase_item=Wikidata 브리지·좌표)wikipedia_extract(title, lang, intro_only, max_chars)— Action APIprop=extracts평문(formatversion=2)wikipedia_links(title, lang, limit)— 연결 문서·분류설계 노트
api.wikimedia.org/core/v1/*(2026-07 폐기 시작·후속 미정)는 미사용 — 비폐기 경로(Action APIformatversion=2+ per-wiki REST +rest_v1)에 앵커.DEFAULT_USER_AGENT상수 +WIKIPEDIA_USER_AGENTenv). 키 선택(WIKIPEDIA_API_TOKENBearer = 레이트 완화, 없어도 전체 읽기 동작).{"error":{code,info}}봉투 별도 처리,formatversion=2배열 형태·redirects=1정규화, 제목quote(safe="")인코딩.get_json재사용).검증
formatversion=2배열·200+error 봉투·제목 인코딩·lang 검증(SSRF 차단)·에러 매핑 전부 확인 → SHIP. 미매핑 상태코드의 raw 본문 노출 NIT 1건은 본 PR에서 하드닝 반영.🤖 Generated with Claude Code