fix: Update @mcp.resource to use function documentation as default descrip… (#489)
This commit is contained in:
parent
c2f8730d6d
commit
1bdeed33c2
1 changed files with 73 additions and 9 deletions
|
|
@ -136,3 +136,22 @@ class TestFunctionResource:
|
|||
content = await resource.read()
|
||||
assert content == "Hello, world!"
|
||||
assert resource.mime_type == "text/plain"
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_from_function(self):
|
||||
"""Test creating a FunctionResource from a function."""
|
||||
|
||||
async def get_data() -> str:
|
||||
"""get_data returns a string"""
|
||||
return "Hello, world!"
|
||||
|
||||
resource = FunctionResource.from_function(
|
||||
fn=get_data,
|
||||
uri="function://test",
|
||||
name="test",
|
||||
)
|
||||
|
||||
assert resource.description == "get_data returns a string"
|
||||
assert resource.mime_type == "text/plain"
|
||||
assert resource.name == "test"
|
||||
assert resource.uri == AnyUrl("function://test")
|
||||
|
|
|
|||
Loading…
Reference in a new issue