search-wikipedia
Search Japanese Wikipedia to retrieve article summaries using keywords. This tool provides concise information from Wikipedia's Japanese content for quick reference.
Instructions
日本語Wikipediaでキーワードを検索し、記事の要約を返すツール
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | 検索キーワード(例: 東京タワー) |
Implementation Reference
- src/index.ts:52-83 (handler)Registration and implementation of the 'search-wikipedia' tool, including input validation schema and fetch logic to Wikipedia API.
server.registerTool( "search-wikipedia", { description: "日本語Wikipediaでキーワードを検索し、記事の要約を返すツール", inputSchema: { query: z.string().describe("検索キーワード(例: 東京タワー)"), }, }, async ({ query }) => { const url = `https://ja.wikipedia.org/api/rest_v1/page/summary/${encodeURIComponent(query)}`; const res = await fetch(url); if (!res.ok) { return { content: [ { type: "text", text: `「${query}」に該当する記事が見つかりませんでした。`, }, ], }; } const data = await res.json(); return { content: [ { type: "text", text: `【${data.title}】\n${data.extract}\n\nURL: ${data.content_urls?.desktop?.page ?? "N/A"}`, }, ], }; }, );