[PR #2473] [CLOSED] [GUI] MCP cached image previews and authenticated downloads #4059

Closed
opened 2026-11-07 15:32:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2473
Author: @cuijinkuo
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: codex/mcp-image-results


📝 Commits (7)

  • 5463b11 mcp: add opt-in cached image previews and authenticated downloads
  • eb7c6e1 mcp: parse image opt-in and tolerate stale cached history
  • 767d72c Merge upstream main and preserve MCP cache ignore rules
  • 0b9ad57 web: keep MCP image chats within narrow viewports
  • 429c900 docs: explain web search and generated image tool setup
  • fcc62c6 Merge Strata 0.2 main and preserve cached MCP image previews
  • 645099f Merge remote-tracking branch 'origin/main' into codex/live-022-20261022

📊 Changes

8 files changed (+655 additions, -10 deletions)

View changed files

📝 .gitignore (+4 -0)
➕ docs/MCP_IMAGES.md (+27 -0)
➕ docs/MCP_TOOLS_GUIDE.md (+177 -0)
📝 serve/mcp.py (+59 -3)
📝 serve/server.py (+46 -2)
➕ serve/test_mcp_media.py (+289 -0)
📝 serve/web/app.css (+11 -2)
📝 serve/web/app.js (+42 -3)

📄 Description

Problem and result

An MCP image result reaches the Python web chat as text describing an unseen picture. This opt-in change caches raster results, forwards them through existing vision preparation when configured, and displays previews with authenticated downloads. Missing cache files become omission notes so later turns continue.

Related: #2130 and #2343. This PR was closed by the 0.2.0-beta tracker reset, not rejected. Updated against main 011c9e600a (0.2.2). #2343 is an overlapping alternative transport and needs reconciliation before merge. No separate maintainer scope approval is recorded for this cache-based alternative.

Approach

Enable with JSON "mcp": {"image_results": true} in the run configuration; disabled by default. PNG/JPEG/WebP are cached by SHA-256 beside the config. Four pictures per result, each capped at 24 million base64 characters. The authenticated same-origin route validates basenames and sends raster MIME, nosniff and same-origin resource-policy headers. Browser previews/downloads use Blob URLs; history stores small references rather than base64. New chat/pagehide reclaim URLs; BFCache restoration rehydrates them.

Merged current main without rewriting history. The sole conflict was an equivalent min-width CSS declaration; kept upstream's form. Narrow layout changes retain tool cards and composer controls.

Setup tutorial: web search, generated images, preview and download

Validation

Revision: 645099fdbe, merged with 0.2.2. Windows, Python 3.14, Node 22.20.0.

Passed:

  • python -m unittest serve.test_mcp_media serve.test_mcp serve.test_images serve.test_web_sampling: 68 tests, OK (27.092 s).
  • python -m unittest serve.test_server serve.test_frontend serve.test_tool_call_envelope serve.test_answer_speed serve.test_gpu_roles_server serve.test_pool_cores: 405 tests, OK, 3 skipped (113.274 s).
  • node --check serve/web/app.js; git diff origin/main --check: passed.
  • Same fake MCP tool and PNG against official 0.2.2 and this branch: official ignores image_results and returns 0 images/no model_content/no cached file; this branch returns 1 image/model_content/1 cached file.
  • Real service switched to this revision with the checksum-verified official CUDA13 engine 0.1.47 on RTX 5080. CPU vision, mmap experts, 16K context. Short text request returned the requested Chinese phrase; localhost and Tailscale health/page requests succeeded. Cached image download matched source SHA-256.
  • Final short-run sampled minimum free VRAM 3057 MiB and free RAM 54.17 GiB. Local deployment uses 5120 MiB VRAM reserve. These are operational smoke results, not a performance benchmark or PR defaults.

Failed / corrected during validation:

  • Initial 32-token smoke exhausted its output in reasoning; the standard chat_template_kwargs enable_thinking=false request with 128-token limit returned the expected answer.
  • Initial local 3072 MiB reserve left about 1 GiB free VRAM. Unloaded and restarted with 5120 MiB reserve, then repeated the smoke successfully.
  • Non-fatal ResourceWarnings appeared in the CPU suite.

Not run:

  • Fresh image/video generation, long-context stress, physical phone/Safari, Linux/macOS and the separate desktop UI.
  • Native builds: no native engine files differ from main; live testing used the official release engine.

Limits

Applies to serve/server.py and serve/web, not the separate apps/host or apps/desktop UI. No bundled search provider, ComfyUI, vision/generation model or GPU lifecycle controller. Cache retention is manual. No performance/quality claim. The local Python web service has been cut over; this is not a desktop-app integration.

0.2.2 overlap: upstream f2709679 already fixes part of the mobile tool-card overflow. The remaining reason for this PR is opt-in cached image transport, vision delivery, previews and downloads. MCP provider configuration and the standalone image-generation API already exist upstream; this PR does not introduce those capabilities.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2473 **Author:** [@cuijinkuo](https://github.com/cuijinkuo) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `codex/mcp-image-results` --- ### 📝 Commits (7) - [`5463b11`](https://github.com/Niko1221/Strata/commit/5463b119ade32a339ca5472a8f95847379d8f9c8) mcp: add opt-in cached image previews and authenticated downloads - [`eb7c6e1`](https://github.com/Niko1221/Strata/commit/eb7c6e193ea8e1eb3b770ef128896cd859fa33ba) mcp: parse image opt-in and tolerate stale cached history - [`767d72c`](https://github.com/Niko1221/Strata/commit/767d72c24f1d1fd09516f485be4faf6e635a6be8) Merge upstream main and preserve MCP cache ignore rules - [`0b9ad57`](https://github.com/Niko1221/Strata/commit/0b9ad57d4a6cf8e9b92fb462b9164ad47be06501) web: keep MCP image chats within narrow viewports - [`429c900`](https://github.com/Niko1221/Strata/commit/429c9009e04f431efdd3c9233ab39f1601e549cb) docs: explain web search and generated image tool setup - [`fcc62c6`](https://github.com/Niko1221/Strata/commit/fcc62c6df17691e76369b4a020900a56ba84e9aa) Merge Strata 0.2 main and preserve cached MCP image previews - [`645099f`](https://github.com/Niko1221/Strata/commit/645099fdbe014c061a59cd19f4389898b479c496) Merge remote-tracking branch 'origin/main' into codex/live-022-20261022 ### 📊 Changes **8 files changed** (+655 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+4 -0) ➕ `docs/MCP_IMAGES.md` (+27 -0) ➕ `docs/MCP_TOOLS_GUIDE.md` (+177 -0) 📝 `serve/mcp.py` (+59 -3) 📝 `serve/server.py` (+46 -2) ➕ `serve/test_mcp_media.py` (+289 -0) 📝 `serve/web/app.css` (+11 -2) 📝 `serve/web/app.js` (+42 -3) </details> ### 📄 Description ## Problem and result An MCP image result reaches the Python web chat as text describing an unseen picture. This opt-in change caches raster results, forwards them through existing vision preparation when configured, and displays previews with authenticated downloads. Missing cache files become omission notes so later turns continue. ## Related discussion Related: #2130 and #2343. This PR was closed by the 0.2.0-beta tracker reset, not rejected. Updated against main 011c9e600a93bbc9fd451c563501b5831c32bbca (0.2.2). #2343 is an overlapping alternative transport and needs reconciliation before merge. No separate maintainer scope approval is recorded for this cache-based alternative. ## Approach Enable with JSON "mcp": {"image_results": true} in the run configuration; disabled by default. PNG/JPEG/WebP are cached by SHA-256 beside the config. Four pictures per result, each capped at 24 million base64 characters. The authenticated same-origin route validates basenames and sends raster MIME, nosniff and same-origin resource-policy headers. Browser previews/downloads use Blob URLs; history stores small references rather than base64. New chat/pagehide reclaim URLs; BFCache restoration rehydrates them. Merged current main without rewriting history. The sole conflict was an equivalent min-width CSS declaration; kept upstream's form. Narrow layout changes retain tool cards and composer controls. [Setup tutorial: web search, generated images, preview and download](https://github.com/cuijinkuo/Strata/blob/codex/mcp-image-results/docs/MCP_TOOLS_GUIDE.md) ## Validation Revision: 645099fdbe014c061a59cd19f4389898b479c496, merged with 0.2.2. Windows, Python 3.14, Node 22.20.0. **Passed:** - python -m unittest serve.test_mcp_media serve.test_mcp serve.test_images serve.test_web_sampling: 68 tests, OK (27.092 s). - python -m unittest serve.test_server serve.test_frontend serve.test_tool_call_envelope serve.test_answer_speed serve.test_gpu_roles_server serve.test_pool_cores: 405 tests, OK, 3 skipped (113.274 s). - node --check serve/web/app.js; git diff origin/main --check: passed. - Same fake MCP tool and PNG against official 0.2.2 and this branch: official ignores image_results and returns 0 images/no model_content/no cached file; this branch returns 1 image/model_content/1 cached file. - Real service switched to this revision with the checksum-verified official CUDA13 engine 0.1.47 on RTX 5080. CPU vision, mmap experts, 16K context. Short text request returned the requested Chinese phrase; localhost and Tailscale health/page requests succeeded. Cached image download matched source SHA-256. - Final short-run sampled minimum free VRAM 3057 MiB and free RAM 54.17 GiB. Local deployment uses 5120 MiB VRAM reserve. These are operational smoke results, not a performance benchmark or PR defaults. **Failed / corrected during validation:** - Initial 32-token smoke exhausted its output in reasoning; the standard chat_template_kwargs enable_thinking=false request with 128-token limit returned the expected answer. - Initial local 3072 MiB reserve left about 1 GiB free VRAM. Unloaded and restarted with 5120 MiB reserve, then repeated the smoke successfully. - Non-fatal ResourceWarnings appeared in the CPU suite. **Not run:** - Fresh image/video generation, long-context stress, physical phone/Safari, Linux/macOS and the separate desktop UI. - Native builds: no native engine files differ from main; live testing used the official release engine. ## Limits Applies to serve/server.py and serve/web, not the separate apps/host or apps/desktop UI. No bundled search provider, ComfyUI, vision/generation model or GPU lifecycle controller. Cache retention is manual. No performance/quality claim. The local Python web service has been cut over; this is not a desktop-app integration. 0.2.2 overlap: upstream f2709679 already fixes part of the mobile tool-card overflow. The remaining reason for this PR is opt-in cached image transport, vision delivery, previews and downloads. MCP provider configuration and the standalone image-generation API already exist upstream; this PR does not introduce those capabilities. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:32:52 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4059
No description provided.