Skip to content

Commit 56b1bfd

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f6a5d42 commit 56b1bfd

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

jupyter_server/extension/manager.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
import importlib
66
from itertools import starmap
77

8+
import jsonschema
89
from tornado.gen import multi
910
from traitlets import Any, Bool, Dict, HasTraits, Instance, List, Unicode, default, observe
1011
from traitlets import validate as validate_trait
1112
from traitlets.config import LoggingConfigurable
12-
import jsonschema
13-
1413

1514
from .config import ExtensionConfigManager
1615
from .utils import ExtensionMetadataError, ExtensionModuleNotFound, get_loader, get_metadata
1716

18-
1917
# probably this should go in it's own file? Not sure where though
2018
MCP_TOOL_SCHEMA = {
2119
"type": "object",
@@ -27,9 +25,9 @@
2725
"properties": {
2826
"type": {"type": "string", "enum": ["object"]},
2927
"properties": {"type": "object"},
30-
"required": {"type": "array", "items": {"type": "string"}}
28+
"required": {"type": "array", "items": {"type": "string"}},
3129
},
32-
"required": ["type", "properties"]
30+
"required": ["type", "properties"],
3331
},
3432
"annotations": {
3533
"type": "object",
@@ -38,15 +36,16 @@
3836
"readOnlyHint": {"type": "boolean"},
3937
"destructiveHint": {"type": "boolean"},
4038
"idempotentHint": {"type": "boolean"},
41-
"openWorldHint": {"type": "boolean"}
39+
"openWorldHint": {"type": "boolean"},
4240
},
43-
"additionalProperties": True
44-
}
41+
"additionalProperties": True,
42+
},
4543
},
4644
"required": ["name", "inputSchema"],
47-
"additionalProperties": False
45+
"additionalProperties": False,
4846
}
4947

48+
5049
class ExtensionPoint(HasTraits):
5150
"""A simple API for connecting to a Jupyter Server extension
5251
point defined by metadata and importable from a Python package.
@@ -129,9 +128,9 @@ def name(self):
129128
def module(self):
130129
"""The imported module (using importlib.import_module)"""
131130
return self._module
132-
131+
133132
@property
134-
def tools(self):
133+
def tools(self):
135134
"""Structured tools exposed by this extension point, if any."""
136135
loc = self.app or self.module
137136
if not loc:
@@ -149,7 +148,7 @@ def tools(self):
149148
jsonschema.validate(instance=tool["metadata"], schema=MCP_TOOL_SCHEMA)
150149
tools[name] = tool
151150
except Exception as e:
152-
# not sure if this should fail quietly, raise an error, or log it?
151+
# not sure if this should fail quietly, raise an error, or log it?
153152
print(f"[tool-discovery] Failed to load tools from {self.module_name}: {e}")
154153
return tools
155154

@@ -167,7 +166,6 @@ def _get_linker(self):
167166
)
168167
return linker
169168

170-
171169
def _get_loader(self):
172170
"""Get a loader."""
173171
loc = self.app
@@ -500,7 +498,6 @@ def load_all_extensions(self):
500498
for name in self.sorted_extensions:
501499
self.load_extension(name)
502500

503-
504501
def get_tools(self) -> Dict[str, Any]:
505502
"""Aggregate tools from all extensions that expose them."""
506503
all_tools = {}

jupyter_server/serverapp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2540,8 +2540,8 @@ 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+
# is this how I would expose it? and Is this a good name?
2544+
def get_tools(self):
25452545
return self.extension_manager.get_tools()
25462546

25472547
def init_mime_overrides(self) -> None:

jupyter_server/services/contents/handlers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,12 +423,13 @@ async def post(self, path=""):
423423
self.set_status(201)
424424
self.finish()
425425

426-
# Somehow this doesn't feel like the right service for this to go in?
426+
427+
# Somehow this doesn't feel like the right service for this to go in?
427428
class ListToolInfoHandler(APIHandler):
428429
@web.authenticated
429430
async def get(self):
430431
tools = self.serverapp.extension_manager.discover_tools()
431-
self.finish({"discovered_tools": tools})
432+
self.finish({"discovered_tools": tools})
432433

433434

434435
# -----------------------------------------------------------------------------
@@ -449,5 +450,4 @@ async def get(self):
449450
(r"/api/contents%s" % path_regex, ContentsHandler),
450451
(r"/api/notebooks/?(.*)", NotebooksRedirectHandler),
451452
(r"/api/tools", ListToolInfoHandler),
452-
453453
]

0 commit comments

Comments
 (0)