HTML to Markdown
MCP Payload Optimization Policy
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 Omni 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. |
| This policy supports Model Context Protocol (MCP) version 2025-06-18 and earlier. To learn more about MCP, see MCP Specification. |
Summary
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-Typeapplication/jsonortext/event-stream(SSE). -
The body is a JSON-RPC MCP
tools/callresult (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.
Configuring Policy Parameters
Managed Omni Gateway and Omni Gateway Connected Mode
When you apply the policy from the UI, the following parameters are displayed:
| Element | Description | Default |
|---|---|---|
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 |
Per-tool overrides
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.



