Repository navigation
feat(mcp): let host apps serve LMS tools from their own server - #139
Merged
Merged
Conversation
Expose LmsServer::TOOLS and the HasSanctumAbilities trait so a host server can spread the LMS tools next to its own. Register the package servers after boot and skip the filament-lms handle and /mcp/lms path when the host already claimed them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
CHECK needs training tools that only exist in CHECK, next to the LMS course tools. The package server has a fixed tool list, so a host app could not add tools to it. Now the package provides the tools, and a host app can serve them from its own MCP server.
What changed
LmsServer::TOOLSlists every LMS tool. A host server spreads it into its own$tools.HasSanctumAbilitiestrait builds the Sanctum ability list for any server.LmsServer::sanctumAbilities()keeps its output.filament-lmsandPOST /mcp/lmsafter every provider boots. It skips each one when the host app already registered it, for example inroutes/ai.php.Scope
mcp.enabledandmcp.webflags still turn registration off.Tradeoffs
A config key that names the host server class was the other option. It still has the package own the route, so the host would not own its server. Detection needs no config, and the existing flags stay as the explicit switch.
Blast Radius
The package routes now register in a
bootedcallback, not inboot. Code that looks up/mcp/lmsfrom another provider'sbootmethod would no longer find it. The package now defines themcprate limiter even withmcp.weboff, unless the app defined it first.Verification
vendor/bin/pest: 310 tests, 305 pass, 5 skipped (the same 5 skip on4.x). The newLmsMcpHostServerTestchecks over HTTP that a host server on/mcp/lmsserves its own tools. The test fails when the skip check is removed.vendor/bin/pintandcomposer analyse(PHPStan) pass.Note
Medium Risk
MCP routes and stdio registration now happen in a
bootedcallback instead of during provider boot, and HTTP MCP remains behind Sanctum and LMS-admin middleware.Overview
Host applications can now compose LMS MCP tools into their own MCP server instead of being limited to the package’s fixed
LmsServertool list.LmsServer::TOOLSis a public constant listing every LMS tool class; host servers spread it into$toolsand add app-specific tools.HasSanctumAbilitiescentralizessanctumAbilities()so combined servers (andLmsServer) can expose Filament Sanctum checkbox labels for all registered tools.MCP registration is deferred until after all providers boot (
app->booted), soroutes/ai.phpcan claim thefilament-lmsstdio handle ormcp/lmsweb path first; the package skips registering its own server when those slots are already taken. Themcprate limiter is registered whenever the package boots MCP support (unless the app defined it first), including whenmcp.webis false. README and config comments document the host-server pattern.LmsMcpHostServerTestverifies default package registration, host override on the same handle/path (HTTPtools/listincludes host + LMS tools), config opt-out, andHasSanctumAbilitieson a host server.Reviewed by Cursor Bugbot for commit 8c840e5. Bugbot is set up for automated code reviews on this repo. Configure here.