-
-
Notifications
You must be signed in to change notification settings - Fork 284
Description
Description
I would like the ability to transform the response data from MCP calls before they get consumed by the LLM so that I can manage my context window more effectively
Problem Statement/Justification
Depending on your Panda CSS theme configuration, certain MCP calls may give a response with an unwieldy amount of tokens.
⏺ panda - get_semantic_tokens (MCP)(category: "colors")
⎿ ⚠ Large MCP response (~17.4k tokens), this can fill up context quickly
Depending on your use case or consumer patterns, this may be too much irrelevant information. For example, in my design system, a single semantic color gives the following response, when really, we probably only want the LLM to be aware of the name of the semantic color and the fact that it exists at all, the value, condition, and cssVar properties are largely irrelevant, particularly if we're pulling values from figma which directly reference the token names rather than values.
{
"name": "foreground.accent",
"values": [
{
"value": "#6950f3",
"condition": "lightTheme"
},
{
"value": "#8880ff",
"condition": "autoTheme.osDark"
},
{
"value": "#8880ff",
"condition": "darkTheme"
},
{
"value": "#ffffff",
"condition": "accentTheme"
}
],
"cssVar": "var(--colors-foreground-accent)"
},This extra information is problematic for a couple of reasons:
- Extra cost when using the Panda CSS MCP with an LLM due to superfluous tokens being sent to the LLM.
- Less context available for other skills or tasks. Rarely are you only making changes to styling and nothing else.
- Worse LLM performance. It's a well known fact that the effectiveness of LLMs decreases the more tokens you pass it.
Proposed Solution or API
I'm not exactly sure what the API would look like, but perhaps another custom integration hook mcp:response that gives the flexibility to run any transformation on any MCP response. This in particular would be beneficial since this could be easily shipped as a panda plugin in an npm package, so multiple consumers could benefit from the same transformation
Alternatives
None, I haven't seen anything in the issues or discussions or docs related to this problem
Additional Information
I'm motivated to address this issue for myself relatively soon. If we can agree on the approach I'd be happy to try contributing :)