-
Notifications
You must be signed in to change notification settings - Fork 12
W-22261003 mcp optimization policy gr #1058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
glenn-rodgers-sf
wants to merge
14
commits into
latest
Choose a base branch
from
W-22261003-mcp-optimization-policy-gr
base: latest
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
592fccb
New policy
glenn-rodgers-sf 77fb87e
Edits
glenn-rodgers-sf 1031051
Edits
glenn-rodgers-sf edaf222
Update policies-included-mcp-payload-optimization.adoc
glenn-rodgers-sf 2c772c2
Update policies-included-mcp-payload-optimization.adoc
glenn-rodgers-sf 4de02b9
Rename to optimization
glenn-rodgers-sf 9a5a0da
MCP Tool Mapping summary update
glenn-rodgers-sf 7e49908
rewrite mcp optimization
glenn-rodgers-sf 4b2ab9d
title change
glenn-rodgers-sf 20d298a
Create policies-included-mcp-optimization.adoc
glenn-rodgers-sf e7ec357
Remove
glenn-rodgers-sf 23d3d1d
Apply suggestions from code review
glenn-rodgers-sf 1503ebb
Apply suggestions from code review
glenn-rodgers-sf d1b763a
Update policies-included-mcp-payload-optimization.adoc
glenn-rodgers-sf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
gateway/1.12/modules/ROOT/pages/policies-included-mcp-payload-optimization.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| | 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[] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
periods here...