fix: respect resource mime type in responses
The server was ignoring mime types set on resources, defaulting to text/plain for strings and application/octet-stream for bytes. Now properly preserves the specified mime type in both FastMCP and low-level server implementations. Note that this is breaks backwards compatibility as it changes the return values of read_resource() on FastMCP. It is BC compatible on lowlevel since it only extends the callback. Github-Issue: #152 Reported-by: eiseleMichael
This commit is contained in:
parent
f10c2e3f1f
commit
8ff4b5e9d3
1 changed files with 82 additions and 40 deletions
|
|
@ -581,8 +581,8 @@ class TestContextInjection:
|
|||
|
||||
@mcp.tool()
|
||||
async def tool_with_resource(ctx: Context) -> str:
|
||||
data = await ctx.read_resource("test://data")
|
||||
return f"Read resource: {data}"
|
||||
data, mime_type = await ctx.read_resource("test://data")
|
||||
return f"Read resource: {data} with mime type {mime_type}"
|
||||
|
||||
async with client_session(mcp._mcp_server) as client:
|
||||
result = await client.call_tool("tool_with_resource", {})
|
||||
|
|
|
|||
Loading…
Reference in a new issue