Spaces:
Running
Running
Merge pull request #315 from jlowin/remove-async
Browse files
src/fastmcp/server/openapi.py
CHANGED
|
@@ -122,7 +122,6 @@ class OpenAPITool(Tool):
|
|
| 122 |
name: str,
|
| 123 |
description: str,
|
| 124 |
parameters: dict[str, Any],
|
| 125 |
-
is_async: bool = True,
|
| 126 |
tags: set[str] = set(),
|
| 127 |
timeout: float | None = None,
|
| 128 |
annotations: ToolAnnotations | None = None,
|
|
@@ -133,7 +132,6 @@ class OpenAPITool(Tool):
|
|
| 133 |
description=description,
|
| 134 |
parameters=parameters,
|
| 135 |
fn=self._execute_request, # We'll use an instance method instead of a global function
|
| 136 |
-
is_async=is_async,
|
| 137 |
context_kwarg="context", # Default context keyword argument
|
| 138 |
tags=tags,
|
| 139 |
annotations=annotations,
|
|
@@ -550,7 +548,6 @@ class FastMCPOpenAPI(FastMCP):
|
|
| 550 |
name=tool_name,
|
| 551 |
description=enhanced_description,
|
| 552 |
parameters=combined_schema,
|
| 553 |
-
is_async=True,
|
| 554 |
tags=set(route.tags or []),
|
| 555 |
timeout=self._timeout,
|
| 556 |
)
|
|
|
|
| 122 |
name: str,
|
| 123 |
description: str,
|
| 124 |
parameters: dict[str, Any],
|
|
|
|
| 125 |
tags: set[str] = set(),
|
| 126 |
timeout: float | None = None,
|
| 127 |
annotations: ToolAnnotations | None = None,
|
|
|
|
| 132 |
description=description,
|
| 133 |
parameters=parameters,
|
| 134 |
fn=self._execute_request, # We'll use an instance method instead of a global function
|
|
|
|
| 135 |
context_kwarg="context", # Default context keyword argument
|
| 136 |
tags=tags,
|
| 137 |
annotations=annotations,
|
|
|
|
| 548 |
name=tool_name,
|
| 549 |
description=enhanced_description,
|
| 550 |
parameters=combined_schema,
|
|
|
|
| 551 |
tags=set(route.tags or []),
|
| 552 |
timeout=self._timeout,
|
| 553 |
)
|
src/fastmcp/server/proxy.py
CHANGED
|
@@ -52,7 +52,6 @@ class ProxyTool(Tool):
|
|
| 52 |
description=tool.description,
|
| 53 |
parameters=tool.inputSchema,
|
| 54 |
fn=_proxy_passthrough,
|
| 55 |
-
is_async=True,
|
| 56 |
)
|
| 57 |
|
| 58 |
async def run(
|
|
|
|
| 52 |
description=tool.description,
|
| 53 |
parameters=tool.inputSchema,
|
| 54 |
fn=_proxy_passthrough,
|
|
|
|
| 55 |
)
|
| 56 |
|
| 57 |
async def run(
|
src/fastmcp/tools/tool.py
CHANGED
|
@@ -40,7 +40,6 @@ class Tool(BaseModel):
|
|
| 40 |
name: str = Field(description="Name of the tool")
|
| 41 |
description: str = Field(description="Description of what the tool does")
|
| 42 |
parameters: dict[str, Any] = Field(description="JSON schema for tool parameters")
|
| 43 |
-
is_async: bool = Field(description="Whether the tool is async")
|
| 44 |
context_kwarg: str | None = Field(
|
| 45 |
None, description="Name of the kwarg that should receive context"
|
| 46 |
)
|
|
@@ -74,7 +73,6 @@ class Tool(BaseModel):
|
|
| 74 |
raise ValueError("You must provide a name for lambda functions")
|
| 75 |
|
| 76 |
func_doc = description or fn.__doc__ or ""
|
| 77 |
-
is_async = inspect.iscoroutinefunction(fn)
|
| 78 |
|
| 79 |
if inspect.ismethod(fn) and hasattr(fn, "__func__"):
|
| 80 |
sig = inspect.signature(fn.__func__)
|
|
@@ -96,7 +94,6 @@ class Tool(BaseModel):
|
|
| 96 |
name=func_name,
|
| 97 |
description=func_doc,
|
| 98 |
parameters=schema,
|
| 99 |
-
is_async=is_async,
|
| 100 |
context_kwarg=context_kwarg,
|
| 101 |
tags=tags or set(),
|
| 102 |
annotations=annotations,
|
|
|
|
| 40 |
name: str = Field(description="Name of the tool")
|
| 41 |
description: str = Field(description="Description of what the tool does")
|
| 42 |
parameters: dict[str, Any] = Field(description="JSON schema for tool parameters")
|
|
|
|
| 43 |
context_kwarg: str | None = Field(
|
| 44 |
None, description="Name of the kwarg that should receive context"
|
| 45 |
)
|
|
|
|
| 73 |
raise ValueError("You must provide a name for lambda functions")
|
| 74 |
|
| 75 |
func_doc = description or fn.__doc__ or ""
|
|
|
|
| 76 |
|
| 77 |
if inspect.ismethod(fn) and hasattr(fn, "__func__"):
|
| 78 |
sig = inspect.signature(fn.__func__)
|
|
|
|
| 94 |
name=func_name,
|
| 95 |
description=func_doc,
|
| 96 |
parameters=schema,
|
|
|
|
| 97 |
context_kwarg=context_kwarg,
|
| 98 |
tags=tags or set(),
|
| 99 |
annotations=annotations,
|
tests/tools/test_tool.py
CHANGED
|
@@ -18,7 +18,6 @@ class TestToolFromFunction:
|
|
| 18 |
|
| 19 |
assert tool.name == "add"
|
| 20 |
assert tool.description == "Add two numbers."
|
| 21 |
-
assert tool.is_async is False
|
| 22 |
assert tool.parameters["properties"]["a"]["type"] == "integer"
|
| 23 |
assert tool.parameters["properties"]["b"]["type"] == "integer"
|
| 24 |
|
|
@@ -33,7 +32,6 @@ class TestToolFromFunction:
|
|
| 33 |
|
| 34 |
assert tool.name == "fetch_data"
|
| 35 |
assert tool.description == "Fetch data from URL."
|
| 36 |
-
assert tool.is_async is True
|
| 37 |
assert tool.parameters["properties"]["url"]["type"] == "string"
|
| 38 |
|
| 39 |
def test_pydantic_model_function(self):
|
|
@@ -51,7 +49,6 @@ class TestToolFromFunction:
|
|
| 51 |
|
| 52 |
assert tool.name == "create_user"
|
| 53 |
assert tool.description == "Create a new user."
|
| 54 |
-
assert tool.is_async is False
|
| 55 |
assert "name" in tool.parameters["$defs"]["UserInput"]["properties"]
|
| 56 |
assert "age" in tool.parameters["$defs"]["UserInput"]["properties"]
|
| 57 |
assert "flag" in tool.parameters["properties"]
|
|
|
|
| 18 |
|
| 19 |
assert tool.name == "add"
|
| 20 |
assert tool.description == "Add two numbers."
|
|
|
|
| 21 |
assert tool.parameters["properties"]["a"]["type"] == "integer"
|
| 22 |
assert tool.parameters["properties"]["b"]["type"] == "integer"
|
| 23 |
|
|
|
|
| 32 |
|
| 33 |
assert tool.name == "fetch_data"
|
| 34 |
assert tool.description == "Fetch data from URL."
|
|
|
|
| 35 |
assert tool.parameters["properties"]["url"]["type"] == "string"
|
| 36 |
|
| 37 |
def test_pydantic_model_function(self):
|
|
|
|
| 49 |
|
| 50 |
assert tool.name == "create_user"
|
| 51 |
assert tool.description == "Create a new user."
|
|
|
|
| 52 |
assert "name" in tool.parameters["$defs"]["UserInput"]["properties"]
|
| 53 |
assert "age" in tool.parameters["$defs"]["UserInput"]["properties"]
|
| 54 |
assert "flag" in tool.parameters["properties"]
|
tests/tools/test_tool_manager.py
CHANGED
|
@@ -31,7 +31,6 @@ class TestAddTools:
|
|
| 31 |
assert tool is not None
|
| 32 |
assert tool.name == "add"
|
| 33 |
assert tool.description == "Add two numbers."
|
| 34 |
-
assert tool.is_async is False
|
| 35 |
assert tool.parameters["properties"]["a"]["type"] == "integer"
|
| 36 |
assert tool.parameters["properties"]["b"]["type"] == "integer"
|
| 37 |
|
|
@@ -49,7 +48,6 @@ class TestAddTools:
|
|
| 49 |
assert tool is not None
|
| 50 |
assert tool.name == "fetch_data"
|
| 51 |
assert tool.description == "Fetch data from URL."
|
| 52 |
-
assert tool.is_async is True
|
| 53 |
assert tool.parameters["properties"]["url"]["type"] == "string"
|
| 54 |
|
| 55 |
def test_pydantic_model_function(self):
|
|
@@ -70,7 +68,6 @@ class TestAddTools:
|
|
| 70 |
assert tool is not None
|
| 71 |
assert tool.name == "create_user"
|
| 72 |
assert tool.description == "Create a new user."
|
| 73 |
-
assert tool.is_async is False
|
| 74 |
assert "name" in tool.parameters["$defs"]["UserInput"]["properties"]
|
| 75 |
assert "age" in tool.parameters["$defs"]["UserInput"]["properties"]
|
| 76 |
assert "flag" in tool.parameters["properties"]
|
|
|
|
| 31 |
assert tool is not None
|
| 32 |
assert tool.name == "add"
|
| 33 |
assert tool.description == "Add two numbers."
|
|
|
|
| 34 |
assert tool.parameters["properties"]["a"]["type"] == "integer"
|
| 35 |
assert tool.parameters["properties"]["b"]["type"] == "integer"
|
| 36 |
|
|
|
|
| 48 |
assert tool is not None
|
| 49 |
assert tool.name == "fetch_data"
|
| 50 |
assert tool.description == "Fetch data from URL."
|
|
|
|
| 51 |
assert tool.parameters["properties"]["url"]["type"] == "string"
|
| 52 |
|
| 53 |
def test_pydantic_model_function(self):
|
|
|
|
| 68 |
assert tool is not None
|
| 69 |
assert tool.name == "create_user"
|
| 70 |
assert tool.description == "Create a new user."
|
|
|
|
| 71 |
assert "name" in tool.parameters["$defs"]["UserInput"]["properties"]
|
| 72 |
assert "age" in tool.parameters["$defs"]["UserInput"]["properties"]
|
| 73 |
assert "flag" in tool.parameters["properties"]
|