Repository navigation
Closed
Description
What happened?
A resource's input request works through Client.read_resource(), but ResourcesAsTools returns [] with is_error=False without asking the user. I expected the same question/answer round to complete through the generated tool.
This also affects resource templates and PromptsAsTools: the latter returns {"messages": []} instead of asking and rendering the prompt. Ordinary results that do not ask for input work.
Example Code
import asyncio
from fastmcp import Client, Context, FastMCP
from fastmcp.client.elicitation import ElicitResult
from fastmcp.server.transforms import ResourcesAsTools
from mcp.types import ElicitRequest, ElicitRequestFormParams, InputRequiredResult
mcp = FastMCP("Repro")
mcp.add_transform(ResourcesAsTools(mcp))
@mcp.resource("greeting://name")
def greeting(ctx: Context) -> str | InputRequiredResult:
if ctx.input_responses is None:
return InputRequiredResult(
result_type="input_required",
input_requests={"name": ElicitRequest(
method="elicitation/create",
params=ElicitRequestFormParams(
message="Name?",
requested_schema={
"type": "object",
"properties": {"name": {"type": "string"}},
"required": ["name"],
},
),
)},
)
return "Hello " + ctx.input_responses["name"].content["name"]
async def answer(message, response_type, params, ctx):
print("Asked:", message)
return ElicitResult(action="accept", content=response_type(name="Ada"))
async def main():
async with Client(mcp, elicitation_handler=answer) as client:
print("Direct:", (await client.read_resource("greeting://name"))[0].text)
result = await client.call_tool("read_resource", {"uri": "greeting://name"})
print("Tool:", result.data, "is_error:", result.is_error)
assert result.data == "Hello Ada"
asyncio.run(main())Version Information
Reproduced with FastMCP 4.0.11, MCP 2.3.0, Pydantic 2.13.5, Python 3.12.12, macOS 26.6.2; also on main 5baeacfe with MCP 2.0.0. Checked both in-memory clients and HTTP through the ASGI app. Reproduced with Codex.
Activity