Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix(mcp): preserve operation return docs

byte1024485bba791931
diff --git a/core/switch_core/bridges/agent/mcp/server.py b/core/switch_core/bridges/agent/mcp/server.py
index 8bd62fbfc..f66b5dd79 100644
--- a/core/switch_core/bridges/agent/mcp/server.py
+++ b/core/switch_core/bridges/agent/mcp/server.py
@@ -84,7 +84,7 @@ mcp.add_middleware(CallContextMiddleware())
# Every operation, registered as a tool. This loop is the only thing that makes
# an operation an MCP tool, so the two surfaces cannot diverge.
for _op in all_operations().values():
- mcp.tool(_op.fn)
+ mcp.tool(_op.fn, description=_op.description)
logger.debug("Registered %d operations as MCP tools", len(all_operations()))
diff --git a/core/tests/switch_core/bridges/agent/test_mcp_tool_surface.py b/core/tests/switch_core/bridges/agent/test_mcp_tool_surface.py
index 797749bad..274b8a9ba 100644
--- a/core/tests/switch_core/bridges/agent/test_mcp_tool_surface.py
+++ b/core/tests/switch_core/bridges/agent/test_mcp_tool_surface.py
@@ -13,6 +13,7 @@ from pathlib import Path
import pytest
from switch_core.bridges.agent.mcp.server import mcp
+from switch_core.bridges.agent.operations import all_operations
TASK_PROTOCOL_TOOLS = {
"delegate_task",
@@ -87,6 +88,14 @@ async def test_documented_tools_exist(tool_names: set[str]) -> None:
)
+async def test_tool_descriptions_preserve_the_full_operation_contract() -> None:
+ tools = {tool.name: tool for tool in await mcp.list_tools()}
+ operation = all_operations()["list_agents"]
+
+ assert tools[operation.name].description == operation.description
+ assert "Returns:" in tools[operation.name].description
+
+
SKILLS = sorted(
(Path(__file__).parents[5] / "connectors").glob("*/skills/switch/SKILL.md")
)