-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hi,
Thank you for putting together this library! It's great that we can host an MCP server directly in Laravel 💯
I've been going through the project README to try and get Laravel Loop working with one of my projects.
I've done the following:
- Installed the Composer package.
- Run
php artisan vendor:publish --tag="loop-config". - Set
LOOP_SSE_ENABLED=truein my project's .env.
I've also configured a very basic sample tool in my AppServiceProvider:
use Kirschbaum\Loop\Facades\Loop;
use Kirschbaum\Loop\Tools\CustomTool;
public function boot(): void
{
... other code...
Loop::tool(
CustomTool::make(
name: 'custom_tool',
description: 'This is a custom tool',
)
->withStringParameter(name: 'name', description: 'The name of the user', required: true)
->withNumberParameter(name: 'age', description: 'The age of the user')
->using(function (string $name, ?int $age = null) {
return sprintf('Hello, %s! You are %d years old.', $name, $age ?? 'unknown');
}),
);
}
I then used the loop:mcp:generate-config command to set up an STDIO MCP server with Claude Code. It worked as expected:
╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
╰───────────────────────────────────────────────────╯
※ Tip: Press Esc twice to edit your previous messages
> Can you use the configured laravel-loop-mcp server and invoke the custom_tool tool with some sample input?
⏺ I can see there's a Laravel Loop MCP server configured. Let me invoke the custom_tool with some sample input.
⏺ laravel-loop-mcp:custom_tool (MCP)(name: "John Doe", age: 30)
⎿ Hello, John Doe! You are 30 years old.
⏺ The custom_tool from the laravel-loop-mcp server worked successfully! It took the name "John Doe" and age 30 as input and returned a greeting message.
I then used the loop:mcp:generate-config command again, but this time I chose the SSE transport. Unfortunately, Claude Code isn't able to correctly detect the tool over SSE:
╭───────────────────────────────────────────────────╮
│ ✻ Welcome to Claude Code! │
│ │
│ /help for help, /status for your current setup │
│ │
╰───────────────────────────────────────────────────╯
※ Tip: Create custom slash commands by adding .md files to .claude/commands/ in your project or ~/.claude/commands/ for commands that work in any project
> Can you use the configured laravel-loop-mcp server and invoke the custom_tool tool with some sample input?
⏺ I'll check the configuration for the laravel-loop-mcp server and then invoke the custom_tool. Let me first examine the configuration to understand what's available.
⏺ Read(config/loop.php)
⎿ Read 111 lines (ctrl+r to expand)
⏺ Let me check the environment configuration and see if MCP is enabled:
⏺ Bash(grep -E "LOOP_|MCP" /Users/mingquah/Projects/platform/.env)
⎿ No (tell Claude what to do differently)
> No, don't check the project - simply invoke the configured MCP tool, custom_tool.
⏺ I'll invoke the custom_tool from the configured laravel-loop-mcp server with some sample input.
⏺ It seems the MCP tool isn't available with that name. Let me check what MCP tools are actually configured by looking at the available tools:
⏺ The MCP tools don't appear to be available in this session. This could mean:
1. The laravel-loop-mcp server isn't running
2. The MCP server isn't properly configured in Claude Code
3. The server needs to be started or connected
Using the /mcp command, it does appear that the MCP SSE server is connected:
│ Manage MCP Servers
│ 1 server found
│
│ laravel-loop-mcp · connected
I can also see POST requests to /mcp/sse/message in my web server logs, so Claude Code is trying to connect, but can't discover the tools for some reason. Since the same tool worked over STDIO, I believe that the tool itself is correctly set up but there's an issue with the SSE stream. I also tried removing the auth:sanctum middleware in loop.php, but this didn't make any difference.
Does Laravel Loop need any special web server configuration for it's SSE transport? I am also using Laravel Octane which might complicate things.