Skip to content

feat(mcp): bounded tool results, authenticated HTTP transport, and e2e 402 loop (closes #416, closes #419, closes #423) - #450

Open
sparkysolutions10-pixel wants to merge 2 commits into
Divinity-Labs:mainfrom
sparkysolutions10-pixel:feat/mcp-bounded-transport-e2e-416-419-423
Open

sparkysolutions10-pixel wants to merge 2 commits into
Divinity-Labs:mainfrom
sparkysolutions10-pixel:feat/mcp-bounded-transport-e2e-416-419-423

Conversation

@sparkysolutions10-pixel

@sparkysolutions10-pixel sparkysolutions10-pixel commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Addresses and resolves issues #416, #419, and #423 by implementing size-bounded tool results with explicit truncation notifications, streamable HTTP transport with mandatory authentication, and a deterministic end-to-end integration test verifying the complete 402 payment loop.

Key Changes

  1. Bounded Tool Results & Memory Protection (Tool results are unbounded #416):

    • Configurable response size boundary (maxResultBytes, env MCP_MAX_RESULT_BYTES, defaulting to 64KB).
    • Removed JSON pretty-printing indentation (null, 2), outputting compact serialization to prevent agent context window inflation.
    • Explicit truncation notifications: When tool output exceeds maxResultBytes, the output includes [TRUNCATED: Result exceeded limit of ... bytes] with isTruncated: true.
    • Bounded collection results: bazaar_search results are bounded to page limit (pageSize, default 20) with total count, returned count, and continuation guidance.
    • Streaming reader (readBoundedResponseBody): Cancels stream reading if an upstream body exceeds maxUpstreamBytes, preventing oversized or hostile responses from being buffered in full in memory.
  2. Streamable HTTP Transport with Authentication (There is no HTTP transport, only stdio #419):

    • Configurable transport (transport: 'http' | 'stdio', env MCP_TRANSPORT, defaulting to stdio).
    • Stdio remains the default for local processes.
    • Remote HTTP transport exposes identical tools via @modelcontextprotocol/sdk/server/streamableHttp.js.
    • Mandatory authentication: HTTP transport strictly requires an API key (MCP_API_KEY), refusing unauthenticated or invalid requests immediately with 401 Unauthorized to protect funds and resources.
    • Documented stdio vs HTTP execution in README.md.
  3. End-to-End 402 Payment Loop Verification (No test drives a real 402 payment loop #423):

    • Comprehensive deterministic integration test driving the complete 402 payment cycle:
      • Ephemeral testnet keypair generation via Keypair.random() (zero committed secrets, zero mainnet accounts).
      • Challenge response with PAYMENT-REQUIRED header.
      • Signed client payload asserting exact amount (0.25), destination account (payTo), and network (stellar:testnet).
      • Second response carrying verified payload and PAYMENT-RESPONSE header.
      • Covers refusal when amount exceeds maxPrice (ERR_PAYMENT_REJECTED).
      • Covers signature expiration mapping (ERR_EXPIRED_AUTHORISATION).
      • 100% deterministic, requiring zero external network access.
  4. Changeset & Tests:

    • Added .changeset/mcp-bounded-transport-and-e2e-402.md.
    • Comprehensive Vitest suite in tests/mcp.test.ts (13 tests, all passing).

Closes #416
Closes #419
Closes #423

@Miracle656 Miracle656 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested: one issue per PR, and only issues assigned to you

This is a process requirement, applied to all 23 of your open PRs in this repo. It is not a judgement about the code, which I have not been able to review — and that is the first half of the problem.

The bundling

Across your open PRs, 150 distinct issues are claimed. This one claims several. #483 claims 22, #481 claims 20, #477 claims 20, #474 claims 20.

A PR that closes twenty issues cannot be reviewed. Each of those issues has its own acceptance criteria — typically five — so twenty issues is a hundred separate things to verify in one diff, and if any one of them is wrong the whole PR is blocked while it is fixed. Every batch I published says the issues are deliberately independent so they can be worked in parallel, by different people, without colliding. Bundling them removes exactly that property.

The assignments

135 of the 150 issues claimed are assigned to other contributors — 67 different people.

This PR is an example: it names issues currently assigned to other contributors who are working on them now. Several have open PRs of their own. If this merged as it stands, those people would have done the work and received nothing for it, and I would have no way to tell the two efforts apart.

I am not assuming anything about why. Assignments change, Drips and GitHub can disagree, and a wide-ranging branch picks up issue numbers easily. But the effect on the people holding those assignments is the same regardless of intent, which is why I have to act on it.

What I need

  • One issue per PR. The issue number in the title, its acceptance criteria met, and nothing else in the diff.
  • Only issues assigned to you, or unassigned ones you have claimed through Drips. If an issue is assigned to someone else, it is theirs.
  • Re-open the work that meets both conditions as individual PRs. I will review them in the order they arrive and at the same pace as everyone else's.

Nothing is being closed. These stay open and are yours to re-cut, withdraw or split as you choose.

Two things worth knowing before you re-cut

Some of this has already landed. #488 (SSRF guard for bazaar_search) and #487 (the paid_call host allow-list) cover the same ground as your #449; #486 covers the MCP README. Check current main before rebuilding something that is already there.

main has moved a long way today — #306, #309, #252, #256, #355, #381, #390, #402, #476, #488 and more. Cut from current main, not from where these branches started.

If you believe an issue named here is genuinely yours, say which and I will check the assignment myself — I would rather be corrected than have someone lose work.

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.

No test drives a real 402 payment loop There is no HTTP transport, only stdio Tool results are unbounded

2 participants