Skip to main content
Glama
AkhrHysd

PokeAPI MCP Server

by AkhrHysd
getPokemonInfo.test.ts1.29 kB
import { describe, it, expect } from "vitest"; import fetch from "node-fetch"; // テスト対象の関数を再定義(本来はimportするが、ここでは自己完結のため再掲) type PokeApiResponse = { name: string; id: number; height: number; weight: number; types: { type: { name: string } }[]; }; async function getPokemonInfo(nameOrId: string) { const res = await fetch( `https://pokeapi.co/api/v2/pokemon/${encodeURIComponent(nameOrId)}` ); if (!res.ok) throw new Error("Not found"); const data = (await res.json()) as PokeApiResponse; return { name: data.name, id: data.id, height: data.height, weight: data.weight, types: data.types.map((t) => t.type.name), }; } describe("getPokemonInfo", () => { it("should fetch Pikachu info correctly", async () => { const result = await getPokemonInfo("pikachu"); expect(result.name).toBe("pikachu"); expect(result.id).toBe(25); expect(Array.isArray(result.types)).toBe(true); expect(result.types).toContain("electric"); expect(typeof result.height).toBe("number"); expect(typeof result.weight).toBe("number"); }); it("should throw on not found", async () => { await expect(getPokemonInfo("notapokemon")).rejects.toThrow("Not found"); }); });

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/AkhrHysd/mcp-pokeapi-server'

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