Skip to content

Normalize outbound MCP tool arguments - #1172

Merged
Bionic711 merged 2 commits into
Developmentfrom
fix/mcp-kwargs-argument-normalization
Aug 7, 2026
Merged

Normalize outbound MCP tool arguments#1172
Bionic711 merged 2 commits into
Developmentfrom
fix/mcp-kwargs-argument-normalization

Conversation

@Bionic711

Copy link
Copy Markdown
Collaborator

Motivation & Context

Outbound MCP tools that receive parameters through Semantic Kernel can arrive at SimpleChat as a single kwargs wrapper. Standards-compliant MCP servers expect tool parameters as top-level fields inside the tools/call arguments object, so wrapped payloads such as { "kwargs": { "type": "..." } } can make required fields invisible to servers such as Splunk MCP. This fixes issue #1163 so parameterized outbound MCP tools receive the expected argument shape while no-parameter tools and legitimate kwargs fields remain safe.

Description & Review Guide

What are the major changes?

  • Added schema-aware MCP tool-call argument normalization in functions_mcp_operations.py.
  • Wired normalization into McpPlugin.call_tool(...) before validation and invocation.
  • Added factory-level defense-in-depth in McpPluginFactory.call_tool_from_config(...) for direct factory callers with cached tool metadata.
  • Added functional_tests/test_mcp_tool_argument_normalization.py covering plugin and factory paths, direct top-level args, wrapped kwargs, legitimate kwargs schemas, and no-argument calls.
  • Bumped config.py to 0.250.127 and added release notes.

What is the impact of these changes?

  • Parameterized outbound MCP tools now forward required fields such as type at the top level expected by MCP servers.
  • Tools that explicitly define a real top-level kwargs property continue to receive that wrapper unchanged.
  • Factory calls without cached tool metadata stay conservative and do not guess/unwrap unknown tool payloads.

What do you want reviewers to focus on?

  • Human reviewers: please focus on the schema-aware unwrap conditions and whether the factory-level conservative behavior is the right compatibility tradeoff. Automated/AI reviewers should review the full change.

Local validation completed before opening this draft:

  • python functional_tests\test_mcp_tool_argument_normalization.py
  • python functional_tests\test_mcp_action_manifest_workflow.py
  • python functional_tests\test_mcp_phase2_probe_metadata.py
  • python functional_tests\test_mcp_destination_governance_and_preconfigurations.py
  • python functional_tests\test_local_mcp_server.py
  • python functional_tests\test_app_version_assertion_guardrails.py
  • python -m py_compile application\single_app\config.py application\single_app\functions_mcp_operations.py application\single_app\semantic_kernel_plugins\mcp_plugin.py application\single_app\semantic_kernel_plugins\mcp_plugin_factory.py functional_tests\test_mcp_tool_argument_normalization.py
  • python scripts\check_xss_sinks.py --full-file application\single_app\config.py application\single_app\functions_mcp_operations.py application\single_app\semantic_kernel_plugins\mcp_plugin.py application\single_app\semantic_kernel_plugins\mcp_plugin_factory.py
  • python scripts\check_broken_access_control.py --full-file application\single_app\config.py application\single_app\functions_mcp_operations.py application\single_app\semantic_kernel_plugins\mcp_plugin.py application\single_app\semantic_kernel_plugins\mcp_plugin_factory.py
  • git diff --check

Related Issue

Fixes #1163

Contribution Checklist

  • This is not a breaking change.
  • I added or updated tests to cover the change.
  • I updated release notes for the user-facing bug fix.
  • I ran targeted local validation for the changed MCP surfaces.

Unwrap schema-aware kwargs wrappers before outbound MCP validation and invocation so standards-compliant MCP servers receive required parameters at the top level. Add regression coverage for plugin and factory call paths while preserving legitimate kwargs fields.

Fixes #1163

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread functional_tests/test_mcp_tool_argument_normalization.py Fixed
Replace the unnecessary App Insights logger lambda in the MCP argument normalization functional test with the named no-op logger helper pattern used by nearby MCP tests. Update branch version metadata for the follow-up change.

Refs #1163

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Bionic711
Bionic711 marked this pull request as ready for review August 7, 2026 21:38
@Bionic711
Bionic711 merged commit 69137df into Development Aug 7, 2026
12 checks passed
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.

3 participants