Create a chuk-term table for tools (does not print it).
(tools: list[ToolInfo], show_details: bool = False)
| 35 | |
| 36 | |
| 37 | def create_tools_table(tools: list[ToolInfo], show_details: bool = False): |
| 38 | """Create a chuk-term table for tools (does not print it).""" |
| 39 | # Prepare data for table |
| 40 | headers = ["Server", "Tool", "Description"] |
| 41 | if show_details: |
| 42 | headers.append("Parameters") |
| 43 | |
| 44 | # Convert to list of dicts for chuk-term's format_table |
| 45 | rows = [] |
| 46 | for tool in tools: |
| 47 | display_data = format_tool_for_display(tool, show_details) |
| 48 | row_dict = { |
| 49 | "Server": display_data["server"], |
| 50 | "Tool": display_data["name"], |
| 51 | "Description": display_data["description"], |
| 52 | } |
| 53 | if show_details: |
| 54 | row_dict["Parameters"] = display_data.get("parameters", "None") |
| 55 | rows.append(row_dict) |
| 56 | |
| 57 | # Create a chuk-term table |
| 58 | table = format_table(rows, title=f"{len(tools)} Available Tools", columns=headers) |
| 59 | |
| 60 | # Return the table object |
| 61 | return table |
| 62 | |
| 63 | |
| 64 | def create_servers_table(servers: list[ServerInfo]): |