Skip to content

fix(mcp): move policy into the ADT layer, where both callers inherit it - #53

Merged
jrosskopf merged 2 commits into
mainfrom
fix/mcp-layering
Aug 31, 2026
Merged

fix(mcp): move policy into the ADT layer, where both callers inherit it#53
jrosskopf merged 2 commits into
mainfrom
fix/mcp-layering

Conversation

@jrosskopf

@jrosskopf jrosskopf commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

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:

Tool Failed with Because
bw_application_log HTTP 400 "Parameter username could not be found" The CLI defaults username and the timestamp window; the MCP handler passed nothing to a route that requires all three
bw_validate HTTP 500 "Action 'validate' is not valid" The CLI had been corrected to send exists; the tool's own default still said validate, and its schema documented that as correct

The 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. BwGetApplicationLog now 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. IAdtSession gained LogonUser(), so the next piece of policy has somewhere correct to go.

Verified over the MCP protocol

bw_application_log (no args)      isError=False  []
bw_validate (real object)         isError=False  []
bw_validate (missing object)      isError=True   {"category":"not_found", ...}

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

  • Six tools my probe called with wrong argument names (cds_name, package_name, root_package, query, text_type) declare those names correctly in their schemas, including required — the probe was wrong, not the tools.
  • bw_transport_check fails because /sap/bw/modeling/cto is 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.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

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.
… 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.
@jrosskopf
jrosskopf merged commit 44e826b into main Aug 31, 2026
5 checks passed
@jrosskopf
jrosskopf deleted the fix/mcp-layering branch August 31, 2026 16:05
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.

1 participant