Fix/payload size - #20
Conversation
📝 WalkthroughWalkthroughThe SSE server now uses Express with an 8MB JSON body limit, and persistent storage uploads stream file data in 1MB ChangesLarge Upload Handling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/index.ts`:
- Around line 3-5: Add host-header validation to the Express transport created
in src/index.ts, before exposing the /mcp route, to preserve the MCP SDK
helper’s DNS-rebinding protection. Reuse the SDK’s equivalent validation
mechanism or enforce the same allowed-host behavior in the Express middleware
without changing unrelated routes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 1b3ee9ae-5ffe-4a55-98c8-b7a20a159033
📒 Files selected for processing (2)
src/clients/nodeClient.tssrc/index.ts
| import { Wallet } from 'ethers' | ||
| import { randomUUID } from 'node:crypto' | ||
| import express from 'express' |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '== files ==\n'
git ls-files src/index.ts
printf '\n== outline ==\n'
ast-grep outline src/index.ts --view expanded || true
printf '\n== contents ==\n'
cat -n src/index.ts
printf '\n== search for MCP helpers/host validation ==\n'
rg -n "createMcpExpressApp|host-header|DNS-rebinding|rebind|validate.*host|allowedHosts|express\(\)" src . || trueRepository: oceanprotocol/on-mcp
Length of output: 9582
Preserve MCP host-header validation on the Express transport. express() removes the DNS-rebinding protection that the SDK helper provided, so add equivalent host-header checks before exposing /mcp over HTTP.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/index.ts` around lines 3 - 5, Add host-header validation to the Express
transport created in src/index.ts, before exposing the /mcp route, to preserve
the MCP SDK helper’s DNS-rebinding protection. Reuse the SDK’s equivalent
validation mechanism or enforce the same allowed-host behavior in the Express
middleware without changing unrelated routes.
Source: MCP tools
Fixes #19 .
Changes proposed in this PR:
Fixes upload_persistent_storage_file failing with 413 Payload Too Large for files over ~70KB on the hosted MCP: the HTTP transport's JSON body limit is raised from Express's 100KB default to 8MB, and uploads are now streamed to the node in 1MiB P2P frames instead of a single frame (which ocean-node capped at 4MiB). Agents can now upload ~6MB of raw file bytes per call — roughly 80× more than before — and larger files need only a handful of chunked calls instead of hundreds, cutting wasted requests and token spend.
Summary by CodeRabbit
Bug Fixes
Improvements