Claude Agent SDK for Laravel

v1.0.0Coding Agentsstable

Anthropic Claude Agent SDK for PHP & Laravel — build AI agents with tool use, sandboxing, MCP servers, subagents, hooks, and structured output via the Claude Code CLI

agentic-aiaiai-agentai-sdkai-tools
Share:
15
Stars
0
Downloads
0
Weekly
0/5

What is Claude Agent SDK for Laravel?

Claude Agent SDK for Laravel is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to anthropic claude agent sdk for php & laravel — build ai agents with tool use, sandboxing, mcp servers, subagents, hooks, and structured output via the claude code cli

Anthropic Claude Agent SDK for PHP & Laravel — build AI agents with tool use, sandboxing, MCP servers, subagents, hooks, and structured output via the Claude Code CLI

This server falls under the Coding Agents category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Anthropic Claude Agent SDK for PHP & Laravel — build AI agen

Use Cases

Build AI agents in PHP and Laravel
Tool use and sandboxed execution
LicenseMIT
Languagephp
Versionv1.0.0
UpdatedApr 15, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx claude-agent-sdk-laravel

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Claude Agent SDK for Laravel

The Claude Agent SDK for Laravel is a PHP/Laravel package that wraps the Claude Code CLI to bring full agentic AI capabilities into Laravel applications. It supports file read/write/edit operations, Bash execution, streaming responses, session resumption, structured JSON output, subagent delegation, MCP server integration, fine-grained permission control with custom handlers, and 12 hook event types — all accessible via a clean Laravel facade.

Prerequisites

  • PHP 8.1+ and Composer installed
  • Laravel 10+ application
  • Claude Code CLI installed and authenticated (npm install -g @anthropic-ai/claude-code)
  • An Anthropic API key from https://console.anthropic.com
1

Install the package via Composer

Add the SDK to your Laravel project using Composer.

composer require mohamed-ashraf-elsaed/claude-agent-sdk-laravel
2

Publish the configuration file

Publish the package config so you can customize model, permission mode, budget, and other settings.

php artisan vendor:publish --tag=claude-agent-config
3

Configure environment variables

Add the required and optional environment variables to your Laravel .env file.

ANTHROPIC_API_KEY=your-api-key-here
CLAUDE_AGENT_MODEL=claude-sonnet-4-5-20250929
CLAUDE_AGENT_PERMISSION_MODE=acceptEdits
CLAUDE_AGENT_MAX_TURNS=10
CLAUDE_AGENT_MAX_BUDGET_USD=10.00
4

Run a basic agent query

Use the ClaudeAgent facade to send a query. The agent has access to Read, Write, Edit, Bash, Grep, Glob, WebFetch, Task, and any connected MCP tools.

<?php
use ClaudeAgentSDK\Facades\ClaudeAgent;

$result = ClaudeAgent::query('What files are in this directory?');
echo $result->text();
echo 'Cost: $' . $result->costUsd();
5

Use streaming for real-time responses

For long-running tasks, stream the response with a callback to process output incrementally.

<?php
use ClaudeAgentSDK\Facades\ClaudeAgent;

ClaudeAgent::stream('Refactor the User model for better readability', function($chunk) {
    echo $chunk;
    ob_flush();
    flush();
});
6

Resume a previous session

Pass a session ID to continue a conversation with full context from a prior agent run.

<?php
$result = ClaudeAgent::query(
    'Continue fixing the auth module',
    sessionId: 'previous-session-id-here'
);
echo $result->text();

Claude Agent SDK for Laravel Examples

Client configuration

The SDK is configured via your Laravel .env and the published config file. No external MCP client config is needed — the package talks to the Claude Code CLI directly.

{
  "model": "claude-sonnet-4-5-20250929",
  "permission_mode": "acceptEdits",
  "max_turns": 10,
  "max_budget_usd": 10.00
}

Prompts to try

Example queries to run against the Claude Agent SDK from your Laravel application.

- "Find and fix the bug in app/Http/Controllers/AuthController.php"
- "Refactor the User model to use mass assignment protection correctly"
- "Create a REST API resource controller for the Product model with CRUD operations"
- "Review the authentication module for security vulnerabilities"
- "Generate a migration for an orders table with foreign keys to users and products"

Troubleshooting Claude Agent SDK for Laravel

CliNotFoundException: Claude Code CLI not found

Install Claude Code CLI globally with 'npm install -g @anthropic-ai/claude-code' and ensure the 'claude' binary is in your system PATH. Run 'which claude' or 'claude --version' to verify.

API key errors or authentication failures

Ensure ANTHROPIC_API_KEY is set correctly in your .env file and that 'php artisan config:clear' has been run to invalidate the config cache. The key must have access to the model specified in CLAUDE_AGENT_MODEL.

Agent exceeds budget or max turns limit

Increase CLAUDE_AGENT_MAX_BUDGET_USD or CLAUDE_AGENT_MAX_TURNS in your .env file. For complex refactoring tasks, a budget of $1-5 and 20-50 turns is typical. Monitor costs with $result->costUsd() per query.

Frequently Asked Questions about Claude Agent SDK for Laravel

What is Claude Agent SDK for Laravel?

Claude Agent SDK for Laravel is a Model Context Protocol (MCP) server that anthropic claude agent sdk for php & laravel — build ai agents with tool use, sandboxing, mcp servers, subagents, hooks, and structured output via the claude code cli It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Claude Agent SDK for Laravel?

Follow the installation instructions on the Claude Agent SDK for Laravel GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Claude Agent SDK for Laravel?

Claude Agent SDK for Laravel works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Claude Agent SDK for Laravel free to use?

Yes, Claude Agent SDK for Laravel is open source and available under the MIT license. You can use it freely in both personal and commercial projects.

Browse More Coding Agents MCP Servers

Explore all coding agents servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "claude-agent-sdk-laravel": { "command": "npx", "args": ["-y", "claude-agent-sdk-laravel"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Claude Agent SDK for Laravel?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides