Getting started Community Training Tutorials Documentation APIs, AI & Tools
HTML to Markdown
Policy Name |
MCP Payload Optimization Policy |
Summary |
Optimizes MCP tool responses for token consumption by transforming HTML to Markdown and removing unnecessary data |
Category |
MCP |
First Flex Gateway version available |
v1.12.0 |
Returned Status Codes |
No return codes exist for this policy. The policy modifies response bodies and doesn’t block traffic based on content. |
The MCP Payload Optimization policy reduces LLM token consumption by transforming MCP tools/call responses before they’re returned to the client.
Configure the transformations to:
Convert HTML to Markdown.
Remove base64-encoded data.
Remove JSON fields with null values.
Remove excessive whitespace.
The policy processes responses when:
The upstream response has Content-Type application/json or text/event-stream (SSE).
The body is a JSON-RPC MCP tools/call result (including streamed SSE events that carry those results).
Configure the minimum response size to skip transformation for small payloads.
The policy uses the pre_transform_tokens and response_tokens for tool metrics to estimate token reduction.
When you apply the policy from the UI, the following parameters are displayed:
| Element | Description | Default |
|---|---|---|
HTML to Markdown |
Converts HTML content in tool results to Markdown. |
Enabled |
Strip Base64 |
Detects and removes base64-encoded data from tool results. |
Enabled |
Remove Nulls |
Removes JSON fields whose value is null. |
Disabled |
Collapse Whitespace |
Removes excess whitespace in text content. |
Enabled |
Min Response Size (bytes) |
Minimum response size in bytes to transform. Smaller responses pass through unchanged. Minimum value is |
|
Per-Tool Overrides |
Overrides the policy configuration values for specific tool names. Tools without an override use the global policy configuration. To learn more, see Per-tool overrides. |
N/A |
Use Per-Tool Overrides to overide the the response optimization of specific tools. For example, if whitespace is necessary for a specific tool response but not for others, override Collapse Whitespace for that tool.
You can override the global policy configuration for the HTML to Markdown, Strip Base64, Remove Nulls, and Collapse Whitespace parameters but for not Min Response Size.
If you omit a parameter in an override configration, the tool uses the corresponding value from the global policy configuration.