@@ -96,7 +96,32 @@ def __init__(self) -> None:
9696 ]
9797
9898 # Define available resources
99- self .resources = []
99+ self .resources = [
100+ {
101+ "uri" : "whois://config" ,
102+ "name" : "Whois Server Configuration" ,
103+ "description" : "Current configuration for Whois servers and settings" ,
104+ "mimeType" : "application/json"
105+ },
106+ {
107+ "uri" : "rdap://config" ,
108+ "name" : "RDAP Server Configuration" ,
109+ "description" : "Current configuration for RDAP servers and settings" ,
110+ "mimeType" : "application/json"
111+ },
112+ {
113+ "uri" : "cache://stats" ,
114+ "name" : "Cache Statistics" ,
115+ "description" : "Current cache usage and performance statistics" ,
116+ "mimeType" : "application/json"
117+ },
118+ {
119+ "uri" : "rate-limit://status" ,
120+ "name" : "Rate Limit Status" ,
121+ "description" : "Current rate limiting status and configuration" ,
122+ "mimeType" : "application/json"
123+ }
124+ ]
100125
101126 def write_message (self , message : dict [str , Any ]) -> None :
102127 """Write a message to stdout."""
@@ -306,51 +331,68 @@ async def handle_read_resource(self, params: dict[str, Any]) -> dict[str, Any]:
306331 uri = params .get ("uri" , "" )
307332
308333 try :
309- if uri .startswith ("whois://domain/" ):
310- domain = uri .replace ("whois://domain/" , "" )
311- result_dict = await self .whois_service .lookup_domain (domain )
334+ if uri == "whois://config" :
335+ config_data = {
336+ "whois_timeout" : self .config .whois_timeout ,
337+ "whois_servers" : getattr (self .whois_service , 'WHOIS_SERVERS' , {}),
338+ "max_retries" : self .config .max_retries ,
339+ "retry_delay" : self .config .retry_delay
340+ }
312341 return {
313342 "contents" : [
314343 {
315344 "uri" : uri ,
316345 "mimeType" : "application/json" ,
317- "text" : json .dumps (result_dict , indent = 2 , default = str ),
346+ "text" : json .dumps (config_data , indent = 2 , default = str ),
318347 }
319348 ]
320349 }
321- elif uri .startswith ("whois://ip/" ):
322- ip = uri .replace ("whois://ip/" , "" )
323- result_dict = await self .whois_service .lookup_ip (ip )
350+ elif uri == "rdap://config" :
351+ config_data = {
352+ "rdap_timeout" : self .config .rdap_timeout ,
353+ "rdap_servers" : getattr (self .rdap_service , 'RDAP_SERVERS' , {}),
354+ "max_connections" : self .config .max_connections ,
355+ "max_keepalive_connections" : self .config .max_keepalive_connections
356+ }
324357 return {
325358 "contents" : [
326359 {
327360 "uri" : uri ,
328361 "mimeType" : "application/json" ,
329- "text" : json .dumps (result_dict , indent = 2 , default = str ),
362+ "text" : json .dumps (config_data , indent = 2 , default = str ),
330363 }
331364 ]
332365 }
333- elif uri .startswith ("rdap://domain/" ):
334- domain = uri .replace ("rdap://domain/" , "" )
335- result_dict = await self .rdap_service .lookup_domain (domain )
366+ elif uri == "cache://stats" :
367+ stats_data = {
368+ "cache_size" : len (self .cache_service ._cache ),
369+ "cache_max_size" : self .config .cache_max_size ,
370+ "cache_ttl" : self .config .cache_ttl ,
371+ "cache_cleanup_interval" : self .config .cache_cleanup_interval
372+ }
336373 return {
337374 "contents" : [
338375 {
339376 "uri" : uri ,
340377 "mimeType" : "application/json" ,
341- "text" : json .dumps (result_dict , indent = 2 , default = str ),
378+ "text" : json .dumps (stats_data , indent = 2 , default = str ),
342379 }
343380 ]
344381 }
345- elif uri .startswith ("rdap://ip/" ):
346- ip = uri .replace ("rdap://ip/" , "" )
347- result_dict = await self .rdap_service .lookup_ip (ip )
382+ elif uri == "rate-limit://status" :
383+ rate_limit_data = {
384+ "global_rate_limit_per_second" : self .config .global_rate_limit_per_second ,
385+ "global_rate_limit_burst" : self .config .global_rate_limit_burst ,
386+ "client_rate_limit_per_second" : self .config .client_rate_limit_per_second ,
387+ "client_rate_limit_burst" : self .config .client_rate_limit_burst ,
388+ "active_clients" : len (self .rate_limiter .client_buckets )
389+ }
348390 return {
349391 "contents" : [
350392 {
351393 "uri" : uri ,
352394 "mimeType" : "application/json" ,
353- "text" : json .dumps (result_dict , indent = 2 , default = str ),
395+ "text" : json .dumps (rate_limit_data , indent = 2 , default = str ),
354396 }
355397 ]
356398 }
0 commit comments