Skip to content

Commit 517c808

Browse files
HaystackBotsjrl
andcommitted
docs: sync Core Integrations API reference (mcp) on Docusaurus (#11704)
Co-authored-by: sjrl <10526848+sjrl@users.noreply.github.com>
1 parent a5f62df commit 517c808

14 files changed

Lines changed: 112 additions & 322 deletions

File tree

  • docs-website
    • reference_versioned_docs
      • version-2.18/integrations-api
      • version-2.19/integrations-api
      • version-2.20/integrations-api
      • version-2.21/integrations-api
      • version-2.22/integrations-api
      • version-2.23/integrations-api
      • version-2.24/integrations-api
      • version-2.25/integrations-api
      • version-2.26/integrations-api
      • version-2.27/integrations-api
      • version-2.28/integrations-api
      • version-2.29/integrations-api
      • version-2.30/integrations-api
    • reference/integrations-api

docs-website/reference/integrations-api/mcp.md

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,9 @@ Example using MCPToolset in a Haystack Pipeline:
787787
# 1. pip install uvx mcp-server-time # Install required MCP server and tools
788788
# 2. export OPENAI_API_KEY="your-api-key" # Set up your OpenAI API key
789789

790-
import os
791790
from haystack import Pipeline
792-
from haystack.components.converters import OutputAdapter
791+
from haystack.components.agents import Agent
793792
from haystack.components.generators.chat import OpenAIChatGenerator
794-
from haystack.components.tools import ToolInvoker
795793
from haystack.dataclasses import ChatMessage
796794
from haystack_integrations.tools.mcp import MCPToolset, StdioServerInfo
797795

@@ -805,30 +803,18 @@ mcp_toolset = MCPToolset(
805803
tool_names=["get_current_time"] # Only include the get_current_time tool
806804
)
807805

808-
# Create a pipeline with the toolset
806+
# Create a pipeline with an Agent that owns the tool-calling loop.
807+
# The Agent passes the toolset to the chat generator, executes any requested
808+
# tool calls, and continues until a final answer is produced.
809809
pipeline = Pipeline()
810-
pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o-mini", tools=mcp_toolset))
811-
pipeline.add_component("tool_invoker", ToolInvoker(tools=mcp_toolset))
812-
pipeline.add_component(
813-
"adapter",
814-
OutputAdapter(
815-
template="{{ initial_msg + initial_tool_messages + tool_messages }}",
816-
output_type=list[ChatMessage],
817-
unsafe=True,
818-
),
819-
)
820-
pipeline.add_component("response_llm", OpenAIChatGenerator(model="gpt-4o-mini"))
821-
pipeline.connect("llm.replies", "tool_invoker.messages")
822-
pipeline.connect("llm.replies", "adapter.initial_tool_messages")
823-
pipeline.connect("tool_invoker.tool_messages", "adapter.tool_messages")
824-
pipeline.connect("adapter.output", "response_llm.messages")
810+
pipeline.add_component("agent", Agent(chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"), tools=mcp_toolset))
825811

826812
# Run the pipeline with a user question
827813
user_input = "What is the time in New York? Be brief."
828814
user_input_msg = ChatMessage.from_user(text=user_input)
829815

830-
result = pipeline.run({"llm": {"messages": [user_input_msg]}, "adapter": {"initial_msg": [user_input_msg]}})
831-
print(result["response_llm"]["replies"][0].text)
816+
result = pipeline.run({"agent": {"messages": [user_input_msg]}})
817+
print(result["agent"]["messages"][-1].text)
832818
```
833819

834820
You can also use the toolset via Streamable HTTP to talk to remote servers:
@@ -873,7 +859,6 @@ Example using SSE (deprecated):
873859

874860
```python
875861
from haystack_integrations.tools.mcp import MCPToolset, SSEServerInfo
876-
from haystack.components.tools import ToolInvoker
877862

878863
# Create the toolset with an SSE connection
879864
sse_toolset = MCPToolset(
@@ -941,7 +926,7 @@ warm_up() -> None
941926

942927
Connect and load tools when eager_connect is turned off.
943928

944-
This method is automatically called by `ToolInvoker.warm_up()` and `Pipeline.warm_up()`.
929+
This method is automatically called by `Agent.warm_up()` and `Pipeline.warm_up()`.
945930
You can also call it directly before using the toolset to ensure all tool schemas
946931
are available without performing a real invocation.
947932

docs-website/reference_versioned_docs/version-2.18/integrations-api/mcp.md

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,9 @@ Example using MCPToolset in a Haystack Pipeline:
787787
# 1. pip install uvx mcp-server-time # Install required MCP server and tools
788788
# 2. export OPENAI_API_KEY="your-api-key" # Set up your OpenAI API key
789789

790-
import os
791790
from haystack import Pipeline
792-
from haystack.components.converters import OutputAdapter
791+
from haystack.components.agents import Agent
793792
from haystack.components.generators.chat import OpenAIChatGenerator
794-
from haystack.components.tools import ToolInvoker
795793
from haystack.dataclasses import ChatMessage
796794
from haystack_integrations.tools.mcp import MCPToolset, StdioServerInfo
797795

@@ -805,30 +803,18 @@ mcp_toolset = MCPToolset(
805803
tool_names=["get_current_time"] # Only include the get_current_time tool
806804
)
807805

808-
# Create a pipeline with the toolset
806+
# Create a pipeline with an Agent that owns the tool-calling loop.
807+
# The Agent passes the toolset to the chat generator, executes any requested
808+
# tool calls, and continues until a final answer is produced.
809809
pipeline = Pipeline()
810-
pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o-mini", tools=mcp_toolset))
811-
pipeline.add_component("tool_invoker", ToolInvoker(tools=mcp_toolset))
812-
pipeline.add_component(
813-
"adapter",
814-
OutputAdapter(
815-
template="{{ initial_msg + initial_tool_messages + tool_messages }}",
816-
output_type=list[ChatMessage],
817-
unsafe=True,
818-
),
819-
)
820-
pipeline.add_component("response_llm", OpenAIChatGenerator(model="gpt-4o-mini"))
821-
pipeline.connect("llm.replies", "tool_invoker.messages")
822-
pipeline.connect("llm.replies", "adapter.initial_tool_messages")
823-
pipeline.connect("tool_invoker.tool_messages", "adapter.tool_messages")
824-
pipeline.connect("adapter.output", "response_llm.messages")
810+
pipeline.add_component("agent", Agent(chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"), tools=mcp_toolset))
825811

826812
# Run the pipeline with a user question
827813
user_input = "What is the time in New York? Be brief."
828814
user_input_msg = ChatMessage.from_user(text=user_input)
829815

830-
result = pipeline.run({"llm": {"messages": [user_input_msg]}, "adapter": {"initial_msg": [user_input_msg]}})
831-
print(result["response_llm"]["replies"][0].text)
816+
result = pipeline.run({"agent": {"messages": [user_input_msg]}})
817+
print(result["agent"]["messages"][-1].text)
832818
```
833819

834820
You can also use the toolset via Streamable HTTP to talk to remote servers:
@@ -873,7 +859,6 @@ Example using SSE (deprecated):
873859

874860
```python
875861
from haystack_integrations.tools.mcp import MCPToolset, SSEServerInfo
876-
from haystack.components.tools import ToolInvoker
877862

878863
# Create the toolset with an SSE connection
879864
sse_toolset = MCPToolset(
@@ -941,7 +926,7 @@ warm_up() -> None
941926

942927
Connect and load tools when eager_connect is turned off.
943928

944-
This method is automatically called by `ToolInvoker.warm_up()` and `Pipeline.warm_up()`.
929+
This method is automatically called by `Agent.warm_up()` and `Pipeline.warm_up()`.
945930
You can also call it directly before using the toolset to ensure all tool schemas
946931
are available without performing a real invocation.
947932

docs-website/reference_versioned_docs/version-2.19/integrations-api/mcp.md

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,9 @@ Example using MCPToolset in a Haystack Pipeline:
787787
# 1. pip install uvx mcp-server-time # Install required MCP server and tools
788788
# 2. export OPENAI_API_KEY="your-api-key" # Set up your OpenAI API key
789789

790-
import os
791790
from haystack import Pipeline
792-
from haystack.components.converters import OutputAdapter
791+
from haystack.components.agents import Agent
793792
from haystack.components.generators.chat import OpenAIChatGenerator
794-
from haystack.components.tools import ToolInvoker
795793
from haystack.dataclasses import ChatMessage
796794
from haystack_integrations.tools.mcp import MCPToolset, StdioServerInfo
797795

@@ -805,30 +803,18 @@ mcp_toolset = MCPToolset(
805803
tool_names=["get_current_time"] # Only include the get_current_time tool
806804
)
807805

808-
# Create a pipeline with the toolset
806+
# Create a pipeline with an Agent that owns the tool-calling loop.
807+
# The Agent passes the toolset to the chat generator, executes any requested
808+
# tool calls, and continues until a final answer is produced.
809809
pipeline = Pipeline()
810-
pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o-mini", tools=mcp_toolset))
811-
pipeline.add_component("tool_invoker", ToolInvoker(tools=mcp_toolset))
812-
pipeline.add_component(
813-
"adapter",
814-
OutputAdapter(
815-
template="{{ initial_msg + initial_tool_messages + tool_messages }}",
816-
output_type=list[ChatMessage],
817-
unsafe=True,
818-
),
819-
)
820-
pipeline.add_component("response_llm", OpenAIChatGenerator(model="gpt-4o-mini"))
821-
pipeline.connect("llm.replies", "tool_invoker.messages")
822-
pipeline.connect("llm.replies", "adapter.initial_tool_messages")
823-
pipeline.connect("tool_invoker.tool_messages", "adapter.tool_messages")
824-
pipeline.connect("adapter.output", "response_llm.messages")
810+
pipeline.add_component("agent", Agent(chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"), tools=mcp_toolset))
825811

826812
# Run the pipeline with a user question
827813
user_input = "What is the time in New York? Be brief."
828814
user_input_msg = ChatMessage.from_user(text=user_input)
829815

830-
result = pipeline.run({"llm": {"messages": [user_input_msg]}, "adapter": {"initial_msg": [user_input_msg]}})
831-
print(result["response_llm"]["replies"][0].text)
816+
result = pipeline.run({"agent": {"messages": [user_input_msg]}})
817+
print(result["agent"]["messages"][-1].text)
832818
```
833819

834820
You can also use the toolset via Streamable HTTP to talk to remote servers:
@@ -873,7 +859,6 @@ Example using SSE (deprecated):
873859

874860
```python
875861
from haystack_integrations.tools.mcp import MCPToolset, SSEServerInfo
876-
from haystack.components.tools import ToolInvoker
877862

878863
# Create the toolset with an SSE connection
879864
sse_toolset = MCPToolset(
@@ -941,7 +926,7 @@ warm_up() -> None
941926

942927
Connect and load tools when eager_connect is turned off.
943928

944-
This method is automatically called by `ToolInvoker.warm_up()` and `Pipeline.warm_up()`.
929+
This method is automatically called by `Agent.warm_up()` and `Pipeline.warm_up()`.
945930
You can also call it directly before using the toolset to ensure all tool schemas
946931
are available without performing a real invocation.
947932

docs-website/reference_versioned_docs/version-2.20/integrations-api/mcp.md

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,9 @@ Example using MCPToolset in a Haystack Pipeline:
787787
# 1. pip install uvx mcp-server-time # Install required MCP server and tools
788788
# 2. export OPENAI_API_KEY="your-api-key" # Set up your OpenAI API key
789789

790-
import os
791790
from haystack import Pipeline
792-
from haystack.components.converters import OutputAdapter
791+
from haystack.components.agents import Agent
793792
from haystack.components.generators.chat import OpenAIChatGenerator
794-
from haystack.components.tools import ToolInvoker
795793
from haystack.dataclasses import ChatMessage
796794
from haystack_integrations.tools.mcp import MCPToolset, StdioServerInfo
797795

@@ -805,30 +803,18 @@ mcp_toolset = MCPToolset(
805803
tool_names=["get_current_time"] # Only include the get_current_time tool
806804
)
807805

808-
# Create a pipeline with the toolset
806+
# Create a pipeline with an Agent that owns the tool-calling loop.
807+
# The Agent passes the toolset to the chat generator, executes any requested
808+
# tool calls, and continues until a final answer is produced.
809809
pipeline = Pipeline()
810-
pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o-mini", tools=mcp_toolset))
811-
pipeline.add_component("tool_invoker", ToolInvoker(tools=mcp_toolset))
812-
pipeline.add_component(
813-
"adapter",
814-
OutputAdapter(
815-
template="{{ initial_msg + initial_tool_messages + tool_messages }}",
816-
output_type=list[ChatMessage],
817-
unsafe=True,
818-
),
819-
)
820-
pipeline.add_component("response_llm", OpenAIChatGenerator(model="gpt-4o-mini"))
821-
pipeline.connect("llm.replies", "tool_invoker.messages")
822-
pipeline.connect("llm.replies", "adapter.initial_tool_messages")
823-
pipeline.connect("tool_invoker.tool_messages", "adapter.tool_messages")
824-
pipeline.connect("adapter.output", "response_llm.messages")
810+
pipeline.add_component("agent", Agent(chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"), tools=mcp_toolset))
825811

826812
# Run the pipeline with a user question
827813
user_input = "What is the time in New York? Be brief."
828814
user_input_msg = ChatMessage.from_user(text=user_input)
829815

830-
result = pipeline.run({"llm": {"messages": [user_input_msg]}, "adapter": {"initial_msg": [user_input_msg]}})
831-
print(result["response_llm"]["replies"][0].text)
816+
result = pipeline.run({"agent": {"messages": [user_input_msg]}})
817+
print(result["agent"]["messages"][-1].text)
832818
```
833819

834820
You can also use the toolset via Streamable HTTP to talk to remote servers:
@@ -873,7 +859,6 @@ Example using SSE (deprecated):
873859

874860
```python
875861
from haystack_integrations.tools.mcp import MCPToolset, SSEServerInfo
876-
from haystack.components.tools import ToolInvoker
877862

878863
# Create the toolset with an SSE connection
879864
sse_toolset = MCPToolset(
@@ -941,7 +926,7 @@ warm_up() -> None
941926

942927
Connect and load tools when eager_connect is turned off.
943928

944-
This method is automatically called by `ToolInvoker.warm_up()` and `Pipeline.warm_up()`.
929+
This method is automatically called by `Agent.warm_up()` and `Pipeline.warm_up()`.
945930
You can also call it directly before using the toolset to ensure all tool schemas
946931
are available without performing a real invocation.
947932

docs-website/reference_versioned_docs/version-2.21/integrations-api/mcp.md

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,9 @@ Example using MCPToolset in a Haystack Pipeline:
787787
# 1. pip install uvx mcp-server-time # Install required MCP server and tools
788788
# 2. export OPENAI_API_KEY="your-api-key" # Set up your OpenAI API key
789789

790-
import os
791790
from haystack import Pipeline
792-
from haystack.components.converters import OutputAdapter
791+
from haystack.components.agents import Agent
793792
from haystack.components.generators.chat import OpenAIChatGenerator
794-
from haystack.components.tools import ToolInvoker
795793
from haystack.dataclasses import ChatMessage
796794
from haystack_integrations.tools.mcp import MCPToolset, StdioServerInfo
797795

@@ -805,30 +803,18 @@ mcp_toolset = MCPToolset(
805803
tool_names=["get_current_time"] # Only include the get_current_time tool
806804
)
807805

808-
# Create a pipeline with the toolset
806+
# Create a pipeline with an Agent that owns the tool-calling loop.
807+
# The Agent passes the toolset to the chat generator, executes any requested
808+
# tool calls, and continues until a final answer is produced.
809809
pipeline = Pipeline()
810-
pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o-mini", tools=mcp_toolset))
811-
pipeline.add_component("tool_invoker", ToolInvoker(tools=mcp_toolset))
812-
pipeline.add_component(
813-
"adapter",
814-
OutputAdapter(
815-
template="{{ initial_msg + initial_tool_messages + tool_messages }}",
816-
output_type=list[ChatMessage],
817-
unsafe=True,
818-
),
819-
)
820-
pipeline.add_component("response_llm", OpenAIChatGenerator(model="gpt-4o-mini"))
821-
pipeline.connect("llm.replies", "tool_invoker.messages")
822-
pipeline.connect("llm.replies", "adapter.initial_tool_messages")
823-
pipeline.connect("tool_invoker.tool_messages", "adapter.tool_messages")
824-
pipeline.connect("adapter.output", "response_llm.messages")
810+
pipeline.add_component("agent", Agent(chat_generator=OpenAIChatGenerator(model="gpt-4o-mini"), tools=mcp_toolset))
825811

826812
# Run the pipeline with a user question
827813
user_input = "What is the time in New York? Be brief."
828814
user_input_msg = ChatMessage.from_user(text=user_input)
829815

830-
result = pipeline.run({"llm": {"messages": [user_input_msg]}, "adapter": {"initial_msg": [user_input_msg]}})
831-
print(result["response_llm"]["replies"][0].text)
816+
result = pipeline.run({"agent": {"messages": [user_input_msg]}})
817+
print(result["agent"]["messages"][-1].text)
832818
```
833819

834820
You can also use the toolset via Streamable HTTP to talk to remote servers:
@@ -873,7 +859,6 @@ Example using SSE (deprecated):
873859

874860
```python
875861
from haystack_integrations.tools.mcp import MCPToolset, SSEServerInfo
876-
from haystack.components.tools import ToolInvoker
877862

878863
# Create the toolset with an SSE connection
879864
sse_toolset = MCPToolset(
@@ -941,7 +926,7 @@ warm_up() -> None
941926

942927
Connect and load tools when eager_connect is turned off.
943928

944-
This method is automatically called by `ToolInvoker.warm_up()` and `Pipeline.warm_up()`.
929+
This method is automatically called by `Agent.warm_up()` and `Pipeline.warm_up()`.
945930
You can also call it directly before using the toolset to ensure all tool schemas
946931
are available without performing a real invocation.
947932

0 commit comments

Comments
 (0)