Repository navigation
[Bug] dsh-mcp-client: server instructions over 32 KB never connect, and the real error is only in ctx.logger #10548
jamesweiym-ops
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Version: dsh
0.2.1-rc.2· nodev22.22.2· macOS arm64 · MCP SDK@modelcontextprotocol/client 2.2.0Component:
@deepseek-ai/dsh-mcp-client(bothstdioandstreamable-httptransports)Version: dsh
0.2.1-rc.2, nodev22.22.2, macOS (darwin arm64)MCP SDK in use:
@modelcontextprotocol/client 2.2.0TL;DR
maxInstructionBytesdefaults to 32 768 (lib/index.js:441,:494). The check runs after a successfulconnect()+initialize(i.e. the server is provably alive and its tools are ready), and it does not truncate — it throws and drops the whole connection:That throw is caught at
:658and reported only throughctx.logger.warn. With the defaultfailOnStartupError: false(:788,:797) the host keeps running with zero tools registered, and every later operation fails with:So a spec-compliant server with a 33 KB instruction block is indistinguishable from a dead one, and nothing in the visible output mentions instructions, the limit, or the config key that fixes it.
Real-world trigger:
https://klox.ai/mcpships 32 984 bytes ofinstructions— over the limit by 216 bytes.Reproduce (≈2 minutes, no credentials, no network)
Minimal stdio MCP server that advertises an oversized
instructionsfield —stub-big-instructions.mjs(attached below, zero dependencies, speak newline-delimited JSON-RPC):node stub-big-instructions.mjs 40000 # 40 000-byte instructionsOverlay it onto any profile with a one-entry patch:
dsh headless --patch ./stub-repro.patch.yml "reply ok"Observed
With the default
failOnStartupError: false(what most users run), the same run succeeds with no error at all, and the server simply has no tools; the only symptom ismcp-client(stubbig): server is disconnectedon first use.Expected
Either the connection succeeds, or the failure says what happened and how to fix it — at minimum naming
maxInstructionBytes. Ideally it succeeds with the instructions truncated to the cap, because the text is only used for prompt injection and carries no protocol meaning.Root cause
lib/index.js:441const DEFAULT_MAX_INSTRUCTION_BYTES = 32768lib/index.js:494config.maxInstructionBytes ?? 32768lib/index.js:656generation.connect()succeeded → throws, connection discardedlib/index.js:658ctx.logger.warn(...)only;closeGeneration()+settleFailedGeneration()lib/index.js:687server is disconnectedlib/index.js:832failOnStartupError: true, wrapped asinitial connection or tool synchronization failed(cause is what carries the useful text)lib/index.js:789,:798.describe()onmaxInstructionBytes— the key is discoverable only by reading sourcelib/index.js:434-439maxAttempts: 10, backoff to 30 s), re-spawning the child process each time before giving up with "tools unregistered"Two independent problems compound here:
instructions; a rich server easily exceeds 32 KB. Rejecting the connection for a field that merely gets prepended to the model prompt is disproportionate.mcp-client(klox): server is disconnectedand spent hours excluding tokens, OAuth, transports, SSE reconnects and agent-scope lifecycle — all of which were healthy. The actual cause appeared the first time we launched an isolatedDSH_HOMEwithconsole.errorpatched in.Suggested fixes (in order of value)
maxInstructionBytes, append\n\n…[instructions truncated: 32984 bytes total], and log a warning. The field is a prompt prefix; truncation degrades gracefully, disconnection does not.Infinity+ warning, avoids a class of support tickets.mcp-client(klox): server instructions are 32984 bytes, over maxInstructionBytes (32768); set maxInstructionBytes in this server's plugin config to raise the limitfailOnStartupError: false. A host-level warning (agent status / GUI notice) such asMCP server klox unavailable: instructions exceed maxInstructionBytes (32768)would have ended this investigation in one minute. Today the only channel isctx.logger, which is not written to the launcher log on adsh weblaunchd setup.maxInstructionBytesvia.describe()in the zod schema so it appears in--dump-config-schema.Workaround (works today)
Setting it on our config made all 29 tools register immediately, with no other change.
Appendix: stub server used above
stub-big-instructions.mjs— dependency-free stdio MCP server; answersinitialize(with an N-byteinstructions),notifications/initialized,tools/list,ping; exits on stdin EOF.Sanity check that the stub really is a valid, oversized server (uses the same SDK version DSH ships):
All reactions