Skip to content

Commit 177748a

Browse files
authored
Fix mcp contract. (#42307)
* Fix mcp contract. * Fix deep research * Regenerate code
1 parent 43700e2 commit 177748a

File tree

12 files changed

+178
-28
lines changed

12 files changed

+178
-28
lines changed

sdk/ai/azure-ai-agents/apiview-properties.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
"azure.ai.agents.models.FunctionName": "Azure.AI.Agents.FunctionName",
4242
"azure.ai.agents.models.FunctionToolDefinition": "Azure.AI.Agents.FunctionToolDefinition",
4343
"azure.ai.agents.models.IncompleteRunDetails": "Azure.AI.Agents.IncompleteRunDetails",
44+
"azure.ai.agents.models.MCPApprovalPerTool": "Azure.AI.Agents.MCPApprovalPerTool",
4445
"azure.ai.agents.models.MCPToolDefinition": "Azure.AI.Agents.MCPToolDefinition",
46+
"azure.ai.agents.models.MCPToolList": "Azure.AI.Agents.MCPToolList",
4547
"azure.ai.agents.models.MCPToolResource": "Azure.AI.Agents.MCPToolResource",
4648
"azure.ai.agents.models.MessageAttachment": "Azure.AI.Agents.MessageAttachment",
4749
"azure.ai.agents.models.MessageContent": "Azure.AI.Agents.MessageContent",
@@ -122,6 +124,8 @@
122124
"azure.ai.agents.models.RunStepDeltaFileSearchToolCall": "Azure.AI.Agents.RunStepDeltaFileSearchToolCall",
123125
"azure.ai.agents.models.RunStepDeltaFunction": "Azure.AI.Agents.RunStepDeltaFunction",
124126
"azure.ai.agents.models.RunStepDeltaFunctionToolCall": "Azure.AI.Agents.RunStepDeltaFunctionToolCall",
127+
"azure.ai.agents.models.RunStepDeltaMCPObject": "Azure.AI.Agents.RunStepDeltaMCPObject",
128+
"azure.ai.agents.models.RunStepDeltaMcpToolCall": "Azure.AI.Agents.RunStepDeltaMcpToolCall",
125129
"azure.ai.agents.models.RunStepDeltaMessageCreation": "Azure.AI.Agents.RunStepDeltaMessageCreation",
126130
"azure.ai.agents.models.RunStepDeltaMessageCreationObject": "Azure.AI.Agents.RunStepDeltaMessageCreationObject",
127131
"azure.ai.agents.models.RunStepDeltaToolCallObject": "Azure.AI.Agents.RunStepDeltaToolCallObject",

sdk/ai/azure-ai-agents/azure/ai/agents/_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
VectorStoreFileBatchesOperations,
2626
VectorStoreFilesOperations,
2727
VectorStoresOperations,
28+
_AgentsClientOperationsMixin,
2829
)
29-
from .operations._operations import _AgentsClientOperationsMixin
3030

3131
if TYPE_CHECKING:
3232
from azure.core.credentials import TokenCredential

sdk/ai/azure-ai-agents/azure/ai/agents/_patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=line-too-long,useless-suppression,too-many-lines
1+
# pylint: disable=line-too-long,useless-suppression,too-many-lines
22
# ------------------------------------
33
# Copyright (c) Microsoft Corporation.
44
# Licensed under the MIT License.

sdk/ai/azure-ai-agents/azure/ai/agents/_types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
88
# --------------------------------------------------------------------------
99

10-
from typing import List, TYPE_CHECKING, Union
10+
from typing import List, Literal, TYPE_CHECKING, Union
1111

1212
if TYPE_CHECKING:
1313
from . import models as _models
14+
MCPRequiredApproval = Union[str, Literal["never"], Literal["always"], "_models.MCPApprovalPerTool"]
1415
MessageInputContent = Union[str, List["_models.MessageInputContentBlock"]]
1516
MessageAttachmentToolDefinition = Union["_models.CodeInterpreterToolDefinition", "_models.FileSearchToolDefinition"]
1617
AgentsToolChoiceOption = Union[str, str, "_models.AgentsToolChoiceOptionMode", "_models.AgentsNamedToolChoice"]

sdk/ai/azure-ai-agents/azure/ai/agents/aio/_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
VectorStoreFileBatchesOperations,
2626
VectorStoreFilesOperations,
2727
VectorStoresOperations,
28+
_AgentsClientOperationsMixin,
2829
)
29-
from .operations._operations import _AgentsClientOperationsMixin
3030

3131
if TYPE_CHECKING:
3232
from azure.core.credentials_async import AsyncTokenCredential

sdk/ai/azure-ai-agents/azure/ai/agents/aio/operations/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ._operations import VectorStoresOperations # type: ignore
2121
from ._operations import VectorStoreFilesOperations # type: ignore
2222
from ._operations import VectorStoreFileBatchesOperations # type: ignore
23+
from ._operations import _AgentsClientOperationsMixin # type: ignore # pylint: disable=unused-import
2324

2425
from ._patch import __all__ as _patch_all
2526
from ._patch import *

sdk/ai/azure-ai-agents/azure/ai/agents/models/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@
5353
FunctionName,
5454
FunctionToolDefinition,
5555
IncompleteRunDetails,
56+
MCPApprovalPerTool,
5657
MCPToolDefinition,
58+
MCPToolList,
5759
MCPToolResource,
5860
MessageAttachment,
5961
MessageContent,
@@ -132,6 +134,8 @@
132134
RunStepDeltaFileSearchToolCall,
133135
RunStepDeltaFunction,
134136
RunStepDeltaFunctionToolCall,
137+
RunStepDeltaMCPObject,
138+
RunStepDeltaMcpToolCall,
135139
RunStepDeltaMessageCreation,
136140
RunStepDeltaMessageCreationObject,
137141
RunStepDeltaToolCall,
@@ -267,7 +271,9 @@
267271
"FunctionName",
268272
"FunctionToolDefinition",
269273
"IncompleteRunDetails",
274+
"MCPApprovalPerTool",
270275
"MCPToolDefinition",
276+
"MCPToolList",
271277
"MCPToolResource",
272278
"MessageAttachment",
273279
"MessageContent",
@@ -346,6 +352,8 @@
346352
"RunStepDeltaFileSearchToolCall",
347353
"RunStepDeltaFunction",
348354
"RunStepDeltaFunctionToolCall",
355+
"RunStepDeltaMCPObject",
356+
"RunStepDeltaMcpToolCall",
349357
"RunStepDeltaMessageCreation",
350358
"RunStepDeltaMessageCreationObject",
351359
"RunStepDeltaToolCall",

sdk/ai/azure-ai-agents/azure/ai/agents/models/_models.py

Lines changed: 152 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,18 +1181,18 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
11811181
class DeepResearchDetails(_Model):
11821182
"""The details of the Deep Research tool.
11831183
1184-
:ivar deep_research_model: The deep research model deployment name. Required.
1185-
:vartype deep_research_model: str
1186-
:ivar deep_research_bing_grounding_connections: The array containing Bing grounding connection
1187-
IDs to enhance deep research capabilities. Required.
1188-
:vartype deep_research_bing_grounding_connections:
1184+
:ivar model: The deep research model deployment name. Required.
1185+
:vartype model: str
1186+
:ivar bing_grounding_connections: The array containing Bing grounding connection IDs to enhance
1187+
deep research capabilities. Required.
1188+
:vartype bing_grounding_connections:
11891189
list[~azure.ai.agents.models.DeepResearchBingGroundingConnection]
11901190
"""
11911191

