Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion gateway-home/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,13 @@ To protect Mule applications that do not require the management and maintenance

| MCP PII Detector ^| Blocks elicitation responses containing personally identifiable information (PII) from reaching MCP servers ^| xref:gateway::policies-included-mcp-pii-detector.adoc[Yes] ^| xref:gateway::policies-included-mcp-pii-detector.adoc[Yes] ^| No ^| No

| MCP Payload Optimization ^| Optimizes MCP tool responses for token consumption by transforming HTML to Markdown and removing unnecessary data ^| xref:gateway::policies-included-mcp-payload-optimization.adoc[Yes] ^| xref:gateway::policies-included-mcp-payload-optimization.adoc[Yes] ^| No ^| No

| MCP Schema Validation ^| Validates MCP requests to ensure they conform to the MCP specification ^| xref:gateway::policies-included-mcp-schema-validation.adoc[Yes] ^| xref:gateway::policies-included-mcp-schema-validation.adoc[Yes] ^| No ^| No

| MCP Support ^| Adds MCP support to a Flex Gateway MCP server instance. This policy is required for your MCP server instance to function properly. ^| xref:gateway::policies-included-mcp-support.adoc[Yes] ^| xref:gateway::policies-included-mcp-support.adoc[Yes] ^| No ^| No

| MCP Tool Mapping ^| Renames MCP tool names in requests and responses to provide flexible tool naming ^| xref:gateway::policies-included-mcp-tool-mapping.adoc[Yes] ^| xref:gateway::policies-included-mcp-tool-mapping.adoc[Yes] ^| No ^| No
| MCP Tool Mapping ^| Redefines tool names and descriptions to reduce prompt complexity and improve LLM comprehension ^| xref:gateway::policies-included-mcp-tool-mapping.adoc[Yes] ^| xref:gateway::policies-included-mcp-tool-mapping.adoc[Yes] ^| No ^| No

| Message Logging ^| Logs custom messages using information from incoming requests, responses from the backend, or information from other policies applied to the same API endpoint ^| xref:gateway::policies-included-message-logging.adoc[Yes] ^| xref:gateway::policies-included-message-logging.adoc[Yes] ^| xref:gateway::policies-included-message-logging.adoc[Yes] ^| xref:mule-gateway::policies-included-message-logging.adoc[Yes]

