PostMessageTransport: make debug logging opt-in (or accept a logger)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 70/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- developer-experience, tooling
Research direction
The issue points to src/message-transport.ts, specifically lines where console.debug is called. Start by examining the PostMessageTransport constructor and its current signature. The task is to add an optional third argument for a logger, defaulting to no logging. Check how the transport is instantiated elsewhere in the codebase to ensure backward compatibility. Write a test to verify logging only occurs when a logger is provided.
Written by the indexing model from the issue text.
Description
Problem
PostMessageTransport calls console.debug unconditionally (src/message-transport.ts at 264d9ca, lines 77, 82, 87 and 128):
- "Sending message" for every outgoing message except
tool-input-partial - "Parsed message" for every valid incoming message
- "Ignoring message from unknown source" for every message from another frame
A host cannot turn these off. The transport takes no option for it, and the only workaround is wrapping console.debug globally.
The noise grows with the number of Apps on a page. Each card's host transport listens on the same window, so a message from any View reaches every bridge. The owning bridge logs "Parsed message", and each of the other N−1 bridges logs "Ignoring message from unknown source" with the full MessageEvent. With four cards in a conversation, every View message produces four host lines, plus the View's own "Sending message" inside its frame. Size changes and host-context updates fan out the same way.
The source check is correct. Only the logging is the problem.
Prior discussion
- #237 / #239 moved the unknown-source log from
console.errortoconsole.debug. - #546 skipped the log for
tool-input-partialbecause it flooded the console. - #741 asked for opt-in logging or a configurable logger, and noted that full payloads, including tool-result
_meta, reach the console. Its filer closed it without a change.
Proposal
Make transport logging opt-in through an options argument:
new PostMessageTransport(eventTarget, eventSource, { logger?: Pick<Console, "debug"> })
Log nothing when logger is absent. The console.error for a malformed JSON-RPC message can stay. The third argument keeps the existing constructor compatible.
Happy to open a PR if this direction works.
Seen on 1.7.5; unchanged on main as of v2.0.0.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 387
- Avg merge
- 2h 54m
- Merged PRs (30d)
- 7
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from modelcontextprotocol/ext-apps
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
modelcontextprotocol/ext-apps#767 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
modelcontextprotocol/ext-apps#742 · 1 comment ·
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
modelcontextprotocol/ext-apps#711 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
modelcontextprotocol/ext-apps#706 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
modelcontextprotocol/ext-apps#703 · 1 reaction ·
All issues in modelcontextprotocol/ext-apps
Similar issues
-
VerificationGate: ATTRIBUTION quote guard never matches a normal quotation (\b around the quote) Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
danielmiessler/LifeOS#2234 ·
-
T: Bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Mend: dependency security vulnerability untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 70/100