Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A comprehensive MCP (Model Context Protocol) server for Statamic CMS v6 that pro
- PHP 8.3+
- Laravel 12+
- Statamic 6.6+
- Laravel MCP ^0.6
- Laravel MCP ^0.6 || ^0.7

## Installation

Expand Down
2 changes: 1 addition & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| PHP | ^8.3 | ^8.3 |
| Statamic | ^5.65 \| ^6.0 | ^6.6 |
| Laravel | ^11.0 \| ^12.0 | ^12.0 \| ^13.0 (via Statamic v6) |
| Laravel MCP | ^0.4.1 \| ^0.5 | ^0.6 |
| Laravel MCP | ^0.4.1 \| ^0.5 | ^0.6 \|\| ^0.7 |
| Symfony YAML | ^7.3 | ^7.0 \| ^8.0 |

**Statamic v5 support has been removed.** If you are on Statamic v5, stay on v1.x.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"require": {
"php": "^8.3",
"statamic/cms": "^6.6",
"laravel/mcp": "^0.6",
"laravel/mcp": "^0.6 || ^0.7",
"symfony/yaml": "^7.0 || ^8.0"
},
"require-dev": {
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ weight: 1
- **PHP** 8.3 or higher
- **Statamic CMS** v6.6+
- **Laravel** 12.0+
- **laravel/mcp** ^0.6 (installed automatically as a dependency)
- **laravel/mcp** ^0.6 || ^0.7 (installed automatically as a dependency)

## Install via Composer

Expand Down
2 changes: 1 addition & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The server registers a set of domain routers — each handling a specific Statam
- **PHP** 8.3+
- **Statamic** v6.6+
- **Laravel** 12.0+
- **laravel/mcp** ^0.6
- **laravel/mcp** ^0.6 || ^0.7

## Quick Links

Expand Down
4 changes: 2 additions & 2 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ protected function getCursorRulesContent(string $projectPath): string
# Statamic MCP Server v2.0 Integration

This project uses Statamic MCP Server v2.0 for enhanced AI-assisted development.
Requires Statamic v6+ and laravel/mcp v0.6+.
Requires Statamic v6+ and laravel/mcp ^0.6 or ^0.7.

## MCP Server Configuration
- Command: php artisan mcp:start statamic
Expand Down Expand Up @@ -801,7 +801,7 @@ protected function getStatamicMcpGuidelines(): string
# Statamic MCP Guidelines (v2.0)

This file provides AI assistants with comprehensive understanding of the Statamic MCP Server v2.0 capabilities.
Requires Statamic v6+ and laravel/mcp v0.6+.
Requires Statamic v6+ and laravel/mcp ^0.6 or ^0.7.

## MCP Server Overview

Expand Down
6 changes: 2 additions & 4 deletions src/Http/Controllers/CP/Concerns/ResolvesUserId.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Cboxdk\StatamicMcp\Http\Controllers\CP\Concerns;

use Cboxdk\StatamicMcp\Support\UserIds;
use Statamic\Facades\User;

trait ResolvesUserId
Expand All @@ -15,9 +16,6 @@ private function resolveUserId(): string
{
$user = User::current();

/** @var string $userId */
$userId = $user ? $user->id() : '';

return $userId;
return $user ? UserIds::normalize($user->id()) : '';
}
}
4 changes: 2 additions & 2 deletions src/Http/Controllers/OAuth/AuthorizeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Cboxdk\StatamicMcp\OAuth\Contracts\OAuthDriver;
use Cboxdk\StatamicMcp\OAuth\Exceptions\OAuthException;
use Cboxdk\StatamicMcp\OAuth\OAuthClient;
use Cboxdk\StatamicMcp\Support\UserIds;
use Illuminate\Contracts\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -277,8 +278,7 @@ public function approve(Request $request): RedirectResponse
])));
}

/** @var string $userId */
$userId = $user->id();
$userId = UserIds::normalize($user->id());

// Get originally requested scopes from the hidden form field (set by show())
/** @var string $originalScope */
Expand Down
13 changes: 13 additions & 0 deletions src/Support/UserIds.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Cboxdk\StatamicMcp\Support;

class UserIds
{
public static function normalize(mixed $userId): string
{
return is_scalar($userId) || $userId === null ? (string) $userId : '';
}
}
72 changes: 72 additions & 0 deletions tests/Unit/Http/Controllers/CP/ResolvesUserIdTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

declare(strict_types=1);

namespace Cboxdk\StatamicMcp\Tests\Unit\Http\Controllers\CP;

use Cboxdk\StatamicMcp\Http\Controllers\CP\Concerns\ResolvesUserId;
use Cboxdk\StatamicMcp\Tests\TestCase;
use Illuminate\Database\Eloquent\Model;
use ReflectionMethod;
use Statamic\Auth\Eloquent\User as EloquentUser;
use Statamic\Facades\User;

class ResolvesUserIdTest extends TestCase
{
public function test_resolves_integer_user_ids_as_strings(): void
{
User::shouldReceive('current')
->once()
->andReturn($this->makeEloquentUserWithId(1));

$this->assertSame('1', $this->resolveCurrentUserId());
}

public function test_preserves_string_user_ids(): void
{
User::shouldReceive('current')
->once()
->andReturn($this->makeEloquentUserWithId('flat-file-user'));

$this->assertSame('flat-file-user', $this->resolveCurrentUserId());
}

public function test_resolves_missing_user_as_empty_string(): void
{
User::shouldReceive('current')
->once()
->andReturn(null);

$this->assertSame('', $this->resolveCurrentUserId());
}

private function resolveCurrentUserId(): string
{
$controller = new class
{
use ResolvesUserId;
};

$method = new ReflectionMethod($controller, 'resolveUserId');
$method->setAccessible(true);

return $method->invoke($controller);
}

private function makeEloquentUserWithId(int|string $id): EloquentUser
{
$model = new class extends Model
{
public $timestamps = false;

public $incrementing = false;

protected $keyType = 'string';

protected $guarded = [];
};
$model->setAttribute('id', $id);

return (new EloquentUser)->model($model);
}
}
21 changes: 21 additions & 0 deletions tests/Unit/Support/UserIdsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace Cboxdk\StatamicMcp\Tests\Unit\Support;

use Cboxdk\StatamicMcp\Support\UserIds;
use Cboxdk\StatamicMcp\Tests\TestCase;

class UserIdsTest extends TestCase
{
public function test_normalizes_integer_user_ids_from_eloquent_driver(): void
{
$this->assertSame('1', UserIds::normalize(1));
}

public function test_preserves_string_user_ids_from_flat_file_driver(): void
{
$this->assertSame('flat-file-user', UserIds::normalize('flat-file-user'));
}
}
Loading