Skip to content

fix(tool): honor shouldRegister on Laravel MCP tools - #1048

Open
nbullorini wants to merge 1 commit into
prism-php:mainfrom
nbullorini:fix/mcp-should-register
Open

nbullorini wants to merge 1 commit into
prism-php:mainfrom
nbullorini:fix/mcp-should-register

Conversation

@nbullorini

Copy link
Copy Markdown

Description

Laravel MCP tools can define shouldRegister() to conditionally register themselves (e.g. only for authenticated users). Prism wrapped them via Tool::make() but always sent them to the provider, so tools that should be hidden were still exposed and callable.

Ineligible LaravelMcpTool instances are now filtered in withTools(), using laravel/mcp's own eligibleForRegistration(), so they are neither sent to the provider nor callable.

Fixes #979

Changes

  • Add LaravelMcpTool::eligibleForRegistration(), delegating to the wrapped MCP tool
  • Filter ineligible Laravel MCP tools in HasTools::withTools()
  • Add tests covering mixed tool lists and shouldRegister(Request $request)
  • Document shouldRegister support in the tools docs

Laravel MCP tools can define shouldRegister() to conditionally register
themselves. Prism wrapped them via Tool::make() and always sent them to
the provider. Ineligible LaravelMcpTool instances are now filtered in
withTools(), so they are neither sent to the provider nor callable.

Fixes prism-php#979

Co-Authored-By: Cursor Agent <cursoragent@cursor.com>

This branch has not been deployed

No deployments
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.

Laravel MCP Tools support doesn't honor shouldRegister

1 participant