encodeHtml
Convert plain text or data into HTML-encoded format to ensure compatibility and security in web applications.
Instructions
Encode input data to HTML-encoded format
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| input | Yes | Data to encode |
Implementation Reference
- src/tools/encoding.ts:115-130 (handler)The asynchronous handler function that implements the core logic of the encodeHtml tool, replacing special HTML characters with their entity equivalents.handler: async ({ input }: { input: string }) => { const encoded = input .replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') .replace(/'/g, '''); return { content: [ { type: 'text', text: encoded } ] }; }
- src/tools/encoding.ts:105-114 (schema)The input schema defining the expected arguments for the encodeHtml tool: a required string 'input'.inputSchema: { type: 'object', properties: { input: { type: 'string', description: 'Data to encode' } }, required: ['input'] },
- src/tools/encoding.ts:102-131 (registration)The complete definition of the encodeHtml tool, including name, description, schema, and handler, exported as part of encodingTools for registration in the main server.encodeHtml: { name: 'encodeHtml', description: 'Encode input data to HTML-encoded format', inputSchema: { type: 'object', properties: { input: { type: 'string', description: 'Data to encode' } }, required: ['input'] }, handler: async ({ input }: { input: string }) => { const encoded = input .replace(/&/g, '&') .replace(/</g, '<') .replace(/>/g, '>') .replace(/"/g, '"') .replace(/'/g, '''); return { content: [ { type: 'text', text: encoded } ] }; } },