MCPcopy Create free account
hub / github.com/IBM/mcp-cli / _build_server_tool_groups

Method _build_server_tool_groups

src/mcp_cli/chat/chat_context.py:543–564  ·  view source on GitHub ↗

Build server-to-tools grouping for the system prompt.

(self)

Source from the content-addressed store, hash-verified

541 self._system_prompt_dirty = False
542
543 def _build_server_tool_groups(self) -> list[ServerToolGroup]:
544 """Build server-to-tools grouping for the system prompt."""
545 if not self.server_info:
546 return []
547
548 # Group tools by server namespace
549 server_tools: dict[str, list[str]] = {}
550 for tool_name, namespace in self.tool_to_server_map.items():
551 server_tools.setdefault(namespace, []).append(tool_name)
552
553 groups = []
554 for server in self.server_info:
555 tools = server_tools.get(server.namespace, [])
556 if tools:
557 groups.append(
558 ServerToolGroup(
559 name=server.name,
560 description=server.display_description,
561 tools=sorted(tools),
562 )
563 )
564 return groups
565
566 async def _initialize_tools(
567 self,

Calls 2

ServerToolGroupClass · 0.90
getMethod · 0.45

Tested by 2