mirror of
https://github.com/aljazceru/mcp-python-sdk.git
synced 2025-12-20 15:24:25 +01:00
fix tests
This commit is contained in:
@@ -521,11 +521,11 @@ class TestContextInjection:
|
|||||||
"""Test that context logging methods work."""
|
"""Test that context logging methods work."""
|
||||||
mcp = FastMCP()
|
mcp = FastMCP()
|
||||||
|
|
||||||
def logging_tool(msg: str, ctx: Context) -> str:
|
async def logging_tool(msg: str, ctx: Context) -> str:
|
||||||
ctx.debug("Debug message")
|
await ctx.debug("Debug message")
|
||||||
ctx.info("Info message")
|
await ctx.info("Info message")
|
||||||
ctx.warning("Warning message")
|
await ctx.warning("Warning message")
|
||||||
ctx.error("Error message")
|
await ctx.error("Error message")
|
||||||
return f"Logged messages for {msg}"
|
return f"Logged messages for {msg}"
|
||||||
|
|
||||||
mcp.add_tool(logging_tool)
|
mcp.add_tool(logging_tool)
|
||||||
@@ -563,8 +563,8 @@ class TestContextInjection:
|
|||||||
|
|
||||||
@mcp.tool()
|
@mcp.tool()
|
||||||
async def tool_with_resource(ctx: Context) -> str:
|
async def tool_with_resource(ctx: Context) -> str:
|
||||||
data = await ctx.read_resource("test://data")
|
data, mime_type = await ctx.read_resource("test://data")
|
||||||
return f"Read resource: {data}"
|
return f"Read resource: {data} with mime type {mime_type}"
|
||||||
|
|
||||||
async with client_session(mcp._mcp_server) as client:
|
async with client_session(mcp._mcp_server) as client:
|
||||||
result = await client.call_tool("tool_with_resource", {})
|
result = await client.call_tool("tool_with_resource", {})
|
||||||
|
|||||||
Reference in New Issue
Block a user