-
Notifications
You must be signed in to change notification settings - Fork 378
Open
Description
Hello, I am trying to implement something using playwright MCP, sometimes this error happens [Cannot read property innerText](https://stackoverflow.com/questions/63367277/cannot-read-property-innertext-of-null-for-valid-selector-using-playwright) I want to ignore this error when it happens because it closes the session while I want to continue the navigation. I found https://docs.langchain.com/oss/python/langchain/mcp#writing-interceptors that I guess is the solution to my issue but it's not working probably with me so I guess I am doing something wrong
async def fallback_interceptor(
request: MCPToolCallRequest,
handler,
):
"""Return a fallback value if tool execution fails."""
raise ValueError()
try:
return await handler(request)
except Exception as e:
return f"Tool {request.name} timed out. Ignore it and continue navigation"
try:
mcp_client = MultiServerMCPClient(connections=PLAYWRIGHT_MCP_CONNECTION, tool_interceptors=[fallback_interceptor])
async with mcp_client.session("playwright") as session:
available_tools: List[BaseTool] = await load_mcp_tools(session)
llm = init_chat_model(
model=LLM_MODEL_NAME,
model_provider="google_genai",
google_api_key=os.getenv("GOOGLE_KEY")
)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels