trypost/app/Mcp/Servers/TryPostServer.php
Paulo Castellano fabce14aad feat: implement MCP server with tools, Post API tests, auth middleware
- Create TryPostServer MCP server with 17 tools:
  Post (List, Get, Create, Delete), Hashtag (List, Create, Update, Delete),
  Label (List, Create, Update, Delete), Workspace (Get),
  ApiKey (List, Create, Delete)
- Create AuthenticateMcpToken middleware (logs in workspace owner)
- Register mcp.auth middleware alias in bootstrap/app.php
- Create routes/ai.php with mcp.trypost.test subdomain
- Add PostApiTest with 6 tests (list, show, create, delete, isolation)
- Fix PostApiTest assertions for pagination/resource wrapping
- 704 tests passing, frontend build passing
2026-03-29 20:30:36 -03:00

66 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Mcp\Servers;
use App\Mcp\Tools\ApiKey\CreateApiKeyTool;
use App\Mcp\Tools\ApiKey\DeleteApiKeyTool;
use App\Mcp\Tools\ApiKey\ListApiKeysTool;
use App\Mcp\Tools\Hashtag\CreateHashtagTool;
use App\Mcp\Tools\Hashtag\DeleteHashtagTool;
use App\Mcp\Tools\Hashtag\ListHashtagsTool;
use App\Mcp\Tools\Hashtag\UpdateHashtagTool;
use App\Mcp\Tools\Label\CreateLabelTool;
use App\Mcp\Tools\Label\DeleteLabelTool;
use App\Mcp\Tools\Label\ListLabelsTool;
use App\Mcp\Tools\Label\UpdateLabelTool;
use App\Mcp\Tools\Post\CreatePostTool;
use App\Mcp\Tools\Post\DeletePostTool;
use App\Mcp\Tools\Post\GetPostTool;
use App\Mcp\Tools\Post\ListPostsTool;
use App\Mcp\Tools\Workspace\GetWorkspaceTool;
use Laravel\Mcp\Server;
use Laravel\Mcp\Server\Attributes\Instructions;
use Laravel\Mcp\Server\Attributes\Name;
use Laravel\Mcp\Server\Attributes\Version;
#[Name('TryPost')]
#[Version('1.0.0')]
#[Instructions('TryPost is a social media scheduling platform. Use this server to manage posts, hashtag groups, labels, workspaces, and API keys.')]
class TryPostServer extends Server
{
public int $defaultPaginationLength = 100;
protected array $tools = [
// Posts
ListPostsTool::class,
GetPostTool::class,
CreatePostTool::class,
DeletePostTool::class,
// Hashtags
ListHashtagsTool::class,
CreateHashtagTool::class,
UpdateHashtagTool::class,
DeleteHashtagTool::class,
// Labels
ListLabelsTool::class,
CreateLabelTool::class,
UpdateLabelTool::class,
DeleteLabelTool::class,
// Workspace
GetWorkspaceTool::class,
// API Keys
ListApiKeysTool::class,
CreateApiKeyTool::class,
DeleteApiKeyTool::class,
];
protected array $resources = [];
protected array $prompts = [];
}