Get README badge code
get_badge_codeGenerate README badge Markdown, HTML, or SVG URL for any approved public Codex pet using its exact slug.
Instructions
Use for a known approved pet slug when the user needs README badge Markdown, HTML, or SVG URL. Do not use for animated README cards, website iframe embeds, install instructions, or pet discovery; use get_card_code, get_embed_code, get_install_instructions, or search_pets instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes | Exact slug of an approved public Codex pet. |
Implementation Reference
- src/lib/pets/mcp-server.ts:171-177 (handler)Main tool handler for get_badge_code - delegates to handleApprovedPetTool which fetches the approved pet by slug and returns badge data (markdown, html, svgUrl).
async (args) => { return handleApprovedPetTool("get_badge_code", args.slug, (pet) => ({ slug: pet.slug, name: pet.name, badge: pet.badge, })); }, - src/lib/pets/mcp-server.ts:162-170 (registration)Registration of get_badge_code tool on the MCP server with title, description, input schema (slug), and read-only annotations.
server.registerTool( "get_badge_code", { title: "Get README badge code", description: "Use for a known approved pet slug when the user needs README badge Markdown, HTML, or SVG URL. Do not use for animated README cards, website iframe embeds, install instructions, or pet discovery; use get_card_code, get_embed_code, get_install_instructions, or search_pets instead.", inputSchema: slugInputSchema, annotations: READ_ONLY_TOOL, }, - packages/cli/src/mcp.js:72-78 (handler)CLI alternative handler - fetches share payload from API and returns badge data (markdown, html, svgUrl) for the given slug.
async getBadgeCode(slug) { const share = await fetchSharePayload(fetchImpl, baseUrl, slug); return { slug: share.pet.slug, name: share.pet.name, badge: share.share.badge, }; - packages/cli/src/mcp.js:171-181 (registration)CLI-side registration of get_badge_code tool on the local MCP server.
server.registerTool( "get_badge_code", { title: "Get README badge code", description: "Use for a known approved pet slug when the user needs README badge Markdown, HTML, or SVG URL. Do not use for animated README cards, website iframe embeds, install instructions, or pet discovery; use get_card_code, get_embed_code, get_install_instructions, or search_pets instead.", inputSchema: slugSchema, annotations: READ_ONLY_TOOL, }, async (args) => runTool(() => dataSource.getBadgeCode(readSlug(args.slug))), ); - Helper that builds the AgentBadgeCode object containing markdown, HTML, and svgUrl for a pet badge.
export function buildAgentBadgeCode(input: { name: string; pageUrl: string; svgUrl: string; }): AgentBadgeCode { const alt = `Codex pet: ${input.name}`; return { markdown: `[](${input.pageUrl})`, html: `<a href="${escapeHtmlAttribute(input.pageUrl)}"><img alt="${escapeHtmlAttribute(alt)}" src="${escapeHtmlAttribute(input.svgUrl)}"></a>`, svgUrl: input.svgUrl, }; }