Skip to content

Python: dispatch MCP approval modes by kind in the declarative tool - #9865

Closed
Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/mcp-approval-mode-specify
Closed

Manohar Paturi (ManoharPaturi) wants to merge 1 commit into
microsoft:mainfrom
ManoharPaturi:fix/mcp-approval-mode-specify

Conversation

@ManoharPaturi

Copy link
Copy Markdown
Contributor

Motivation & Context

An MCP tool configured with approvalMode in specify mode could not be loaded. The dict form with its tool lists raised a TypeError because the tool parsed approval modes with the base class, which only carries the kind, and the simplified string form parsed into that base class instead of the specify subclass, so the agent loader never matched it and the approval configuration was silently dropped. The always and never modes only worked because the base class happens to hold all their state.

Description & Review Guide

  • What are the major changes? McpTool now parses approvalMode through the same kind based dispatch the top level component path uses, so every mode lands in its own subclass with its full state, and an unknown mode name is rejected with a clear error instead of silently parsing as the base mode.
  • What is the impact of these changes? Specs using specify mode load instead of crashing, the loader wires require_approval from the tool lists as intended, and existing always and never specs parse to the same subclasses they already used.
  • What do you want reviewers to focus on? The dispatch call replacing the direct base class construction, and the unknown mode rejection, which surfaces config errors at load time rather than ignoring them.

Related Issue

Fixes #9864

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

The tool parsed approvalMode with the base class, which only carries the kind, so specify mode with its tool lists raised a TypeError and the simplified string parsed into the base class that the loader never matches. Parsing now dispatches by kind like the top level component path, and an unknown mode name is rejected.

Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
@ManoharPaturi

Copy link
Copy Markdown
Contributor Author

Sorry about that, I should have waited. #9864 now carries the template with both failing shapes and the stack trace, and this PR stays closed until the team agrees with the direction.

This branch was previously deployed

1 inactive deployment
github-app-auth — 07ce160a Deployed Oct 30, 2026 by ManoharPaturi via team_check #8069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: declarative MCP approvalMode in specify mode fails to load

2 participants