The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(mcp): rename the list_events utility to list_event_types
emozillae6548b932c57
diff --git a/cli-config.yaml.example b/cli-config.yaml.exampleindex 02232862d48..544f64cdb09 100644--- a/cli-config.yaml.example+++ b/cli-config.yaml.example@@ -1609,7 +1609,7 @@ platform_toolsets:# log_level: "info" # audit verbosity## MCP events (experimental, webhook delivery) — opt-in per server. Adds the-# list_events / subscribe_event / unsubscribe_event tools; needs+# list_event_types / subscribe_event / unsubscribe_event tools; needs# platforms.webhook.extra.public_url and a running gateway:# feeds:# url: https://feeds.example.com/mcpdiff --git a/tests/tools/test_mcp_events.py b/tests/tools/test_mcp_events.pyindex cc15bcc90d5..dad5e5b3371 100644--- a/tests/tools/test_mcp_events.py+++ b/tests/tools/test_mcp_events.py@@ -84,6 +84,19 @@ class TestUtilitySelection:assert not self._keys({}) & set(events.EVENT_UTILITY_KEYS)assert set(events.EVENT_UTILITY_KEYS) <= self._keys({"events": True})+ def test_a_native_list_events_tool_keeps_every_event_utility(self):+ # Calendar servers commonly ship a native ``list_events`` tool; a native tool shadows a utility+ # of the same name, which would leave the model no way to list event types.+ from tools import mcp_tool_registration as reg+ from tools.mcp_tool_schema import _build_utility_schemas+ native = SimpleNamespace(name="list_events", description="Calendar events", inputSchema={"type": "object"})+ utilities = [e for e in _build_utility_schemas("cal") if e["handler_key"] in events.EVENT_UTILITY_KEYS]+ candidates = reg._tool_candidates("cal", [native], lambda name: True, 30)+ candidates += reg._utility_candidates("cal", utilities, 30)+ kept = {c.origin for c in reg._resolve_name_collisions("cal", candidates)}+ assert "tool 'list_events'" in kept+ assert {f"generated utility {key!r}" for key in events.EVENT_UTILITY_KEYS} <= kept+class TestList:def test_listing_stops_at_the_page_cap(self, home):@@ -95,7 +108,7 @@ class TestList:await asyncio.sleep(0)return {"events": [{"name": f"e{Endless.calls}"}], "nextCursor": f"c{Endless.calls}"}- result = asyncio.run(asyncio.wait_for(events._list_events(Endless(), {}, "ambush"), timeout=5))+ result = asyncio.run(asyncio.wait_for(events._list_event_types(Endless(), {}, "ambush"), timeout=5))assert len(result["events"]) == Endless.calls == events._MAX_LIST_PAGESassert "truncated" in resultdiff --git a/tools/mcp_tool_events.py b/tools/mcp_tool_events.pyindex 84e72a3b30b..37cb47d517e 100644--- a/tools/mcp_tool_events.py+++ b/tools/mcp_tool_events.py@@ -27,7 +27,7 @@ from tools.registry import tool_errorlogger = logging.getLogger("tools.mcp_tool")-EVENT_UTILITY_KEYS = ("list_events", "subscribe_event", "unsubscribe_event")+EVENT_UTILITY_KEYS = ("list_event_types", "subscribe_event", "unsubscribe_event")_DEFAULT_TTL_MS = 24 * 3600 * 1000# Refresh once this share of the granted lifetime has elapsed (never later than 60s before expiry)._REFRESH_AT_FRACTION = 0.8@@ -317,7 +317,7 @@ def start_refresh_task(server) -> Optional[asyncio.Task]:# ---- utility tools -----async def _list_events(session, args: dict, server_name: str) -> dict:+async def _list_event_types(session, args: dict, server_name: str) -> dict:events, cursor, pages = [], None, 0while True:result = await _send(session, "events/list", {"cursor": cursor} if cursor else {})@@ -439,7 +439,7 @@ def _consent_error(server_name: str, args: dict) -> Optional[str]:return tool_error("The user did not approve this event subscription. Do not retry without explicit user direction.")-def _make_events_handler(op: str, label: str, rpc, needs_consent: bool = False):+def _make_events_handler(op: str, label: str, rpc, *, needs_name: bool = True, needs_consent: bool = False):"""Like ``mcp_tool_handlers._make_utility_handler``, with ``name`` required and an optional consent gate."""def _factory(server_name: str, tool_timeout: float):def _handler(args: dict, **kwargs) -> str:@@ -448,7 +448,7 @@ def _make_events_handler(op: str, label: str, rpc, needs_consent: bool = False):server = _discovery._get_connected_server_for_call(server_name)if not server or not server.session:return tool_error(f"MCP server '{server_name}' is not connected")- if label != "list_events" and not isinstance(args.get("name"), str):+ if needs_name and not isinstance(args.get("name"), str):return tool_error("Missing required parameter 'name'")if args.get("arguments") is not None and not isinstance(args["arguments"], dict):return tool_error("'arguments' must be an object")@@ -470,7 +470,8 @@ def _make_events_handler(op: str, label: str, rpc, needs_consent: bool = False):return _factory-_make_list_events_handler = _make_events_handler("events/list", "list_events", _list_events)+_make_list_event_types_handler = _make_events_handler(+ "events/list", "list_event_types", _list_event_types, needs_name=False)_make_subscribe_event_handler = _make_events_handler("events/subscribe", "subscribe_event", _subscribe_event, needs_consent=True)_make_unsubscribe_event_handler = _make_events_handler("events/unsubscribe", "unsubscribe_event", _unsubscribe_event)diff --git a/tools/mcp_tool_registration.py b/tools/mcp_tool_registration.pyindex 0e154ad6512..ea6431aaa13 100644--- a/tools/mcp_tool_registration.py+++ b/tools/mcp_tool_registration.py@@ -33,7 +33,7 @@ _UTILITY_ORIGIN_PREFIX = "generated utility "_UTILITY_HANDLER_FACTORIES = {"list_resources": _make_list_resources_handler, "read_resource": _make_read_resource_handler,"list_prompts": _make_list_prompts_handler, "get_prompt": _make_get_prompt_handler,- "list_events": _events._make_list_events_handler, "subscribe_event": _events._make_subscribe_event_handler,+ "list_event_types": _events._make_list_event_types_handler, "subscribe_event": _events._make_subscribe_event_handler,"unsubscribe_event": _events._make_unsubscribe_event_handler}diff --git a/tools/mcp_tool_schema.py b/tools/mcp_tool_schema.pyindex e3679494f6b..6ec03702959 100644--- a/tools/mcp_tool_schema.py+++ b/tools/mcp_tool_schema.py@@ -210,12 +210,12 @@ _UTILITY_TOOL_SPECS = ("properties": {},"additionalProperties": True},}, ["name"]),- ("list_events", "List the event types MCP server '{server}' can notify about, and your active "+ ("list_event_types", "List the event types MCP server '{server}' can notify about, and your active ""subscriptions to them", {}, None),("subscribe_event", "Subscribe to an event from MCP server '{server}': each occurrence starts a new ""agent run with your instructions and delivers its result to the chosen target",{- "name": {"type": "string", "description": "Event type name from list_events"},+ "name": {"type": "string", "description": "Event type name from list_event_types"},"arguments": {"type": "object","description": "Subscription arguments matching the event's inputSchema",@@ -289,4 +289,4 @@ def matches_name_filter(tool_name: str, patterns: set[str]) -> bool:_UTILITY_CAPABILITY_ATTRS = {"list_resources": "resources", "read_resource": "resources","list_prompts": "prompts", "get_prompt": "prompts",- "list_events": "events", "subscribe_event": "events", "unsubscribe_event": "events"}+ "list_event_types": "events", "subscribe_event": "events", "unsubscribe_event": "events"}diff --git a/website/docs/user-guide/features/mcp.md b/website/docs/user-guide/features/mcp.mdindex 923b30ca529..df4134a53a4 100644--- a/website/docs/user-guide/features/mcp.md+++ b/website/docs/user-guide/features/mcp.md@@ -1024,7 +1024,7 @@ platforms:The server then gets three more utility tools:-- `list_events`: the event types the server offers, and your current subscriptions to them+- `list_event_types`: the event types the server offers, and your current subscriptions to them- `subscribe_event`: subscribe with the event's arguments, what to do when it arrives(`instructions`, up to 2000 characters) and where each run's result goes (`deliver`,`deliver_chat_id`). You are asked to approve every subscription, since it starts unattended agent