Expand Down
2 changes: 1 addition & 1 deletion gateway/1.11/modules/ROOT/pages/flex-agent-policies.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Both A2A and MCP support the following policies for Server-Sent Events (SSE) str
| xref:policies-included-mcp-pii-detector.adoc[MCP PII Detector] | Blocks elicitation responses containing personally identifiable information (PII) from reaching MCP servers
| xref:policies-included-mcp-schema-validation.adoc[MCP Schema Validation] | Validates MCP requests to ensure they conform to the MCP specification
| xref:policies-included-mcp-support.adoc[MCP Support] | Adds MCP support to a Flex Gateway MCP server instance. This policy is required for your MCP server instance to function properly.
| xref:policies-included-mcp-tool-mapping.adoc[MCP Tool Mapping] | Renames MCP tool names in requests and responses to provide flexible tool naming
| xref:policies-included-mcp-tool-mapping.adoc[MCP Tool Mapping] | Redefines tool names and descriptions to reduce prompt complexity and improve LLM comprehension
|===


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ endif::[]
| xref:policies-included-mcp-attribute-access-control.adoc[MCP Attribute-Based Access Control] | MCP | Controls access to tools, resources, and prompts based on user information such as Tiers, IP, Headers, or Claims
| xref:policies-included-mcp-pii-detector.adoc[MCP PII Detector] | MCP | Blocks elicitation responses containing personally identifiable information (PII) from reaching MCP servers
| xref:policies-included-mcp-schema-validation.adoc[MCP Schema Validation] | MCP | Validates MCP requests to ensure they conform to the MCP specification
| xref:policies-included-mcp-support.adoc[MCP Support] | MCP | Adds MCP support to a Flex Gateway MCP server instance. This policy is required for your MCP server instance to function properly.
| xref:policies-included-mcp-tool-mapping.adoc[MCP Tool Mapping] | MCP | Renames MCP tool names in requests and responses to provide flexible tool naming
| xref:policies-included-mcp-support.adoc[MCP Support] | MCP | Adds MCP support to a Flex Gateway MCP server instance, required for your MCP server instance to function properly
| xref:policies-included-mcp-tool-mapping.adoc[MCP Tool Mapping] | MCP | Redefines tool names and descriptions to reduce prompt complexity and improve LLM comprehension
| xref:policies-included-message-logging.adoc[Message Logging] | Troubleshooting | Logs custom messages using information from incoming requests, responses from the backend, or information from other policies applied to the same API endpoint
| xref:policies-included-oauth-token-introspection.adoc[OAuth 2.0 Token Introspection] | Security | Allows access only to authorized client applications
| xref:policies-included-openid-token-enforcement.adoc[OpenID Connect OAuth 2.0 Access Token Enforcement] | Security | Allows access only to authorized client applications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif::[]
[width="100%", cols="5,15"]
|===
>s| Policy Name | MCP Tool Mapping
>s|Summary | Renames MCP tool names in requests and responses to provide flexible tool naming
>s|Summary | Redefines tool names and descriptions to reduce prompt complexity and improve LLM comprehension
>s|Category | MCP
>s|First Flex Gateway version available | v1.11.0
>s| Returned Status Codes | No return codes exist for this policy.
Expand Down
1 change: 1 addition & 0 deletions gateway/1.12/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
*** xref:policies-included-mcp-attribute-access-control.adoc[MCP Attribute-Based Access Control]
*** xref:policies-included-mcp-global-access.adoc[MCP Global Access]
*** xref:policies-included-mcp-pii-detector.adoc[MCP PII Detector]
*** xref:policies-included-mcp-payload-optimization.adoc[MCP Payload Optimization]
*** xref:policies-included-mcp-schema-validation.adoc[MCP Schema Validation]
*** xref:policies-included-mcp-support.adoc[MCP Support]
*** xref:policies-included-mcp-tool-mapping.adoc[MCP Tool Mapping]
Expand Down
3 changes: 2 additions & 1 deletion gateway/1.12/modules/ROOT/pages/flex-agent-policies.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ Both A2A and MCP support the following policies for Server-Sent Events (SSE) str
| xref:policies-included-mcp-attribute-access-control.adoc[MCP Attribute-Based Access Control] | Controls access to tools, resources, and prompts based on user information such as Tiers, IP, Headers, or Claims
| xref:policies-included-mcp-global-access.adoc[MCP Global Access] | Restricts which MCP tools are exposed by defining Allow and Block rules
| xref:policies-included-mcp-pii-detector.adoc[MCP PII Detector] | Blocks elicitation responses containing personally identifiable information (PII) from reaching MCP servers
| xref:policies-included-mcp-payload-optimization.adoc[MCP Payload Optimization] | Optimizes MCP tool responses for token consumption by transforming HTML to Markdown and removing unnecessary data
| xref:policies-included-mcp-schema-validation.adoc[MCP Schema Validation] | Validates MCP requests to ensure they conform to the MCP specification
| xref:policies-included-mcp-support.adoc[MCP Support] | Adds MCP support to a Flex Gateway MCP server instance. This policy is required for your MCP server instance to function properly.
| xref:policies-included-mcp-tool-mapping.adoc[MCP Tool Mapping] | Renames MCP tool names in requests and responses to provide flexible tool naming
| xref:policies-included-mcp-tool-mapping.adoc[MCP Tool Mapping] | Redefines tool names and descriptions to reduce prompt complexity and improve LLM comprehension
|===


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ endif::[]
| xref:policies-included-mcp-attribute-access-control.adoc[MCP Attribute-Based Access Control] | MCP | Controls access to tools, resources, and prompts based on user information such as Tiers, IP, Headers, or Claims
| xref:policies-included-mcp-global-access.adoc[MCP Global Access] | MCP | Restricts which MCP tools are exposed by defining Allow and Block rules
| xref:policies-included-mcp-pii-detector.adoc[MCP PII Detector] | MCP | Blocks elicitation responses containing personally identifiable information (PII) from reaching MCP servers
| xref:policies-included-mcp-payload-optimization.adoc[MCP Payload Optimization] | MCP | Optimizes MCP tool responses for token consumption by transforming HTML to Markdown and removing unnecessary data
| xref:policies-included-mcp-schema-validation.adoc[MCP Schema Validation] | MCP | Validates MCP requests to ensure they conform to the MCP specification
| xref:policies-included-mcp-support.adoc[MCP Support] | MCP | Adds MCP support to a Flex Gateway MCP server instance. This policy is required for your MCP server instance to function properly.
| xref:policies-included-mcp-tool-mapping.adoc[MCP Tool Mapping] | MCP | Renames MCP tool names in requests and responses to provide flexible tool naming
| xref:policies-included-mcp-tool-mapping.adoc[MCP Tool Mapping] | MCP | Redefines tool names and descriptions to reduce prompt complexity and improve LLM comprehension
| xref:policies-included-message-logging.adoc[Message Logging] | Troubleshooting | Logs custom messages using information from incoming requests, responses from the backend, or information from other policies applied to the same API endpoint
| xref:policies-included-oauth-token-introspection.adoc[OAuth 2.0 Token Introspection] | Security | Allows access only to authorized client applications
| xref:policies-included-openid-token-enforcement.adoc[OpenID Connect OAuth 2.0 Access Token Enforcement] | Security | Allows access only to authorized client applications
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
= MCP Payload Optimization Policy
ifndef::env-site,env-github[]
include::_attributes.adoc[]
endif::[]
:imagesdir: ../assets/images
:keywords: api gateway, flex gateway, gateway, policy

