GenAiHub

Last checked 24 November 2026 — responded normally.

Compress MCP tool outputs into token-efficient LLM context via webhook

Quick overview

Live
Open / InstallLast updated November 24, 2026

Description

Quick overview This workflow exposes a POST webhook that accepts large tool/MCP outputs, runs parallel compression strategies, enforces a target token budget, and returns an optimized context package with before/after metrics and an audit trail, using HTTP Request calls plus custom JavaScript processing. How it works Receives a POST request on the /mcp-context-optimize webhook containing context/tool results plus optional token budget, strategy, and field include/exclude hints. Validates the payload, estimates baseline size (chars/tokens), creates an optimization session, and signs a short-lived session token. Builds three candidate artifacts (prune/deduplicate, summarize long text, and structure-preserving key extraction) and sends each candidate to an external HTTP endpoint in parallel. Waits for the candidate responses and also runs a hard timeout path to ensure the workflow continues if responses are slow. Scores the candidates, selects the best option that fits the token budget (or trims as a fallback), and records the decision in the session audit. Assembles the final optimized context package with savings metrics and returns it as the webhook response. Setup Set a strong signingSecret value in the first code step to securely sign session tokens. Review and adjust limits such as defaultTokenBudget, maxInputChars, and charsPerTokenEstimate to match your LLM and expected payload sizes. Replace the https://httpbin.org/post URLs in the three HTTP Request steps with your own compression/summarization endpoints (or keep them as-is for echo/testing). Activate the workflow and copy the production webhook URL for /mcp-context-optimize into the system that will send tool/MCP outputs. An n8n automation workflow template by Oneclick AI Squad.

Community Metrics

Views
0
Avg Rating
N/A
Ratings
0
Likes
0
Comments
—

Author

Oneclick AI Squad

Platform

web

Pricing model

free

Categories

  • Automation

Tags

  • n8n
  • workflow
  • http-request
  • code

Capabilities

  • 2 nodes

Information

TypeWorkflow
Sourcen8n
AddedNovember 17, 2026

Comments

?

Others in the same category, ranked by how often they are opened.