|
5 | 5 | Tool,
|
6 | 6 | )
|
7 | 7 | import ssl
|
8 |
| -from .models import Enqueue, Fanout, ListQueues |
| 8 | +from .models import Enqueue, Fanout, ListQueues, ListExchanges |
9 | 9 | from .logger import Logger, LOG_LEVEL
|
10 | 10 | from .connection import RabbitMQConnection, validate_rabbitmq_name
|
11 |
| -from .handlers import handle_enqueue, handle_fanout, handle_list_queues |
| 11 | +from .handlers import handle_enqueue, handle_fanout, handle_list_queues, handle_list_exchanges |
12 | 12 | from .admin import RabbitMQAdmin
|
13 | 13 |
|
14 | 14 |
|
@@ -43,6 +43,11 @@ async def list_tools() -> list[Tool]:
|
43 | 43 | name="list_queues",
|
44 | 44 | description="""List all the queues in the broker""",
|
45 | 45 | inputSchema=ListQueues.model_json_schema(),
|
| 46 | + ), |
| 47 | + Tool( |
| 48 | + name="list_exchanges", |
| 49 | + description="""List all the exchanges in the broker""", |
| 50 | + inputSchema=ListExchanges.model_json_schema(), |
46 | 51 | )
|
47 | 52 | ]
|
48 | 53 |
|
@@ -90,6 +95,14 @@ async def call_tool(
|
90 | 95 | logger.error(f"{e}")
|
91 | 96 | return [TextContent(type="text", text=str("failed"))]
|
92 | 97 | return [TextContent(type="text", text=str("succeeded"))]
|
| 98 | + elif name == "list_exchanges": |
| 99 | + try: |
| 100 | + admin = RabbitMQAdmin(rabbitmq_host, api_port, username, password, use_tls) |
| 101 | + result = handle_list_exchanges(admin) |
| 102 | + return [TextContent(type="text", text=str(result))] |
| 103 | + except Exception as e: |
| 104 | + logger.error(f"{e}") |
| 105 | + return [TextContent(type="text", text=str("failed"))] |
93 | 106 | raise ValueError(f"Tool not found: {name}")
|
94 | 107 |
|
95 | 108 | options = server.create_initialization_options()
|
|
0 commit comments