Skip to content

Commit 7683197

Browse files
committed
Remove Annotated
1 parent 6210130 commit 7683197

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

azure/functions/decorators/function_app.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
AssistantQueryInput, AssistantPostInput, InputType, EmbeddingsInput, \
4545
semantic_search_system_prompt, \
4646
SemanticSearchInput, EmbeddingsStoreOutput
47-
from .mcp import MCPToolTrigger, _TYPE_MAPPING, _extract_type_and_description
47+
from .mcp import MCPToolTrigger, _TYPE_MAPPING
4848
from .retry_policy import RetryPolicy
4949
from .function_name import FunctionName
5050
from .warmup import WarmUpTrigger
@@ -1603,15 +1603,14 @@ def decorator(fb: FunctionBuilder) -> FunctionBuilder:
16031603
continue
16041604
param_type_hint = param.annotation if param.annotation != inspect.Parameter.empty else str # noqa
16051605
# Parse type and description from type hint
1606-
actual_type, param_desc = _extract_type_and_description(
1607-
param_name, param_type_hint)
1606+
actual_type = param_type_hint
16081607
if actual_type is MCPToolContext:
16091608
continue
16101609
property_type = _TYPE_MAPPING.get(actual_type, "string")
16111610
tool_properties.append({
16121611
"propertyName": param_name,
16131612
"propertyType": property_type,
1614-
"description": param_desc,
1613+
"description": "",
16151614
})
16161615

16171616
tool_properties_json = json.dumps(tool_properties)
@@ -1634,7 +1633,7 @@ async def wrapper(context: str, *args, **kwargs):
16341633
call_kwargs = {}
16351634
for param_name, param in sig.parameters.items():
16361635
param_type_hint = param.annotation if param.annotation != inspect.Parameter.empty else str # noqa
1637-
actual_type, _ = _extract_type_and_description(param_name, param_type_hint)
1636+
actual_type = param_type_hint
16381637
if actual_type is MCPToolContext:
16391638
call_kwargs[param_name] = content
16401639
elif param_name in arguments:

azure/functions/decorators/mcp.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
33
from typing import Optional
4-
from typing import Any, Tuple, get_args, get_origin, Annotated
4+
from datetime import datetime
55

66
from azure.functions.decorators.constants import (
77
MCP_TOOL_TRIGGER
@@ -14,6 +14,8 @@
1414
float: "number",
1515
str: "string",
1616
bool: "boolean",
17+
object: "object",
18+
datetime: "string"
1719
}
1820

1921

@@ -34,14 +36,3 @@ def __init__(self,
3436
self.description = description
3537
self.tool_properties = tool_properties
3638
super().__init__(name=name, data_type=data_type)
37-
38-
39-
# Helper to extract actual type and description from Annotated types
40-
def _extract_type_and_description(param_name: str, type_hint: Any) -> Tuple[Any, str]:
41-
if get_origin(type_hint) is Annotated:
42-
args = get_args(type_hint)
43-
actual_type = args[0]
44-
# Use first string annotation as description if present
45-
param_description = next((a for a in args[1:] if isinstance(a, str)), f"The {param_name} parameter.") # noqa
46-
return actual_type, param_description
47-
return type_hint, f"The {param_name} parameter."

0 commit comments

Comments
 (0)