Skip to content

refactor(mcp-parser): Generic method handling and improved logging#364

Merged
huang195 merged 5 commits into
rossoctl:mainfrom
huang195:refactor/mcp-parser-generic-logging
May 4, 2026
Merged

refactor(mcp-parser): Generic method handling and improved logging#364
huang195 merged 5 commits into
rossoctl:mainfrom
huang195:refactor/mcp-parser-generic-logging

Conversation

@huang195

@huang195 huang195 commented May 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Remove hardcoded method switch in MCP parser — all JSON-RPC methods are now handled uniformly
  • All methods logged at Info level with method name; payload logged at Debug (truncated to 128 chars)
  • MCPExtension simplified: stores raw Params map instead of method-specific sub-structs (Tool/Resource/Prompt)
  • Forward-compatible with future MCP protocol changes without code modifications

Logging behavior

  • level=INFO msg=mcp-parser method=tools/call
  • level=INFO msg=mcp-parser method=initialize
  • level=DEBUG msg="mcp-parser: payload" method=tools/call body={...truncated to 128 chars...}

Test plan

  • All authlib tests pass
  • All listener tests pass (extproc, extauthz, reverseproxy, forwardproxy)
  • Deploy and verify logs show method names for all MCP calls at Info level

Assisted-By: Claude (Anthropic AI) noreply@anthropic.com

Remove hardcoded method switch (tools/call, resources/read, prompts/get)
in favor of a generic approach that handles any MCP JSON-RPC method.
All methods are logged uniformly at Info level; payload is logged at
Debug level (truncated to 128 chars). MCPExtension now stores raw Params
instead of method-specific sub-structs, making the parser forward-compatible
with future MCP protocol changes.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
huang195 added 2 commits May 4, 2026 12:34
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
The container image has no standalone kill/grep/cat/tr binaries.
Replace broken instructions with a pure-bash-builtin one-liner that
finds the authbridge PID dynamically via /proc/*/cmdline.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>

@esnible esnible left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean refactor that simplifies the MCP parser by removing method-specific handling in favor of storing raw params. Forward-compatible design — new MCP methods won't require code changes.

One stale doc reference needs fixing (references a removed struct field), and two helper methods are now dead code.

Areas reviewed: Go (code + tests), Documentation (3 READMEs)
Commits: 3 commits, all signed-off ✓
CI status: all passing ✓


must-fix: authbridge/demos/mcp-parser/README.md line 288 still references pctx.Extensions.MCP.Tool.Name — this struct field no longer exists after this refactor. Readers trying to write policy plugins will get a compile error. Update to pctx.Extensions.MCP.Params["name"].

suggestion: authbridge/authlib/plugins/mcpparser.gostringParam() and mapParam() methods (lines 68-77) are now dead code with no callers. Consider removing them.

nit: authbridge/authlib/plugins/mcpparser.go line 12 — doc comment still says "populates … with the parsed method, tool name, resource URI, or prompt name" but now it stores raw params. A one-line update would keep this accurate.

Comment thread authbridge/authlib/plugins/mcpparser.go
- Update README reference from .Tool.Name to .Params["name"]
- Update MCPParser doc comment to reflect raw params design

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
@huang195

huang195 commented May 4, 2026

Copy link
Copy Markdown
Member Author

All three items addressed:

  1. must-fix (README stale reference): Updated pctx.Extensions.MCP.Tool.Namepctx.Extensions.MCP.Params["name"] (0b20251)
  2. suggestion (dead code): Removed stringParam() and mapParam() (983dba2). PR feat: Add A2A parser plugin for inbound request inspection #363 will re-add them when it merges.
  3. nit (doc comment): Updated to reflect "method, RPC ID, and raw params" (0b20251)

Dead code in this PR -- no callers remain after removing the method
switch. The A2A parser (PR rossoctl#363) will re-add them when it merges.

Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com>
Signed-off-by: Hai Huang <huang195@gmail.com>
@huang195
huang195 merged commit 44c2d2b into rossoctl:main May 4, 2026
17 checks passed
@huang195
huang195 deleted the refactor/mcp-parser-generic-logging branch May 4, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants