-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
When MCPToolset is initialized, we try to make a connection to the MCP server and raise an MCPConnectionError if no connection can be established.
mcp_toolset = MCPToolset(
server_info=server_info,
tool_names=["get_current_time"]
)
This is problematic when a pipeline gets validated, for example to validate a pipeline template that uses an MCPToolset with a GitHub MCP server requiring authentication:
tools:
data:
server_info:
type: haystack_integrations.tools.mcp.mcp_tool.StreamableHttpServerInfo
url: https://api.githubcopilot.com/mcp/
token:
env_vars:
- GITHUB_PAT
strict: false
type: env_var
timeout: 900
tool_names: [get_issue, list_pull_requests]
type: haystack_integrations.tools.mcp.MCPToolset
full example here with the error here.
The problem is that at the time of pipeline validation, the authentication token to connect to the MCP server, is not set yet. We need to enable pipeline validation without raising an error connecting to the MCP server. The pipeline validation calls the init of MCPToolset.
Other Haystack components have a warmup method. Maybe that could be an option here to reduced the init? Or have a parameter in the init that let's users specify if a connection should be established at initialization time.