html-decode
Convert HTML entities back into readable text using this decoding tool. Ideal for developers working with encoded HTML content.
Instructions
Decode HTML entities
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | HTML encoded text to decode |
Implementation Reference
- The handler function that decodes HTML entities by replacing <, >, ", ', and & in the correct order to avoid double-unescaping.}, async ({ text }) => { // Proper HTML decoding order: decode & LAST to prevent double-unescaping const decoded = text .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') .replace(/'/g, "'") .replace(/&/g, '&'); // Decode ampersand LAST return { content: [ { type: "text", text: `HTML decoded: ${decoded}`, }, ], }; }
- Input schema for the tool, requiring a 'text' string parameter containing HTML encoded text.inputSchema: { text: z.string().describe("HTML encoded text to decode"), },
- src/tools/encoding/decode_html/index.ts:4-34 (registration)Registration function that sets up the 'decode_html' tool on the MCP server, including description, schema, annotations, and handler.export function registerDecodeHtml(server: McpServer) { server.registerTool("decode_html", { description: "Decode HTML entities", inputSchema: { text: z.string().describe("HTML encoded text to decode"), }, // VS Code compliance annotations annotations: { title: "Decode Html", description: "Decode HTML entities", readOnlyHint: false } }, async ({ text }) => { // Proper HTML decoding order: decode & LAST to prevent double-unescaping const decoded = text .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') .replace(/'/g, "'") .replace(/&/g, '&'); // Decode ampersand LAST return { content: [ { type: "text", text: `HTML decoded: ${decoded}`, }, ], }; } ); }