refactor: move mcp discovered tool specs helper

This commit is contained in:
lda
2026-06-08 10:34:56 +07:00 Verified
parent 42a4412c95
commit ec3414c1cb
8 changed files with 649 additions and 15 deletions
+2
View File
@@ -65,6 +65,7 @@ __all__ = [
"model_from_schema",
"neutral_auth_from_mcp",
"registry_entry_to_connection_config",
"specs_from_discovered_tools",
"tool_call_completed_event",
"tool_call_started_event",
"ToolWrapperEvent",
@@ -106,6 +107,7 @@ def __getattr__(name: str) -> object:
if name in {
"DiscoveredConnectionCapabilities",
"discover_connection_capabilities",
"specs_from_discovered_tools",
}:
from . import discovery
+29 -2
View File
@@ -7,10 +7,13 @@ from typing import Any, TypeVar
from mcp import McpError
from mcp.types import METHOD_NOT_FOUND
from wf_authoring import NodeSpec
from wf_sources_mcp.auth import AuthRecord
from wf_sources_mcp.catalog import DiscoveredPrompt, DiscoveredResource, DiscoveredTool
from wf_sources_mcp.connections import McpSourceConnection
from wf_sources_mcp.sdk import BackendAdapter
from wf_sources_mcp.sdk import BackendAdapter, ToolExecutor
from wf_sources_mcp.tool_events import ToolWrapperEventSink
from wf_sources_mcp.tool_wrappers import wrap_discovered_tool
_CapabilityT = TypeVar("_CapabilityT")
@@ -74,4 +77,28 @@ def _root_exception(exc: BaseException) -> BaseException:
return current
__all__ = ["DiscoveredConnectionCapabilities", "discover_connection_capabilities"]
def specs_from_discovered_tools(
*,
connection: McpSourceConnection,
auth: AuthRecord | None,
executor: ToolExecutor,
tools: list[DiscoveredTool],
emit_event: ToolWrapperEventSink | None = None,
) -> list[NodeSpec[Any, Any]]:
return [
wrap_discovered_tool(
connection=connection,
auth=auth,
executor=executor,
tool=tool,
emit_event=emit_event,
)
for tool in tools
]
__all__ = [
"DiscoveredConnectionCapabilities",
"discover_connection_capabilities",
"specs_from_discovered_tools",
]