4545from ..util ._types import MaybeAwaitable
4646from .util import (
4747 HttpClientFactory ,
48+ MCPToolCustomDataExtractor ,
4849 MCPToolMetaResolver ,
4950 ToolFilter ,
5051 ToolFilterContext ,
@@ -229,6 +230,7 @@ def __init__(
229230 require_approval : RequireApprovalSetting = None ,
230231 failure_error_function : ToolErrorFunction | None | _UnsetType = _UNSET ,
231232 tool_meta_resolver : MCPToolMetaResolver | None = None ,
233+ custom_data_extractor : MCPToolCustomDataExtractor | None = None ,
232234 ):
233235 """
234236 Args:
@@ -248,13 +250,16 @@ def __init__(
248250 SDK default) will be used.
249251 tool_meta_resolver: Optional callable that produces MCP request metadata (`_meta`) for
250252 tool calls. It is invoked by the Agents SDK before calling `call_tool`.
253+ custom_data_extractor: Optional callable that produces SDK-only custom data for
254+ emitted MCP tool output items.
251255 """
252256 self .use_structured_content = use_structured_content
253257 self ._needs_approval_policy = self ._normalize_needs_approval (
254258 require_approval = require_approval
255259 )
256260 self ._failure_error_function = failure_error_function
257261 self .tool_meta_resolver = tool_meta_resolver
262+ self .custom_data_extractor = custom_data_extractor
258263
259264 @abc .abstractmethod
260265 async def connect (self ):
@@ -544,6 +549,7 @@ def __init__(
544549 require_approval : RequireApprovalSetting = None ,
545550 failure_error_function : ToolErrorFunction | None | _UnsetType = _UNSET ,
546551 tool_meta_resolver : MCPToolMetaResolver | None = None ,
552+ custom_data_extractor : MCPToolCustomDataExtractor | None = None ,
547553 ):
548554 """
549555 Args:
@@ -576,12 +582,15 @@ def __init__(
576582 SDK default) will be used.
577583 tool_meta_resolver: Optional callable that produces MCP request metadata (`_meta`) for
578584 tool calls. It is invoked by the Agents SDK before calling `call_tool`.
585+ custom_data_extractor: Optional callable that produces SDK-only custom data for
586+ emitted MCP tool output items.
579587 """
580588 super ().__init__ (
581589 use_structured_content = use_structured_content ,
582590 require_approval = require_approval ,
583591 failure_error_function = failure_error_function ,
584592 tool_meta_resolver = tool_meta_resolver ,
593+ custom_data_extractor = custom_data_extractor ,
585594 )
586595 self .session : ClientSession | None = None
587596 self .exit_stack : AsyncExitStack = AsyncExitStack ()
@@ -1108,6 +1117,7 @@ def __init__(
11081117 require_approval : RequireApprovalSetting = None ,
11091118 failure_error_function : ToolErrorFunction | None | _UnsetType = _UNSET ,
11101119 tool_meta_resolver : MCPToolMetaResolver | None = None ,
1120+ custom_data_extractor : MCPToolCustomDataExtractor | None = None ,
11111121 ):
11121122 """Create a new MCP server based on the stdio transport.
11131123
@@ -1145,6 +1155,8 @@ def __init__(
11451155 SDK default) will be used.
11461156 tool_meta_resolver: Optional callable that produces MCP request metadata (`_meta`) for
11471157 tool calls. It is invoked by the Agents SDK before calling `call_tool`.
1158+ custom_data_extractor: Optional callable that produces SDK-only custom data for
1159+ emitted MCP tool output items.
11481160 """
11491161 super ().__init__ (
11501162 cache_tools_list = cache_tools_list ,
@@ -1157,6 +1169,7 @@ def __init__(
11571169 require_approval = require_approval ,
11581170 failure_error_function = failure_error_function ,
11591171 tool_meta_resolver = tool_meta_resolver ,
1172+ custom_data_extractor = custom_data_extractor ,
11601173 )
11611174
11621175 self .params = StdioServerParameters (
@@ -1229,6 +1242,7 @@ def __init__(
12291242 require_approval : RequireApprovalSetting = None ,
12301243 failure_error_function : ToolErrorFunction | None | _UnsetType = _UNSET ,
12311244 tool_meta_resolver : MCPToolMetaResolver | None = None ,
1245+ custom_data_extractor : MCPToolCustomDataExtractor | None = None ,
12321246 ):
12331247 """Create a new MCP server based on the HTTP with SSE transport.
12341248
@@ -1268,6 +1282,8 @@ def __init__(
12681282 SDK default) will be used.
12691283 tool_meta_resolver: Optional callable that produces MCP request metadata (`_meta`) for
12701284 tool calls. It is invoked by the Agents SDK before calling `call_tool`.
1285+ custom_data_extractor: Optional callable that produces SDK-only custom data for
1286+ emitted MCP tool output items.
12711287 """
12721288 super ().__init__ (
12731289 cache_tools_list = cache_tools_list ,
@@ -1280,6 +1296,7 @@ def __init__(
12801296 require_approval = require_approval ,
12811297 failure_error_function = failure_error_function ,
12821298 tool_meta_resolver = tool_meta_resolver ,
1299+ custom_data_extractor = custom_data_extractor ,
12831300 )
12841301
12851302 self .params = params
@@ -1365,6 +1382,7 @@ def __init__(
13651382 require_approval : RequireApprovalSetting = None ,
13661383 failure_error_function : ToolErrorFunction | None | _UnsetType = _UNSET ,
13671384 tool_meta_resolver : MCPToolMetaResolver | None = None ,
1385+ custom_data_extractor : MCPToolCustomDataExtractor | None = None ,
13681386 ):
13691387 """Create a new MCP server based on the Streamable HTTP transport.
13701388
@@ -1405,6 +1423,8 @@ def __init__(
14051423 SDK default) will be used.
14061424 tool_meta_resolver: Optional callable that produces MCP request metadata (`_meta`) for
14071425 tool calls. It is invoked by the Agents SDK before calling `call_tool`.
1426+ custom_data_extractor: Optional callable that produces SDK-only custom data for
1427+ emitted MCP tool output items.
14081428 """
14091429 super ().__init__ (
14101430 cache_tools_list = cache_tools_list ,
@@ -1417,6 +1437,7 @@ def __init__(
14171437 require_approval = require_approval ,
14181438 failure_error_function = failure_error_function ,
14191439 tool_meta_resolver = tool_meta_resolver ,
1440+ custom_data_extractor = custom_data_extractor ,
14201441 )
14211442
14221443 self .params = params
0 commit comments