[width="100%", cols="5,15"]
|===
>s| Policy Name | MCP Payload Optimization Policy
>s|Summary | Optimizes MCP tool responses for token consumption by transforming HTML to Markdown and removing unnecessary data
>s|Category | MCP
>s|First Flex Gateway version available | v1.12.0
>s| Returned Status Codes | No return codes exist for this policy. The policy modifies response bodies and doesn't block traffic based on content.
|===

== 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-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.

== Configuring Policy Parameters

include::partial$policy-title-headers.adoc[tag=configFileTitleOnly]

The MCP Payload Optimization policy isn't supported in Local Mode.

include::partial$policy-title-headers.adoc[tag=ui]

[%header%autowidth.spread,cols="a,a,a"]

|===
| Element | Description | Default
| HTML to Markdown | Converts HTML content in tool results to Markdown. | Enabled
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

periods here...

| 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 `0`. | `500`
| 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 <<tool-overrides>>. | N/A
|===

[[tool-overrides]]
=== 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.

== See Also

* xref:policies-included-mcp-support.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif::[]
[width="100%", cols="5,15"]
|===
>s| Policy Name | MCP Tool Mapping
>s|Summary | Renames MCP tool names in requests and responses to provide flexible tool naming
>s|Summary | Redefines tool names and descriptions to reduce prompt complexity and improve LLM comprehension
>s|Category | MCP
>s|First Flex Gateway version available | v1.11.0
>s| Returned Status Codes | No return codes exist for this policy.
Expand Down Expand Up @@ -139,4 +139,3 @@ Standardize tool names across different servers. For example, this configuration
* xref:policies-included-mcp-global-access.adoc[MCP Global Access]
* xref:policies-included-mcp-attribute-access-control.adoc[MCP Attribute-Based Access Control]
* xref:policies-included-directory.adoc[Included Policies Directory]

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif::[]
Flex Gateway provides three MCP policies that work together to control which tools and related MCP entities are exposed:

* xref:policies-included-mcp-global-access.adoc[MCP Global Access]: Restricts which tools are exposed by using allow or block rules.
* xref:policies-included-mcp-tool-mapping.adoc[MCP Tool Mapping]: Renames and modifies tool descriptions.
* xref:policies-included-mcp-tool-mapping.adoc[MCP Tool Mapping]: Redefines tool names and descriptions to reduce prompt complexity and improve LLM comprehension.
* xref:policies-included-mcp-attribute-access-control.adoc[MCP Attribute-Based Access Control]: Grants each client a subset of tools based on who they are, such as Tiers, IP, headers, or claims.

== How the Policies Work Together
Expand All @@ -19,7 +19,7 @@ MCP Global Access::
Filters the overall tool list. Define rules to allow or block specific tools so that only the tools you want to expose enter your network.

MCP Tool Mapping::
Renames tools or changes their descriptions. Mapping doesn't filter tools. If you use both policies, MCP Global Access must allow a tool before mapping applies.
Redefines tool names and descriptions to reduce prompt complexity and improve LLM comprehension. Mapping doesn't filter tools. If you use both policies, MCP Global Access must allow a tool before mapping applies.

MCP Attribute-Based Access Control::
Grants each connecting client a tailored subset of the available tools based on attributes, such as tiers, IP addresses, headers, or claims.
Expand Down