Repository navigation
Open
Labels
triageUsage: [Issues], Target: All issues that still need to be triagedUsage: [Issues], Target: All issues that still need to be triaged
Description
Observed Behavior
McpTool parses its approvalMode with the base McpServerApprovalMode, which only accepts kind. Two shapes fail:
- The dict form with the specify mode and its tool lists raises
TypeError, crashing the load of any spec that uses an MCP tool in specify mode. - The string form
"specify"(and{kind: specify}without lists) parses into the base class instead ofMcpServerToolSpecifyApprovalMode, and the agent loader dispatchesrequire_approvalby checking for the specify subclass, so the approval configuration is silently dropped and default approval rules apply.
Expected Behavior
Every documented approval mode parses into its own subclass with its full state on both the dict and simplified string forms, so the loader can wire require_approval from the tool lists.
Steps to Reproduce
- Build
McpTool.from_dictwithapprovalMode: {kind: specify, alwaysRequireApprovalTools: [...], neverRequireApprovalTools: [...]}. - Observe the TypeError.
- Build the same tool with
approvalMode: "specify"and checktype(tool.approvalMode).
Minimal Reproduction
from agent_framework_declarative._models import McpTool
tool = McpTool.from_dict({
"kind": "mcp", "name": "srv",
"approvalMode": {
"kind": "specify",
"alwaysRequireApprovalTools": ["alpha"],
"neverRequireApprovalTools": ["beta"],
},
})
# TypeError: McpServerApprovalMode.__init__() got an unexpected keyword argument 'alwaysRequireApprovalTools'
tool = McpTool.from_dict({"kind": "mcp", "name": "srv", "approvalMode": "specify"})
# type(tool.approvalMode) is McpServerApprovalMode (base), not McpServerToolSpecifyApprovalModeError Messages and Stack Traces
TypeError: McpServerApprovalMode.__init__() got an unexpected keyword argument 'alwaysRequireApprovalTools'
Package Versions
agent-framework-declarative: 1.4.0 (main @ 4d28d0a)
Python Version
Python 3.12.13
Operating System
macOS
Regression
Unknown
Additional Context
The always and never modes work only because the base class happens to hold all their state. agent_schema_dispatch already builds the specify subclass correctly when the approval mode is loaded as a top level component, so the tool parsing could dispatch by kind the same way. I have a fix ready once the team agrees with the direction.
Acknowledgements
- I searched existing issues and did not find a duplicate.
- I personally verified this behavior and the reproduction details are authentic.
- I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.
Metadata
Metadata
Assignees
Labels
triageUsage: [Issues], Target: All issues that still need to be triagedUsage: [Issues], Target: All issues that still need to be triaged
Type
Projects
- StatusShow more project fieldsNo status
Activity
eavanvalkenburg commentedon Oct 30, 2026
please use the defined issue templates and wait for the team to review before opening a PR Manohar Paturi (@ManoharPaturi)
[-]Declarative: MCP approvalMode in specify mode fails to load with tool lists[/-][+]Python: [Bug]: declarative MCP approvalMode in specify mode fails to load[/+]eavanvalkenburg commentedon Nov 9, 2026
/plan Plan the confirmed declarative MCP approval-mode parsing bug on current main before readiness. A list-bearing specify dictionary raises TypeError in McpServerApprovalMode.init. Independent exact-source probes also show that a supported explicit specify-mode object serializes with its subclass type marker but fails to reload through McpTool with a type-mismatch ValueError; existing serialized base-mode always payloads do round-trip and must remain usable. Reuse the existing approval classes and loader require_approval mapping, preserving both tool lists and current always/never behavior. Cover raw dictionaries, simplified strings, preconstructed modes, legacy base-mode type markers, subclass round-trips, nested agent loading, and exact loader kwargs. An empty specify string/dictionary has no tool lists, so do not claim independent policy loss from that form alone. Separate the supported-mode repair from the new unknown-kind rejection proposed by already closed #9865; do not silently introduce a validation/compatibility policy change. Determine the smallest correct production scope and serialization contract before calling this a minor fix. Keep triage, do not add ready-for-implementation, and defer assignment. The author is willing, but this is planning, not implementation approval or permission to reopen the closed PR.
github-actions commentedon Nov 9, 2026
Summary
McpToolalways parsesapprovalModewith the base classMcpServerApprovalMode, which only acceptskind(_models.pylines 737-814). I checked this by reading the source only. I did not run any code.The issue is real on current main, and it has three parts:
{kind: specify, alwaysRequireApprovalTools: [...], ...}is passed to the base class. The base__init__has no list parameters, so it raisesTypeError. This is a confirmed crash.McpServerToolSpecifyApprovalModeis a supported class. Itsto_dict()writestype: mcp_server_tool_specify_approval_mode, and the base class'sfrom_dict()expectsmcp_server_approval_mode.SerializationMixin.from_dicttherefore raisesValueError: Type mismatch. This agrees with your probes. The same logic also applies to the always/never subclasses, which I did not probe (see questions below).specify(string or{kind: specify}). This becomes a base-class object. The loader (_loader.py~808-825) checkskind == "always", then"never", thenisinstance(..., McpServerToolSpecifyApprovalMode). The base-class object fails that last check, so norequire_approvalis set. But there are no tool lists in this form, so this is not independent policy loss. It is a wrong type and a latent trap for anything that later adds lists.Always and never work today only because the base class holds all of their state. The loader branches on
kindfor those two.The top-level path already dispatches by kind.
agent_schema_dispatchmapsalways,neverandspecifyto their subclasses (lines ~1124-1128), and tests cover that attest_declarative_loader.py~269-300. The nestedMcpToolpath does not use it.Recommendation
Code change: warranted, but small and confined to the declarative package. Keep it labelled
triage, with noready-for-implementationlabel and no assignment yet. I would not call it a "minor fix" until the points under "Serialization contract" below are settled. There is no workaround short of constructingMcpServerToolSpecifyApprovalModeobjects in Python and never reloading them.Smallest production scope
_models.py, inside theMcpTool.__init__approval-mode normalisation._loader.pyalready maps the specify subclass torequire_approvalcorrectly. Once the right subclass arrives, it works.SerializationMixinis deliberate and should stay.Serialization contract (the real decision)
The marker is derived from the class name, so each class has its own
type:mcp_server_approval_modemcp_server_tool_specify_approval_modeFor loading, I propose the following rules. Maintainers should confirm them.
kind.always,neverandspecifygo to their subclasses, as the top-level dispatch does.typemarker. Legacy base-class markers must keep loading, so existing serialized base-mode payloads continue to work. Subclass markers must also load. This is the part that needs a careful look:from_dictrejects a marker that does not match the target class, so the code must pick the target class before calling it, or strip or normalisetype.to_dict()output for existing objects unless maintainers choose to.alwaysRequireApprovalToolsandneverRequireApprovalTools) through load and save."always"and"never". If the kind-dispatched classes round-trip correctly, nothing observable changes.Keep separate: unknown-kind rejection (Closes #9865)
Today an unknown
kindloads into the base class without error. Rejecting it would be a new compatibility and validation policy, not a repair of a supported mode. I suggest the repair keeps the existing fallback for unrecognised kinds (still the base class, so there is no behaviour change). Whether to reject them should be a separate, explicit decision, possibly with a deprecation step. It is not authorised by this plan.Proposed plan
This is a proposal only. No changes have been made.
Decide the contract. Maintainers confirm the rules above, especially which
typemarkers load and what is written on output.Change
McpToolnormalisation in_models.py. Replace the twoMcpServerApprovalMode.from_dict(...)calls with kind-based selection of the existing classes. Leave pre-builtMcpServerApprovalModeinstances untouched. Handle both the string form and the dict form, and tolerate legacy base-classtypemarkers.Tests in
test_declarative_models.pyandtest_declarative_loader.py:"always","never"and"specify": the first two behave as before, and"specify"gives the specify subclass with no lists.{kind: specify}forms: assert norequire_approval, with no policy-loss claim.typemarkers still load (always and never).to_dict()followed by loading again, for the specify subclass and for existing base always payloads.AgentFactoryfrom YAML with a specify block.require_approval == {"always": {"tool_names": [...]}, "never": {"tool_names": [...]}}. Also check always, never and the two single-list cases.kindkeeps its current behaviour (a pin test, so the policy decision stays separate).Done when the issue's two snippets load, specify tool lists survive a save and reload, existing always/never tests pass unchanged, and the declarative test suite is green.
Questions before readiness
typemarker (today's behaviour), or shouldMcpToolserialise thekindform only? This decides whether old and new readers can exchange payloads.McpTool) also be covered, or only specify? By the same logic it should fail to reload today, but I did not verify it.The author is willing, but this is planning only. Please wait for maintainer agreement on the contract before any implementation work.
ManoharPaturi commentedon Nov 10, 2026
Eduard van Valkenburg (@eavanvalkenburg) should i start working on this ?