mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-22 21:44:18 +02:00
Add get_tool utility
This commit is contained in:
parent
1d80a50b72
commit
fe5aa910e7
1 changed files with 6 additions and 0 deletions
|
|
@ -263,6 +263,12 @@ class FastMCP(Generic[LifespanResultT]):
|
|||
self._cache.set("tools", tools)
|
||||
return tools
|
||||
|
||||
async def get_tool(self, key: str) -> Tool:
|
||||
tools = await self.get_tools()
|
||||
if key not in tools:
|
||||
raise NotFoundError(f"Unknown tool: {key}")
|
||||
return tools[key]
|
||||
|
||||
async def get_resources(self) -> dict[str, Resource]:
|
||||
"""Get all registered resources, indexed by registered key."""
|
||||
if (resources := self._cache.get("resources")) is self._cache.NOT_FOUND:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue