Skip to content

[0.x] Adding events to tool calls #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Katalam
Copy link

@Katalam Katalam commented Aug 20, 2025

To add a better event handling of tool calls I've added 3 new events

  • Laravel\Mcp\Server\Events\ToolCallFailed
  • Laravel\Mcp\Server\Events\ToolCallFinished
  • Laravel\Mcp\Server\Events\ToolCallStarting

Inside the CallTool Method they will be dispatched through the normal framework dispatcher.
I added 2 new test cases to catch the ToolCallFinished and ToolCallFailed events.

I personally can now listen to these events instead of having a wrapper function for each tool.

A new doc block is possible

The mcp server dispatches three events when running tools: Laravel\Mcp\Server\Events\ToolCallStarting, Laravel\Mcp\Server\Events\ToolCallFinished, and Laravel\Mcp\Server\Events\ToolCallFailed. The ToolCallStarting event is dispatched immediately when the tool call starts running. Next, the ToolCallFinished event is dispatched immediately after a tool call finished executing. If needed, the ToolCallFailed event is dispatched once a command fails validating inside the execution.

@Katalam Katalam changed the title Adding events to tool calls [0.x] Adding events to tool calls Aug 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant