|
10 | 10 | asynccontextmanager, |
11 | 11 | ) |
12 | 12 | from itertools import chain |
13 | | -from typing import Any, Generic, Literal, overload |
| 13 | +from typing import Any, Generic, Literal |
14 | 14 |
|
15 | 15 | import anyio |
16 | 16 | import pydantic_core |
@@ -315,42 +315,31 @@ async def read_resource(self, uri: AnyUrl | str) -> Iterable[ReadResourceContent |
315 | 315 | logger.error(f"Error reading resource {uri}: {e}") |
316 | 316 | raise ResourceError(str(e)) |
317 | 317 |
|
318 | | - @overload |
319 | | - def add_tool(self, fn: Tool) -> None: ... |
| 318 | + def add_tool_instance(self, tool: Tool) -> None: |
| 319 | + """Add a Tool instance to the server.""" |
| 320 | + self._tool_manager.add_tool_instance(tool) |
320 | 321 |
|
321 | | - @overload |
322 | 322 | def add_tool( |
323 | 323 | self, |
324 | 324 | fn: AnyFunction, |
325 | 325 | name: str | None = None, |
326 | 326 | description: str | None = None, |
327 | 327 | annotations: ToolAnnotations | None = None, |
328 | | - ) -> None: ... |
329 | | - |
330 | | - def add_tool( |
331 | | - self, |
332 | | - fn: AnyFunction | Tool, |
333 | | - name: str | None = None, |
334 | | - description: str | None = None, |
335 | | - annotations: ToolAnnotations | None = None, |
336 | 328 | ) -> None: |
337 | 329 | """Add a tool to the server. |
338 | 330 |
|
339 | 331 | The tool function can optionally request a Context object by adding a parameter |
340 | 332 | with the Context type annotation. See the @tool decorator for examples. |
341 | 333 |
|
342 | 334 | Args: |
343 | | - fn: The function to register as a tool or a Tool instance |
| 335 | + fn: The function to register as a tool |
344 | 336 | name: Optional name for the tool (defaults to function name) |
345 | 337 | description: Optional description of what the tool does |
346 | 338 | annotations: Optional ToolAnnotations providing additional tool information |
347 | 339 | """ |
348 | | - if isinstance(fn, Tool): |
349 | | - self._tool_manager.add_tool(fn) |
350 | | - else: |
351 | | - self._tool_manager.add_tool( |
352 | | - fn, name=name, description=description, annotations=annotations |
353 | | - ) |
| 340 | + self._tool_manager.add_tool( |
| 341 | + fn, name=name, description=description, annotations=annotations |
| 342 | + ) |
354 | 343 |
|
355 | 344 | def tool( |
356 | 345 | self, |
|
0 commit comments