File tree Expand file tree Collapse file tree 4 files changed +24
-14
lines changed Expand file tree Collapse file tree 4 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -130,8 +130,11 @@ def module(self):
130130 return self ._module
131131
132132 @property
133- def tools (self ):
134- """Structured tools exposed by this extension point, if any."""
133+ def tools (self ):
134+ """Structured tools exposed by this extension point, if any.
135+
136+ Searches for a `jupyter_server_extension_tools` function on the extension module or app.
137+ """
135138 loc = self .app or self .module
136139 if not loc :
137140 return {}
@@ -499,15 +502,15 @@ def load_all_extensions(self):
499502 self .load_extension (name )
500503
501504 def get_tools (self ) -> Dict [str , Any ]:
502- """Aggregate tools from all extensions that expose them ."""
505+ """Aggregate and return structured tools (with metadata) from all enabled extensions ."""
503506 all_tools = {}
504507
505508 for ext_name , ext_pkg in self .extensions .items ():
506509 if not ext_pkg .enabled :
507510 continue
508511
509512 for point in ext_pkg .extension_points .values ():
510- for name , tool in point .tools .items (): # <— new property!
513+ for name , tool in point .tools .items ():
511514 if name in all_tools :
512515 raise ValueError (f"Duplicate tool name detected: '{ name } '" )
513516 all_tools [name ] = tool
Original file line number Diff line number Diff line change @@ -2540,8 +2540,9 @@ def load_server_extensions(self) -> None:
25402540 """
25412541 self .extension_manager .load_all_extensions ()
25422542
2543- # is this how I would expose it? and Is this a good name?
2544- def get_tools (self ):
2543+
2544+ def get_tools (self ):
2545+ """Aggregate and return tools + tool metadata from all the extensions that expose them."""
25452546 return self .extension_manager .get_tools ()
25462547
25472548 def init_mime_overrides (self ) -> None :
Original file line number Diff line number Diff line change @@ -424,13 +424,6 @@ async def post(self, path=""):
424424 self .finish ()
425425
426426
427- # Somehow this doesn't feel like the right service for this to go in?
428- class ListToolInfoHandler (APIHandler ):
429- @web .authenticated
430- async def get (self ):
431- tools = self .serverapp .extension_manager .discover_tools ()
432- self .finish ({"discovered_tools" : tools })
433-
434427
435428# -----------------------------------------------------------------------------
436429# URL to handler mappings
@@ -449,5 +442,4 @@ async def get(self):
449442 (r"/api/contents%s/trust" % path_regex , TrustNotebooksHandler ),
450443 (r"/api/contents%s" % path_regex , ContentsHandler ),
451444 (r"/api/notebooks/?(.*)" , NotebooksRedirectHandler ),
452- (r"/api/tools" , ListToolInfoHandler ),
453445]
Original file line number Diff line number Diff line change 1+ from tornado import web
2+ from jupyter_server .base .handlers import APIHandler
3+
4+ class ListToolInfoHandler (APIHandler ):
5+ @web .authenticated
6+ async def get (self ):
7+ tools = self .serverapp .extension_manager .discover_tools ()
8+ self .finish ({"discovered_tools" : tools })
9+
10+
11+
12+ default_handlers = [
13+ (r"/api/tools" , ListToolInfoHandler ),
14+ ]
You can’t perform that action at this time.
0 commit comments