Open-source social media scheduler built for AI agents and the teams behind them. Create, schedule and publish posts to every network through MCP or the REST API, or write them yourself in a composer your team will love.
PHP ai-agentsblueskyfacebookinstagramlaravellinkedinmastodonmcpmcp-serveropen-sourcerest-apiself-hostedsocial-mediasocial-media-managementsocial-media-schedulerthreadstiktokvuejsxyoutube
Compare the remaining MCP methods with the Method enum (#441)
Paulo Castellano28ed431ba41c
diff --git a/.ai/rules/mcp.md b/.ai/rules/mcp.mdindex 023295725..f27907cdd 100644--- a/.ai/rules/mcp.md+++ b/.ai/rules/mcp.md@@ -9,4 +9,4 @@ paths:# Mcp## Compare MCP JSON-RPC methods with App\Enums\Mcp\Method-Never compare an MCP method as a string literal ('tools/call', 'tools/list', 'initialize', ...). Use `App\Enums\Mcp\Method`, comparing the raw value strictly: `$request->json('method') !== Method::ToolsCall->value` (`LoadMcpWorkspace`). Never `$request->enum('method', Method::class)`: the body is client input, and a non-scalar `method` makes `tryFrom()` throw a TypeError, which turns laravel/mcp's JSON-RPC -32600 into a 500. laravel/mcp keeps its method names in the protected `Server::$methods` array, so there is no package constant. A method the app starts reading gets a case in the enum. `ChallengeChatGptToolCalls`, `ChatGptMcpClient` and `TryPostServer` still use strings; moving them is issue #438.+Never compare an MCP method as a string literal ('tools/call', 'tools/list', 'initialize', ...). Use `App\Enums\Mcp\Method`, comparing the raw value strictly: `$request->json('method') !== Method::ToolsCall->value` (`LoadMcpWorkspace`). Never `$request->enum('method', Method::class)`: the body is client input, and a non-scalar `method` makes `tryFrom()` throw a TypeError, which turns laravel/mcp's JSON-RPC -32600 into a 500. laravel/mcp keeps its method names in the protected `Server::$methods` array, so there is no package constant. A method the app starts reading gets a case in the enum.diff --git a/app/Http/Middleware/Mcp/ChallengeChatGptToolCalls.php b/app/Http/Middleware/Mcp/ChallengeChatGptToolCalls.phpindex 7c4876fd3..ded20f04e 100644--- a/app/Http/Middleware/Mcp/ChallengeChatGptToolCalls.php+++ b/app/Http/Middleware/Mcp/ChallengeChatGptToolCalls.php@@ -4,6 +4,7 @@ declare(strict_types=1);namespace App\Http\Middleware\Mcp;+use App\Enums\Mcp\Method;use App\Support\Mcp\ChatGptMcpClient;use Closure;use Illuminate\Http\Request;@@ -32,7 +33,7 @@ class ChallengeChatGptToolCalls$call = rescue(fn (): JsonRpcRequest => JsonRpcRequest::from($request->json()->all()), report: false);- if ($call?->method !== 'tools/call') {+ if ($call?->method !== Method::ToolsCall->value) {return $response;}diff --git a/app/Mcp/Servers/TryPostServer.php b/app/Mcp/Servers/TryPostServer.phpindex e7a302ee5..266e40f2e 100644--- a/app/Mcp/Servers/TryPostServer.php+++ b/app/Mcp/Servers/TryPostServer.php@@ -4,6 +4,7 @@ declare(strict_types=1);namespace App\Mcp\Servers;+use App\Enums\Mcp\Method;use App\Mcp\Methods\ListToolsWithSecuritySchemes;use App\Mcp\Tools\Analytics\GetAnalyticsPublicationTool;use App\Mcp\Tools\Analytics\GetAnalyticsReportTool;@@ -206,6 +207,6 @@ class TryPostServer extends Serverprotected function boot(): void{- $this->addMethod('tools/list', ListToolsWithSecuritySchemes::class);+ $this->addMethod(Method::ToolsList->value, ListToolsWithSecuritySchemes::class);}}diff --git a/app/Support/Mcp/ChatGptMcpClient.php b/app/Support/Mcp/ChatGptMcpClient.phpindex cb54fc428..97f7b99cc 100644--- a/app/Support/Mcp/ChatGptMcpClient.php+++ b/app/Support/Mcp/ChatGptMcpClient.php@@ -5,6 +5,7 @@ declare(strict_types=1);namespace App\Support\Mcp;use App\Actions\Mcp\ListChatGptEgressRanges;+use App\Enums\Mcp\Method;use Illuminate\Http\Request;use Symfony\Component\HttpFoundation\IpUtils;@@ -14,7 +15,12 @@ class ChatGptMcpClient* JSON-RPC methods ChatGPT may call without a token: connecting and* reading the tool list. A tool call always needs a token.*/- private const DISCOVERY_METHODS = ['initialize', 'notifications/initialized', 'ping', 'tools/list'];+ private const DISCOVERY_METHODS = [+ Method::Initialize->value,+ Method::NotificationsInitialized->value,+ Method::Ping->value,+ Method::ToolsList->value,+ ];/*** Passport blanks the Authorization header when it refuses a token, so