fix(mcp): move policy into the ADT layer, where both callers inherit it - #53
Merged
Conversation
Probing the 77 MCP tools the way an agent calls them — over the protocol rather than through the CLI — found two commands that work from the command line and fail as tools. Both were my own fixes from earlier today, applied in the CLI handler: - `bw_application_log` answered HTTP 400 "Parameter username could not be found". The CLI defaults username and the timestamp window; the MCP handler passed nothing, so the tool called a route that requires all three. - `bw_validate` answered HTTP 500 "Action 'validate' is not valid". The CLI had been corrected to send `exists`, but the tool's own default still said `validate`, and its schema documented that as the default. The lesson is the layering, not the two bugs: policy that a route requires belongs where every caller passes through. BwGetApplicationLog now applies the defaults itself, and the CLI passes only what the user typed. The MCP validation tool no longer overrides the option default at all. Defaulting the username needed the session's own user, which nothing below the CLI could see, so IAdtSession gained LogonUser(). That is what made the CLI-only workaround necessary in the first place. Verified over the MCP protocol: bw_application_log with no arguments returns a feed, bw_validate returns an empty message list for a real object and a not-found error for a missing one. Also confirmed by the same sweep, and not defects: the six tools my probe called with wrong argument names declare those names correctly in their schemas, and bw_transport_check's /sap/bw/modeling/cto route is absent on this release, like the four dead BW routes already documented. The accessor is LogonUserName(), not LogonUser(): windows.h defines LogonUser as a macro expanding to LogonUserA, and httplib pulls windows.h in on the MSVC build, so the first name broke that platform only.
jrosskopf
force-pushed
the
fix/mcp-layering
branch
from
August 31, 2026 15:33
ecf7af6 to
3ea377e
Compare
… CLI Every other test in the suite drives the CLI, which left the blind spot this session kept falling into: a fix applied in the CLI handler can leave the same operation broken as a tool, and nothing noticed. It happened three times — bw applog and bw validate both worked from the command line while their tools answered HTTP 400 and 500. These speak JSON-RPC to `erpl-adt mcp` on stdin and assert the read-only tools answer without isError: the core ADT tools, the two BW tools that were broken as tools, that results carry structuredContent as data rather than a JSON string, and that tools/list gives every tool annotations and a title. One more asserts the silent-success contract holds for tools too: adt_run_atc, adt_run_tests and adt_check_syntax must report an error for an object that does not exist, not an empty finding list. Deliberately shallow — the point is coverage of the *path*. Each tool's semantics stay with the CLI tests, which already carry them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The audit's last sweep called all 77 MCP tools the way an agent does — over the protocol, not through the CLI — and found two commands that work from the command line and fail as tools.
Both were my own fixes from earlier in this session, applied in the CLI handler:
bw_application_logbw_validateexists; the tool's own default still saidvalidate, and its schema documented that as correctThe point isn't the two bugs
It's where the policy lived. A requirement the route imposes belongs where every caller passes through, not in one of two front ends.
BwGetApplicationLognow applies the defaults itself and the CLI passes only what the user typed; the validation tool no longer overrides the option default at all.Defaulting the username needed the session's own user, which nothing below the CLI could see — that gap is precisely why the workaround ended up in the CLI.
IAdtSessiongainedLogonUser(), so the next piece of policy has somewhere correct to go.Verified over the MCP protocol
1349 unit tests pass (two new ones assert the defaults are applied and that explicit values still win), plus the live integration suites for BW utils and the missing-target contract: 20 passed, 2 skipped.
Also checked, and not defects
cds_name,package_name,root_package,query,text_type) declare those names correctly in their schemas, includingrequired— the probe was wrong, not the tools.bw_transport_checkfails because/sap/bw/modeling/ctois absent on this release, like the four dead BW routes already documented in CLAUDE.md.Pushed through the GitHub API; the dev machine's SSH agent is still unreachable.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.