Skip to content

feat(profiles): per-profile tool_response_limit - #2029

Open
Dumbris wants to merge 6 commits into
mainfrom
claude/issue-2027-investigation-1b7baa
Open

Dumbris wants to merge 6 commits into
mainfrom
claude/issue-2027-investigation-1b7baa

Conversation

@Dumbris

@Dumbris Dumbris commented Nov 24, 2026

Copy link
Copy Markdown
Member

Summary

Since 0.75.0 (#1937) tool_response_limit also bounds structuredContent. That is right for agents, but a local script that parses the JSON itself now gets cut answers, and read_cache cannot rebuild them (it pages one record array and leaves out sibling fields such as @odata.nextLink).

This adds the override the issue asks for: profiles[].tool_response_limit.

  • unset: the profile inherits the global limit
  • 0: no limit, text blocks and structuredContent arrive whole
  • a positive number: that many characters (may be larger or smaller than the global limit)

A script gets its own read-only profile with whole answers; chats keep the default bound.

{ "name": "script", "servers": ["workiq", "tickets"], "max_tier": "read", "tool_response_limit": 0 }

closes #2027

What changed

  • Config (internal/config/profiles.go): new ToolResponseLimit *int (a pointer, so an explicit 0 survives omitempty), EffectiveToolResponseLimit, and a negative value is refused by the one profile validator (field tool_response_limit). It is a delivery setting, not policy: it does not make a profile non-legacy.
  • Serving path (internal/server/profile_response_limit.go): the truncator is resolved per call from the effective profile (truncatorForProfile), and used by call_tool_read|write|destructive, the legacy call_tool, the direct tools, retrieve_tools, read_cache and the TOON encoder. A profile that sets no limit, or a name that no longer exists, keeps the live global truncator.
  • Sanitisation is not weakened. Output sanitisation reads text blocks only, and under the global limit an oversize structured result reached it as text. While sanitisation is set to block, redact or strip, the global limit still decides when a structured result becomes a text block; the profile's limit then delivers that text whole (structuredWithholdLimit). With sanitisation in its default mode the result stays in structuredContent.
  • Admin surfaces: REST ProfileView.tool_response_limit, the profile change diff, the MCP profiles tool schema, CLI profile create|update --tool-response-limit <n|inherit> / --clear-tool-response-limit / profile try --set tool_response_limit=, profile show.
  • Editors: the Web UI and macOS profile editors gain an Inherit / No limit / Custom control. Without it, saving a profile there would have dropped a limit set elsewhere, because both build the PUT body from their own draft.
  • Docs: docs/features/profiles.md "Response limit per profile", config reference, CLI and REST references, swagger, changelog.

Decisions made without asking

  • The override may widen as well as narrow. The limit is a context-budget setting, not an access rule, and only an operator can set it. Any caller that can select the profile gets its limit, which the docs say.
  • mcpproxy call tool-read has no profile argument and is unchanged; a script uses /mcp/p/<profile> or a credential bound to the profile.

Testing

  • New Go tests: config validation and JSON round trip, handleCallToolVariant under URL, session and pinned profiles against a real in-process upstream (fails without the change), the sanitisation case, direct-mode limit resolution, REST view and diff, CLI flags.
  • New vitest spec for the editor control; new XCTest cases for the Swift payload round trip.
  • Live check with the built binary and a fixture returning 128,357 characters of structuredContent (300 records plus @odata.nextLink):
Endpoint Result
/mcp (no profile, limit 20000) structuredContent withheld, text cut at 19,811
/mcp/p/chat (inherits) same as above
/mcp/p/script (tool_response_limit: 0) structuredContent whole: 300 records, @odata.nextLink present

A live profile update chat --tool-response-limit 60000 took effect on the next call without a restart.

Known, not changed here

Direct mode reads the global limit from the construction-time config, so a hot-reloaded global tool_response_limit does not reach it. That predates this change.

A profile can replace the global tool_response_limit for calls served
under it: profiles[].tool_response_limit, where unset inherits, 0 means no
limit and a positive number is that many characters. A script that parses
whole results gets its own profile and receives text blocks and
structuredContent whole, while other callers keep the global bound.

The truncator is resolved per call from the effective profile and used by
call_tool_*, the legacy call_tool, the direct tools, retrieve_tools,
read_cache and the TOON encoder. While output sanitisation is set to
block, redact or strip, the global limit still decides when an oversize
structured result becomes a text block, so a wider profile limit never
carries it past sanitisation.

Wired through the REST profile view, the profile change diff, the MCP
profiles tool, the CLI (--tool-response-limit, --clear-tool-response-limit)
and the Web UI and macOS profile editors, which would otherwise drop a
stored limit on save.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Deploying mcpproxy-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 73c2f3c
Status: ✅  Deploy successful!
Preview URL: https://417f3b1e.mcpproxy-docs.pages.dev
Branch Preview URL: https://claude-issue-2027-investigat.mcpproxy-docs.pages.dev

View logs

…estigation-1b7baa

# Conflicts:
#	frontend/package-lock.json
@Dumbris
Dumbris enabled auto-merge (squash) November 24, 2026 13:49
@codecov-commenter

codecov-commenter commented Nov 24, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 60.86957% with 18 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/server/profile_response_limit.go 64.28% 9 Missing and 1 partial ⚠️
internal/server/mcp.go 54.54% 5 Missing ⚠️
internal/server/mcp_routing.go 60.00% 2 Missing ⚠️
internal/server/toon_encode.go 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions

Copy link
Copy Markdown
Contributor

📦 Build Artifacts

Workflow Run: View Run
Branch: claude/issue-2027-investigation-1b7baa

Available Artifacts

  • archive-darwin-amd64 (33 MB)
  • archive-darwin-arm64 (30 MB)
  • archive-linux-amd64 (21 MB)
  • archive-linux-arm64 (19 MB)
  • archive-windows-amd64 (33 MB)
  • archive-windows-arm64 (29 MB)
  • frontend-dist-pr (0 MB)
  • installer-dmg-darwin-amd64 (29 MB)
  • installer-dmg-darwin-arm64 (26 MB)
  • smart-mcp-proxymcpproxy-go4HHDUK.dockerbuild (0 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page linked above
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 45391280601 --repo smart-mcp-proxy/mcpproxy-go

Note: Artifacts expire in 14 days.

…aude/issue-2027-investigation-1b7baa

# Conflicts:
#	oas/docs.go

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Per-profile tool_response_limit for clients that parse whole results

2 participants