search_names
Search Pokémon and moves using substring queries to find specific creatures or attacks in the Pokémon database.
Instructions
Búsqueda en PokeAPI de Pokémon y movimientos (substring).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- src/index.ts:50-55 (registration)Registers the 'search_names' MCP tool with input schema (query: string) and a handler that normalizes the query and calls pokeapi.searchNames, returning JSON content.registerTool('search_names', 'Búsqueda en PokeAPI de Pokémon y movimientos (substring).', { type:'object', properties:{ query:{ type:'string' } }, required:['query'] }, async (args:any) => { const q = String(args.query || ''); return jsonContent(await pokeapi.searchNames(q)); });
- src/index.ts:51-51 (schema)Input schema for search_names tool: requires a 'query' string parameter.type:'object', properties:{ query:{ type:'string' } }, required:['query']
- src/pokeapi.ts:141-147 (handler)Core handler logic: normalizes query, fetches all pokemon and move names via cached lists, filters substrings matches, uniques, limits to 50 per category, returns {pokemon: [...], moves: [...]}async searchNames(query: string) { const q = normName(query); const poke = await this.listNames('pokemon'); const moves = await this.listNames('move'); const filt = (arr:string[]) => unique(arr.filter(n => n.includes(q))).slice(0, 50); return { pokemon: filt(poke), moves: filt(moves) }; }
- src/index.ts:29-29 (helper)Helper function used by search_names handler (and others) to format response as MCP content with JSON text.const jsonContent = (obj:any)=>({ content: [{ type: 'text', text: JSON.stringify(obj, null, 2) }] });