1192-
deep_research_model: str = rest_field(visibility=["read", "create", "update", "delete", "query"])
1192+
model: str = rest_field(name="deep_research_model", visibility=["read", "create", "update", "delete", "query"])
11931193
"""The deep research model deployment name. Required."""
1194-
deep_research_bing_grounding_connections: List["_models.DeepResearchBingGroundingConnection"] = rest_field(
1195-
name="bing_grounding_connections", visibility=["read", "create", "update", "delete", "query"]
1194+
bing_grounding_connections: List["_models.DeepResearchBingGroundingConnection"] = rest_field(
1195+
visibility=["read", "create", "update", "delete", "query"]
11961196
)
11971197
"""The array containing Bing grounding connection IDs to enhance deep research capabilities.
11981198
Required."""
@@ -1201,8 +1201,8 @@ class DeepResearchDetails(_Model):
12011201
def __init__(
12021202
self,
12031203
*,
1204-
deep_research_model: str,
1205-
deep_research_bing_grounding_connections: List["_models.DeepResearchBingGroundingConnection"],
1204+
model: str,
1205+
bing_grounding_connections: List["_models.DeepResearchBingGroundingConnection"],
12061206
) -> None: ...
12071207

12081208
@overload
@@ -1753,6 +1753,39 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
17531753
super().__init__(*args, **kwargs)
17541754

17551755

1756+
class MCPApprovalPerTool(_Model):
1757+
"""Customized MCP approval object, listing tools requiring and not requiring approvals.
1758+
1759+
:ivar never: The list of tools, not requiring approval.
1760+
:vartype never: ~azure.ai.agents.models.MCPToolList
1761+
:ivar always: The list of tools, always requiring approval.
1762+
:vartype always: ~azure.ai.agents.models.MCPToolList
1763+
"""
1764+
1765+
never: Optional["_models.MCPToolList"] = rest_field(visibility=["read", "create", "update", "delete", "query"])
1766+
"""The list of tools, not requiring approval."""
1767+
always: Optional["_models.MCPToolList"] = rest_field(visibility=["read", "create", "update", "delete", "query"])
1768+
"""The list of tools, always requiring approval."""
1769+
1770+
@overload
1771+
def __init__(
1772+
self,
1773+
*,
1774+
never: Optional["_models.MCPToolList"] = None,
1775+
always: Optional["_models.MCPToolList"] = None,
1776+
) -> None: ...
1777+
1778+
@overload
1779+
def __init__(self, mapping: Mapping[str, Any]) -> None:
1780+
"""
1781+
:param mapping: raw JSON to initialize the model.
1782+
:type mapping: Mapping[str, Any]
1783+
"""
1784+
1785+
def __init__(self, *args: Any, **kwargs: Any) -> None:
1786+
super().__init__(*args, **kwargs)
1787+
1788+
17561789
class MCPToolDefinition(ToolDefinition, discriminator="mcp"):
17571790
"""The input definition information for a MCP tool which defines a MCP server endpoint.
17581791
@@ -1795,35 +1828,63 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
17951828
super().__init__(*args, type="mcp", **kwargs)
17961829

17971830

1831+
class MCPToolList(_Model):
1832+
"""The object, containing list of tools for approvals.
1833+
1834+
:ivar tool_names: The list of tools for approval. Required.
1835+
:vartype tool_names: list[str]
1836+
"""
1837+
1838+
tool_names: List[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
1839+
"""The list of tools for approval. Required."""
1840+
1841+
@overload
1842+
def __init__(
1843+
self,
1844+
*,
1845+
tool_names: List[str],
1846+
) -> None: ...
1847+
1848+
@overload
1849+
def __init__(self, mapping: Mapping[str, Any]) -> None:
1850+
"""
1851+
:param mapping: raw JSON to initialize the model.
1852+
:type mapping: Mapping[str, Any]
1853+
"""
1854+
1855+
def __init__(self, *args: Any, **kwargs: Any) -> None:
1856+
super().__init__(*args, **kwargs)
1857+
1858+
17981859
class MCPToolResource(_Model):
17991860
"""A set of resources that are used by the ``mcp`` tool.
18001861
18011862
:ivar server_label: The label for the MCP server. Required.
18021863
:vartype server_label: str
18031864
:ivar headers: The headers for the MCP server updates. Required.
18041865
:vartype headers: dict[str, str]
1805-
:ivar require_approval: Does MCP server require approval. Is one of the following types:
1806-
Literal["never"], Literal["always"], str
1807-
:vartype require_approval: str or str or str
1866+
:ivar require_approval: Does MCP server require approval. Is one of the following types: str,
1867+
Literal["never"], Literal["always"], MCPApprovalPerTool
1868+
:vartype require_approval: str or str or str or ~azure.ai.agents.models.MCPApprovalPerTool
18081869
"""
18091870

18101871
server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"])
18111872
"""The label for the MCP server. Required."""
18121873
headers: Dict[str, str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
18131874
"""The headers for the MCP server updates. Required."""
1814-
require_approval: Optional[Union[Literal["never"], Literal["always"], str]] = rest_field(
1875+
require_approval: Optional["_types.MCPRequiredApproval"] = rest_field(
18151876
visibility=["read", "create", "update", "delete", "query"]
18161877
)
1817-
"""Does MCP server require approval. Is one of the following types: Literal[\"never\"],
1818-
Literal[\"always\"], str"""
1878+
"""Does MCP server require approval. Is one of the following types: str, Literal[\"never\"],
1879+
Literal[\"always\"], MCPApprovalPerTool"""
18191880

18201881
@overload
18211882
def __init__(
18221883
self,
18231884
*,
18241885
server_label: str,
18251886
headers: Dict[str, str],
1826-
require_approval: Optional[Union[Literal["never"], Literal["always"], str]] = None,
1887+
require_approval: Optional["_types.MCPRequiredApproval"] = None,
18271888
) -> None: ...
18281889

18291890
@overload
@@ -4653,7 +4714,7 @@ class RunStepDeltaToolCall(_Model):
46534714
46544715
You probably want to use the sub-classes and not this class directly. Known sub-classes are:
46554716
RunStepDeltaCodeInterpreterToolCall, RunStepDeltaFileSearchToolCall,
4656-
RunStepDeltaFunctionToolCall
4717+
RunStepDeltaFunctionToolCall, RunStepDeltaMcpToolCall
46574718
46584719
:ivar index: The index of the tool call detail in the run step's tool_calls array. Required.
46594720
:vartype index: int
@@ -4739,7 +4800,7 @@ class RunStepDeltaDetail(_Model):
47394800
"""Represents a single run step detail item in a streaming run step's delta payload.
47404801
47414802
You probably want to use the sub-classes and not this class directly. Known sub-classes are:
4742-
RunStepDeltaMessageCreation, RunStepDeltaToolCallObject
4803+
RunStepDeltaMCPObject, RunStepDeltaMessageCreation, RunStepDeltaToolCallObject
47434804
47444805
:ivar type: The object type for the run step detail object. Required. Default value is None.
47454806
:vartype type: str
@@ -4887,6 +4948,78 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
48874948
super().__init__(*args, type="function", **kwargs)
48884949

48894950

4951+
class RunStepDeltaMCPObject(RunStepDeltaDetail, discriminator="mcp"):
4952+
"""Represents an invocation of mcp as part of a streaming run step.
4953+
4954+
:ivar type: The object type, which is always "mcp". Required. Default value is "mcp".
4955+
:vartype type: str
4956+
:ivar tool_calls: The collection of tool calls for the tool call detail item.
4957+
:vartype tool_calls: list[~azure.ai.agents.models.RunStepDeltaMcpToolCall]
4958+
"""
4959+
4960+
type: Literal["mcp"] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore
4961+
"""The object type, which is always \"mcp\". Required. Default value is \"mcp\"."""
4962+
tool_calls: Optional[List["_models.RunStepDeltaMcpToolCall"]] = rest_field(
4963+
visibility=["read", "create", "update", "delete", "query"]
4964+
)
4965+
"""The collection of tool calls for the tool call detail item."""
4966+
4967+
@overload
4968+
def __init__(
4969+
self,
4970+
*,
4971+
tool_calls: Optional[List["_models.RunStepDeltaMcpToolCall"]] = None,
4972+
) -> None: ...
4973+
4974+
@overload
4975+
def __init__(self, mapping: Mapping[str, Any]) -> None:
4976+
"""
4977+
:param mapping: raw JSON to initialize the model.
4978+
:type mapping: Mapping[str, Any]
4979+
"""
4980+
4981+
def __init__(self, *args: Any, **kwargs: Any) -> None:
4982+
super().__init__(*args, type="mcp", **kwargs)
4983+
4984+
4985+
class RunStepDeltaMcpToolCall(RunStepDeltaToolCall, discriminator="mcp"):
4986+
"""Represents the function data in a streaming run step MCP call.*.
4987+
4988+
:ivar id: The ID of the tool call, used when submitting outputs to the run. Required.
4989+
:vartype id: str
4990+
:ivar type: The object type, which is always "mcp". Required. Default value is "mcp".
4991+
:vartype type: str
4992+
:ivar index: The index of a response. Required.
4993+
:vartype index: int
4994+
:ivar arguments: The arguments for MCP call. Required.
4995+
:vartype arguments: str
4996+
"""
4997+
4998+
type: Literal["mcp"] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore
4999+
"""The object type, which is always \"mcp\". Required. Default value is \"mcp\"."""
5000+
arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"])
5001+
"""The arguments for MCP call. Required."""
5002+
5003+
@overload
5004+
def __init__(
5005+
self,
5006+
*,
5007+
id: str, # pylint: disable=redefined-builtin
5008+
index: int,
5009+
arguments: str,
5010+
) -> None: ...
5011+
5012+
@overload
5013+
def __init__(self, mapping: Mapping[str, Any]) -> None:
5014+
"""
5015+
:param mapping: raw JSON to initialize the model.
5016+
:type mapping: Mapping[str, Any]
5017+
"""
5018+
5019+
def __init__(self, *args: Any, **kwargs: Any) -> None:
5020+
super().__init__(*args, type="mcp", **kwargs)
5021+
5022+
48905023
class RunStepDeltaMessageCreation(RunStepDeltaDetail, discriminator="message_creation"):
48915024
"""Represents a message creation within a streaming run step delta.
48925025

sdk/ai/azure-ai-agents/azure/ai/agents/models/_patch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,8 @@ def __init__(self, bing_grounding_connection_id: str, deep_research_model: str):
10851085
)
10861086

10871087
self._deep_research_details = DeepResearchDetails(
1088-
deep_research_model=deep_research_model,
1089-
deep_research_bing_grounding_connections=[
1088+
model=deep_research_model,
1089+
bing_grounding_connections=[
10901090
DeepResearchBingGroundingConnection(connection_id=bing_grounding_connection_id)
10911091
],
10921092
)

sdk/ai/azure-ai-agents/azure/ai/agents/operations/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from ._operations import VectorStoresOperations # type: ignore
2121
from ._operations import VectorStoreFilesOperations # type: ignore
2222
from ._operations import VectorStoreFileBatchesOperations # type: ignore
23+
from ._operations import _AgentsClientOperationsMixin # type: ignore # pylint: disable=unused-import
2324

2425
from ._patch import __all__ as _patch_all
2526
from ._patch import *

0 commit comments

Comments
 (0)