Result processing and error handling issues #29

Closed
opened 2026-02-15 20:17:32 -05:00 by yindo · 2 comments
Owner

Originally created by @bmen25124 on GitHub (Apr 10, 2025).

I'm not sure how many users are using MCP in their main workflow. But I find it incapable of most things.

  1. LLM made the call. Since this line doesn't handling exceptions, program shutting down itself 😶

logs:

Calling endpoint: delete_observations, with args: {'deletions': [{'entityName': 'default_user', 'observations': ["Tomorrow is default_user's birthday"]}]}
INFO:     172.22.0.3:39842 - "POST /delete_observations HTTP/1.1" 200 OK
    raise exc
  File "/app/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 714, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 734, in app
    await route.handle(scope, receive, send)
  File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 76, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/app/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/app/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 73, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/mcpo/main.py", line 158, in tool
    result = await session.call_tool(endpoint_name, arguments=args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/mcp/client/session.py", line 256, in call_tool
    return await self.send_request(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.11/site-packages/mcp/shared/session.py", line 266, in send_request
    raise McpError(response_or_error.error)
mcp.shared.exceptions.McpError: Entity with name default_user not found
INFO:     Shutting down
INFO:     Waiting for application shutdown.
INFO:     Application shutdown complete
  1. CallToolResult has isError field. We should check it.

  2. We are returning 200 with only a response. But we should also return isError. Because sometimes MCP servers don't throw exceptions, they can set isError.

  3. This is more related to open-webui part. If there is an error(validation or whatever), LLM should be able to read the error. So it can fix the error by itself. This is what I found in open-webui chat:

me -> can you delete that?
llm -> Observations deleted successfully [1].

In the background, I got the error(first log). mcp0 process exited. But somehow open-webui thought this was a successful call.

Without successful error/result handling, MCP(or tool calling) remains a toy. If you approve of these issues, I could try to make a PR.

Originally created by @bmen25124 on GitHub (Apr 10, 2025). I'm not sure how many users are using MCP in their main workflow. But I find it incapable of most things. 1. LLM made the call. Since [this line](https://github.com/open-webui/mcpo/blob/f25a6fbb9a5605b009c73a615b5cc994a99b3c36/src/mcpo/main.py#L158) doesn't handling exceptions, program shutting down itself 😶 logs: ``` Calling endpoint: delete_observations, with args: {'deletions': [{'entityName': 'default_user', 'observations': ["Tomorrow is default_user's birthday"]}]} INFO: 172.22.0.3:39842 - "POST /delete_observations HTTP/1.1" 200 OK raise exc File "/app/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 714, in __call__ await self.middleware_stack(scope, receive, send) File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 734, in app await route.handle(scope, receive, send) File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle await self.app(scope, receive, send) File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 76, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "/app/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app raise exc File "/app/.venv/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app await app(scope, receive, sender) File "/app/.venv/lib/python3.11/site-packages/starlette/routing.py", line 73, in app response = await f(request) ^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 301, in app raw_response = await run_endpoint_function( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 212, in run_endpoint_function return await dependant.call(**values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/site-packages/mcpo/main.py", line 158, in tool result = await session.call_tool(endpoint_name, arguments=args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/site-packages/mcp/client/session.py", line 256, in call_tool return await self.send_request( ^^^^^^^^^^^^^^^^^^^^^^^^ File "/app/.venv/lib/python3.11/site-packages/mcp/shared/session.py", line 266, in send_request raise McpError(response_or_error.error) mcp.shared.exceptions.McpError: Entity with name default_user not found INFO: Shutting down INFO: Waiting for application shutdown. INFO: Application shutdown complete ``` 2. [CallToolResult](https://github.com/modelcontextprotocol/python-sdk/blob/c4beb3e8eff4869b4eb063d3a5f257bdf67dd62f/src/mcp/types.py#L745) has `isError` field. We should check it. 3. We are returning `200` with only a response. But we should also return `isError`. Because sometimes MCP servers don't throw exceptions, they can set `isError.` 4. This is more related to _open-webui_ part. If there is an error(validation or whatever), LLM should be able to read the error. So it can fix the error by itself. This is what I found in _open-webui_ chat: ``` me -> can you delete that? llm -> Observations deleted successfully [1]. ``` In the background, I got the error(first log). `mcp0` process exited. But somehow _open-webui_ thought this was a successful call. Without successful error/result handling, MCP(or tool calling) remains a toy. If you approve of these issues, I could try to make a PR.
yindo added the bug label 2026-02-15 20:17:32 -05:00
yindo closed this issue 2026-02-15 20:17:32 -05:00
Author
Owner

@tjbck commented on GitHub (Apr 10, 2025):

PR Welcome!

@tjbck commented on GitHub (Apr 10, 2025): PR Welcome!
Author
Owner

@bmen25124 commented on GitHub (Apr 10, 2025):

Fixed in #63

@bmen25124 commented on GitHub (Apr 10, 2025): Fixed in #63
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: open-webui/mcpo#29