Repository navigation
fix(mcp): trim tool descriptions and add ServerInstructions - #761
Conversation
Cut tool/param Description novels down to one job plus a failure mode, fix get_device_status so it mentions digital channels, and send the four README session rules as MCP ServerInstructions. Co-authored-by: Tyler Kron <tylerkron@gmail.com>
…pture-rate guidance Three follow-ups on the trim: - ServerInstructions is now per-server rather than a const. The `--read-only` bullet was sent to every session, including the ones where writes are allowed — noise, and a hint that writes might be refused on a server where they will not be. It is now included only when the server actually runs read-only, and phrased as a statement about this server. - capture_samples kept losing the only text that says how to read measuredRateHz / deviceClockRateHz against sampleRateHz. Nothing else the agent can see carries it: the DTO's XML docs are not in the output schema, which is built from [Description] attributes. Restored compactly, along with "configure channels and the sample rate first". - set_analog_output's "(latch is device-wide)" was too cryptic to act on. Says what that actually costs you: latch=true also applies values staged earlier on other channels. Contract tests: the timeout-parameter test now asserts the clamp range is still documented (the part an agent cannot get anywhere else) instead of listing prose fragments that must not appear, and the tool-description budget goes to 450 so it stays a guardrail against essays rather than a style rule. Verified end to end over stdio that the SDK puts `instructions` in the initialize result, with and without --read-only. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
/agentic_review |
Code Review by Qodo
1.
|
|
Reviewed (Claude): APPROVE — the trim is real (about 6,000 characters, roughly 1,500 tokens, off every |
PR Summary by QodoStreamline MCP descriptions and add session instructions
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
|
Code review by qodo was updated up to the latest commit 9ae0ee6 |
…iptions-e818 # Conflicts: # src/Daqifi.Mcp/Tools/DaqifiTools.cs
…e real handshake Two review findings on the ServerInstructions change: - The "retrieve before you stream" rule told every client that a live stream collapses the SD buffer and empties later downloads. That is firmware #703, which firmware 3.7.3 fixed. v3.7.2 is still the latest stable release, so the advice still matters, but stated unconditionally it is wrong for any device on the fix. The handshake rule, the download_sd_file description and the README now say "on firmware below 3.7.3", and point at the firmwareVersion discover_devices already returns. The recovery step now says "power-cycled" rather than "reconnected", which is what the firmware issue and SdCardEmptyTransferException both say clears it. - The instruction tests read ServerOptions.Instructions directly, so they stayed green with the o.ServerInstructions assignment in Program.cs deleted. ServerInstructionsHandshakeTests now starts the real server over stdio with the SDK's own client and reads `instructions` off the initialize result, with and without --read-only. Deleting the assignment turns both red on net9.0 and net10.0. The direct tests they replace are removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit 8bf8d1c |
Scoping the SD-collapse rule to "firmware below 3.7.3" left no safe default. Discovery can report an empty firmwareVersion (mDNS, HID, WiFi) or "Unknown" (serial), and a client that cannot classify the device could read the rule as not applying, stream first, and hit the empty downloads. The handshake rule, the download_sd_file description and the README now say to retrieve before streaming unless discover_devices reports 3.7.3 or later, and to treat an empty or unknown version as older. The contract and handshake tests pin that wording. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/agentic_review |
|
Code review by qodo was updated up to the latest commit a59dab9 |
|
Qodo-clean, CI green — ready for review |
StartupArgumentTests and #761's ServerInstructionsHandshakeTests each carried an identical DotnetHost() and server-dll lookup. Both now use ServerProcess. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve DaqifiTools.cs against #761: keep main's [McpServerTool] lines and trimmed [Description] text on every tool, and add UseStructuredContent = true. Program.cs auto-merged: main's ServerInstructions plus WithDaqifiTools(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
StartupArgumentTests and #761's ServerInstructionsHandshakeTests each carried an identical DotnetHost() and server-dll lookup. Both now use ServerProcess. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What was wrong
The tool descriptions are the only documentation an AI client ever sees, and they had grown into essays.
list_analog_outputsran to a thousand characters.capture_samples,read_channel_values,disable_pwm,get_server_infoand thetimeoutMs/durationMsparameters retold bench measurements and firmware history. Every client pays for all of it on everytools/list, in context-window space that would otherwise hold the user's actual data.Two smaller problems came with it:
get_device_statussaid it returned "enabled analog channels", but it has always returned digital ones too. So an agent had no reason to call it to check a DIO pin.How it was fixed
tools/list(roughly 1,500 tokens).get_device_statusnow names analog and digital channels.ServerInstructions. Clients pass these to the model as context, so a rule can be stated without paying for it on every request.initialize.Review notes (Claude)
instructionsin theinitializeresult. The field isn't set and then dropped. This is now a test:ServerInstructionsHandshakeTestsrunsdaqifi-mcp.dllfrom the test output with the SDK's ownMcpClient, with and without--read-only. Commenting outo.ServerInstructions = ...in Program.cs turns both tests red on net9.0 and net10.0.--read-onlyrule is conditional. Sent to every session, including ones where writes are allowed, it was noise, plus a hint that writes might be refused on a server where they won't be. It now appears only when the server really is running--read-only, phrased as a statement about this server.firmwareVersionthatdiscover_devicesalready returns is 3.7.3 or later. Discovery can report an empty or"Unknown"version, so those count as older (second Qodo round). The same wording is in the handshake, indownload_sd_file, and in the MCP README. The recovery step now says "power-cycled" rather than "reconnected", which matches the firmware issue andSdCardEmptyTransferException.capture_samples. It was the only text telling an agent how to readmeasuredRateHz/deviceClockRateHzagainstsampleRateHz. Nothing else the agent can see carries it: the output schema is generated from[Description]attributes, so the DTO's XML doc comments never reach it. Also put back "configure channels and the sample rate first".set_analog_output. "(latch is device-wide)" was too cryptic to act on. It now says what that costs you:latch=truealso applies values staged earlier on other channels.Tests
Full
dotnet testgreen on net9.0 and net10.0 (4342 Core + 278 MCP).Merge order
This branch has merged main, with #744's tool hints already in. Each conflict took main's
[McpServerTool(...)]line and this PR's[Description]line. It still rewrites the[Description]line next to the[McpServerTool]attribute that #750 (UseStructuredContent) rewrites on all 26 tools, and it touches Program.cs'sAddMcpServerblock, which #765 also edits. Whichever of these lands second will need a rebase.🤖 Generated with Claude Code