search_nasa_images
Search NASA’s image, video, and audio library for space-related media. Specify search queries, media types, and page numbers to find and explore space content directly from NASA’s database.
Instructions
NASA 이미지 및 비디오 라이브러리에서 검색합니다
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| media_type | No | 미디어 타입 | image |
| page | No | 페이지 번호 | |
| q | Yes | 검색 쿼리 |
Implementation Reference
- server/index.js:317-353 (handler)The main handler function that executes the tool logic: destructures args, fetches from NASA images API, handles errors, limits results to 10, and returns formatted text content with search results.async searchNASAImages(args) { const { q, media_type = 'image', page = 1 } = args; const params = new URLSearchParams({ q, media_type, page: page.toString(), }); const response = await fetch(`https://images-api.nasa.gov/search?${params}`); const data = await response.json(); if (!response.ok) { throw new Error(`NASA Images API 오류: ${data.reason || '알 수 없는 오류'}`); } const items = data.collection.items.slice(0, 10); // 최대 10개 결과만 반환 return { content: [ { type: 'text', text: `**NASA 이미지 검색 결과** - "${q}" 총 ${data.collection.metadata.total_hits}개의 결과를 찾았습니다. 처음 ${items.length}개를 보여드립니다: ${items.map((item, index) => ` ${index + 1}. **${item.data[0].title}** - **설명**: ${item.data[0].description || '설명 없음'} - **날짜**: ${item.data[0].date_created} - **미디어 타입**: ${item.data[0].media_type} - **이미지 URL**: ${item.links?.[0]?.href || '이미지 없음'} - **NASA ID**: ${item.data[0].nasa_id} `).join('')}`, }, ], }; }
- server/index.js:105-125 (schema)Input schema definition for the tool, specifying required 'q' parameter and optional media_type and page.inputSchema: { type: 'object', properties: { q: { type: 'string', description: '검색 쿼리', }, media_type: { type: 'string', enum: ['image', 'video', 'audio'], description: '미디어 타입', default: 'image', }, page: { type: 'number', description: '페이지 번호', default: 1, }, }, required: ['q'], },
- server/index.js:102-126 (registration)Tool registration in the ListToolsRequestSchema handler, including name, description, and input schema.{ name: 'search_nasa_images', description: 'NASA 이미지 및 비디오 라이브러리에서 검색합니다', inputSchema: { type: 'object', properties: { q: { type: 'string', description: '검색 쿼리', }, media_type: { type: 'string', enum: ['image', 'video', 'audio'], description: '미디어 타입', default: 'image', }, page: { type: 'number', description: '페이지 번호', default: 1, }, }, required: ['q'], }, },
- server/index.js:169-170 (registration)Dispatch registration in the CallToolRequestSchema switch statement, mapping the tool name to its handler method.case 'search_nasa_images': return await this.searchNASAImages(args);