@@ -56,6 +56,18 @@ async def call_tool(
56
56
logger .debug ("Executing enqueue tool" )
57
57
message = arguments ["message" ]
58
58
queue = arguments ["queue" ]
59
+
60
+ if not message or not message .strip ():
61
+ raise ValueError ("Message cannot be empty" )
62
+ if not queue or not queue .strip ():
63
+ raise ValueError ("Queue name cannot be empty" )
64
+ # RabbitMQ queue names can only contain letters, digits, hyphen, underscore, period, or colon
65
+ # and must be less than 255 characters
66
+ if not all (c .isalnum () or c in '-_.:' for c in queue ):
67
+ raise ValueError ("Queue name can only contain letters, digits, hyphen, underscore, period, or colon" )
68
+ if len (queue ) > 255 :
69
+ raise ValueError ("Queue name must be less than 255 characters" )
70
+
59
71
try :
60
72
connection = pika .BlockingConnection (parameters )
61
73
channel = connection .channel ()
@@ -67,8 +79,20 @@ async def call_tool(
67
79
return [TextContent (type = "text" , text = str ("failed" ))]
68
80
elif name == "fanout" :
69
81
logger .debug ("Executing fanout tool" )
70
- exchange = arguments ["exchange" ]
71
82
message = arguments ["message" ]
83
+ exchange = arguments ["exchange" ]
84
+
85
+ if not message or not message .strip ():
86
+ raise ValueError ("Message cannot be empty" )
87
+ if not exchange or not exchange .strip ():
88
+ raise ValueError ("Exchange name cannot be empty" )
89
+ # RabbitMQ exchange names can only contain letters, digits, hyphen, underscore, period, or colon
90
+ # and must be less than 255 characters
91
+ if not all (c .isalnum () or c in '-_.:' for c in exchange ):
92
+ raise ValueError ("Exchange name can only contain letters, digits, hyphen, underscore, period, or colon" )
93
+ if len (exchange ) > 255 :
94
+ raise ValueError ("Exchange name must be less than 255 characters" )
95
+
72
96
try :
73
97
connection = pika .BlockingConnection (parameters )
74
98
channel = connection .channel ()
0 commit comments