Skip to main content
Glama

pokemon-query

Answer natural language queries about Pokémon by retrieving detailed data, discovering random Pokémon, and finding Pokémon by region or type through the Poke-MCP server.

Instructions

Answer natural language Pokémon queries

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesA natural language query about Pokémon

Implementation Reference

  • Main execution logic for the 'pokemon-query' tool: parses natural language input, matches patterns for Pokémon ID, random, region, or type queries, delegates to helpers, or provides usage examples.
    async ({ query }, _extra) => { const normalizedQuery = query.toLowerCase(); // Check for Pokémon number query const numberMatch = normalizedQuery.match(/pokemon\s+#?(\d+)/i) || normalizedQuery.match(/what\s+is\s+pokemon\s+#?(\d+)/i); if (numberMatch) { const pokemonId = parseInt(numberMatch[1], 10); return await getPokemonById(pokemonId); } // Check for random Pokémon request if ( normalizedQuery.includes("random pokemon") && !normalizedQuery.includes("from") && !normalizedQuery.includes("type") ) { return await getRandomPokemon(); } // Check for random Pokémon from region const regionMatch = normalizedQuery.match(/random pokemon from (\w+)/i); if (regionMatch) { const region = regionMatch[1].toLowerCase(); return await getRandomPokemonFromRegion(region); } // Check for random Pokémon by type const typeMatch = normalizedQuery.match(/random (\w+) pokemon/i) || normalizedQuery.match(/random pokemon of type (\w+)/i); if (typeMatch) { const type = typeMatch[1].toLowerCase(); // Check if the matched word is actually a type and not just any adjective const validTypes = [ "normal", "fire", "water", "grass", "electric", "ice", "fighting", "poison", "ground", "flying", "psychic", "bug", "rock", "ghost", "dragon", "dark", "steel", "fairy", ]; if (validTypes.includes(type)) { return await getRandomPokemonByType(type); } } // Default response for unrecognized queries return { content: [ { type: "text", text: ` I can help with Pokémon queries! Try asking: - "What is pokemon #25?" - "Give me a random Pokémon" - "Give me a random Pokémon from Kanto" - "Give me a random Fire Pokémon" `.trim(), }, ], }; }
  • Input schema defining the 'query' parameter as a string for natural language Pokémon questions.
    { query: z.string().describe("A natural language query about Pokémon"), },
  • src/index.ts:354-436 (registration)
    Registers the 'pokemon-query' tool with the MCP server, including name, description, input schema, and handler reference.
    server.tool( "pokemon-query", "Answer natural language Pokémon queries", { query: z.string().describe("A natural language query about Pokémon"), }, async ({ query }, _extra) => { const normalizedQuery = query.toLowerCase(); // Check for Pokémon number query const numberMatch = normalizedQuery.match(/pokemon\s+#?(\d+)/i) || normalizedQuery.match(/what\s+is\s+pokemon\s+#?(\d+)/i); if (numberMatch) { const pokemonId = parseInt(numberMatch[1], 10); return await getPokemonById(pokemonId); } // Check for random Pokémon request if ( normalizedQuery.includes("random pokemon") && !normalizedQuery.includes("from") && !normalizedQuery.includes("type") ) { return await getRandomPokemon(); } // Check for random Pokémon from region const regionMatch = normalizedQuery.match(/random pokemon from (\w+)/i); if (regionMatch) { const region = regionMatch[1].toLowerCase(); return await getRandomPokemonFromRegion(region); } // Check for random Pokémon by type const typeMatch = normalizedQuery.match(/random (\w+) pokemon/i) || normalizedQuery.match(/random pokemon of type (\w+)/i); if (typeMatch) { const type = typeMatch[1].toLowerCase(); // Check if the matched word is actually a type and not just any adjective const validTypes = [ "normal", "fire", "water", "grass", "electric", "ice", "fighting", "poison", "ground", "flying", "psychic", "bug", "rock", "ghost", "dragon", "dark", "steel", "fairy", ]; if (validTypes.includes(type)) { return await getRandomPokemonByType(type); } } // Default response for unrecognized queries return { content: [ { type: "text", text: ` I can help with Pokémon queries! Try asking: - "What is pokemon #25?" - "Give me a random Pokémon" - "Give me a random Pokémon from Kanto" - "Give me a random Fire Pokémon" `.trim(), }, ], }; } );
  • Helper function called by pokemon-query handler to fetch and format details for a specific Pokémon by ID.
    async function getPokemonById(id: number): Promise<PokemonResponse> { const details = await getPokemonDetails(id.toString()); if (!details) { return { content: [ { type: "text", text: `No Pokémon found with ID #${id}.`, }, ], }; } return formatPokemonResponse(details.pokemon, details.species); }
  • Type definition for the output response format used by pokemon-query and its helpers.
    export interface PokemonResponse { content: { type: "text"; text: string; }[]; }

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/NaveenBandarage/poke-mcp'

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