Skip to main content
Glama

search_pokemon

Find Pokémon by entering a partial name to retrieve detailed information. Access stats, abilities, and more, enabling precise queries for Pokémon data.

Instructions

Search for Pokémon by partial name match

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesPartial name to search for

Implementation Reference

  • src/tools.ts:68-87 (registration)
    Registers the search_pokemon tool with MCP server, including description, input schema, and inline handler function.
    server.tool( "search_pokemon", "Search for Pokémon by partial name match", { query: z.string().min(1).describe("Partial name to search for") }, async ({ query }) => { try { // Get a larger list to search through const pokemonList = await pokeAPI.getPokemonList(1500); const matches = pokemonList.results .filter((p) => p.name.toLowerCase().includes(query.toLowerCase().trim()), ) .slice(0, 20); // Limit to 20 results return formatPokemonSearchResults(query, matches); } catch (error) { return formatCaughtError(error, "searching Pokémon"); } }, );
  • The handler executes the tool logic: fetches up to 1500 pokemon, filters names containing the query (case-insensitive), limits to 20 matches, formats and returns results or error.
    async ({ query }) => { try { // Get a larger list to search through const pokemonList = await pokeAPI.getPokemonList(1500); const matches = pokemonList.results .filter((p) => p.name.toLowerCase().includes(query.toLowerCase().trim()), ) .slice(0, 20); // Limit to 20 results return formatPokemonSearchResults(query, matches); } catch (error) { return formatCaughtError(error, "searching Pokémon"); } },
  • Input schema validates 'query' as a non-empty string.
    { query: z.string().min(1).describe("Partial name to search for") },
  • Helper function formats the search matches into a formatted MCP text response, handling no results case.
    export function formatPokemonSearchResults( query: string, matches: Array<{ name: string; url: string }> ): MCPResponse { if (matches.length === 0) { return { content: [ { type: "text", text: `No Pokémon found matching "${query}". Try a different search term.`, }, ], }; } const resultText = matches .map((p, index) => { const id = p.url.split("/").filter(Boolean).pop(); return `${index + 1}. ${p.name} (ID: ${id})`; }) .join("\n"); return { content: [ { type: "text", text: `**Search results for "${query}":**\n\n${resultText}\n\n*Use fetch_pokemon with any of these names to get detailed information.*`, }, ], }; }
  • Helper function formats caught errors into MCP response format.
    export function formatCaughtError(error: unknown, context: string): MCPResponse { const message = error instanceof Error ? error.message : String(error); return formatError(`Error ${context}: ${message}`); }

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/hollanddd/pokedex-mcp'

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