Skip to main content
Glama
TeeDDub

Aladin Book Search MCP Server

by TeeDDub

카테고리 검색

search_categories

Search for book categories using Aladin's database, prioritizing top-level categories. Specify a term and define the number of results for accurate category discovery.

Instructions

알라딘 도서 카테고리를 검색합니다. 상위 레벨 카테고리를 우선으로 표시합니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
maxResultsNo최대 결과 개수
searchTermYes검색할 카테고리 이름

Implementation Reference

  • Core implementation of the category search logic. Traverses the category tree recursively, matches search term case-insensitively, prioritizes lower levels, and returns formatted CategoryInfo with full path.
    function searchCategories(searchTerm: string, data: any): CategoryInfo[] {
      const results: Array<CategoryInfo & { level: number; fullPath: string }> = [];
      
      function traverse(node: CategoryNode, path: string[] = [], currentLevel: number = 1) {
        // 현재 노드의 카테고리 정보 확인
        if (node.categories) {
          for (const category of node.categories) {
            if (category.name.toLowerCase().includes(searchTerm.toLowerCase())) {
              results.push({
                ...category,
                level: currentLevel,
                fullPath: `${path.join(' > ')} > ${category.name}`,
                name: category.name // 원본 이름 유지
              });
            }
          }
        }
        
        // 자식 노드 순회
        if (node.children) {
          for (const [childName, childNode] of Object.entries(node.children)) {
            traverse(childNode, [...path, childName], currentLevel + 1);
          }
        }
      }
      
      for (const [rootName, rootNode] of Object.entries(data)) {
        traverse(rootNode as CategoryNode, [rootName]);
      }
      
      // 레벨별로 정렬 (level 1이 가장 우선, 같은 레벨에서는 이름순)
      results.sort((a, b) => {
        if (a.level !== b.level) {
          return a.level - b.level;
        }
        return a.name.localeCompare(b.name);
      });
      
      // 결과 반환 시 fullPath를 name으로 설정
      return results.map(result => ({
        cid: result.cid,
        name: result.fullPath,
        mall: result.mall
      }));
    }
  • src/index.ts:672-736 (registration)
    MCP tool registration for 'search_categories'. Defines title, description, Zod input schema, and async handler that uses the searchCategories function to process input and return formatted results.
    server.registerTool(
      'search_categories',
      {
        title: '카테고리 검색',
        description: '알라딘 도서 카테고리를 검색합니다. 상위 레벨 카테고리를 우선으로 표시합니다.',
        inputSchema: {
          searchTerm: z.string().describe('검색할 카테고리 이름'),
          maxResults: z.number().min(1).max(50).default(20).describe('최대 결과 개수')
        }
      },
      async ({ searchTerm, maxResults }) => {
        try {
          const allCategories = searchCategories(searchTerm, categoryData);
          const categories = allCategories.slice(0, maxResults);
          
          if (categories.length === 0) {
            return {
              content: [{
                type: 'text',
                text: `'${searchTerm}'과 관련된 카테고리를 찾을 수 없습니다.`
              }]
            };
          }
          
          // 레벨별로 그룹화
          const levelGroups: { [level: string]: any[] } = {};
          categories.forEach(cat => {
            const level = cat.name.split(' > ').length - 1;
            if (!levelGroups[level]) {
              levelGroups[level] = [];
            }
            levelGroups[level].push(cat);
          });
          
          let resultText = `'${searchTerm}' 검색 결과 (${categories.length}개${allCategories.length > maxResults ? `, 총 ${allCategories.length}개 중 상위 ${maxResults}개 표시` : ''}):\n\n`;
          
          // 레벨별로 표시
          Object.keys(levelGroups).sort((a, b) => Number(a) - Number(b)).forEach(level => {
            const levelName = level === '1' ? '대분류' : level === '2' ? '중분류' : '소분류';
            resultText += `📚 ${levelName} (Level ${level}):\n`;
            levelGroups[level].forEach((cat, index) => {
              resultText += `${index + 1}. ${cat.name}\n`;
              resultText += `   CID: ${cat.cid} | 몰: ${cat.mall}\n`;
            });
            resultText += '\n';
          });
          
          return {
            content: [{
              type: 'text',
              text: resultText
            }]
          };
        } catch (error) {
          logger.error(`카테고리 검색 중 오류 발생: ${error}`);
          return {
            content: [{
              type: 'text',
              text: `카테고리 검색 중 오류가 발생했습니다: ${error instanceof Error ? error.message : String(error)}`
            }],
            isError: true
          };
        }
      }
    );
  • TypeScript interface defining the structure of category information returned by the search function.
    interface CategoryInfo {
      cid: string;
      name: string;
      mall: string;
    }
  • Zod input schema validation for the tool parameters: searchTerm (string) and maxResults (number with constraints).
    inputSchema: {
      searchTerm: z.string().describe('검색할 카테고리 이름'),
      maxResults: z.number().min(1).max(50).default(20).describe('최대 결과 개수')
    }
  • Usage of searchCategories function within the 'get_popular_categories' tool to find categories for popular terms.
    const categories = searchCategories(popular.searchTerm, categoryData);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions the prioritization of higher-level categories, which is useful context, but fails to describe important behaviors like whether this is a read-only operation, what the return format looks like, whether results are paginated, or any rate limits. For a search tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - just two sentences that directly state the tool's function and a key behavioral characteristic. Every word serves a purpose with zero redundancy or unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a search tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what the search results look like, how they're structured, whether there's pagination, or what happens when no matches are found. The prioritization hint is helpful but doesn't compensate for missing behavioral and output context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents both parameters. The description adds no additional parameter information beyond what's in the schema. The baseline score of 3 reflects adequate parameter documentation solely through the schema, with no value added by the description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('search') and resource ('Aladin book categories'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_popular_categories' or 'search_books', which would require more specific scope definition.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance - it mentions that higher-level categories are prioritized, but offers no explicit when-to-use advice, no exclusions, and no comparison to alternatives like 'get_popular_categories' or 'search_books'. The agent must infer usage context from the tool name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related 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/TeeDDub/mcp-aladin-books-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server