๐—•๐—จ๐—œ๐—Ÿ๐——๐—œ๐—ก๐—š ๐—” ๐—ฃ๐—˜๐—ฅ๐— ๐—œ๐—ฆ๐—ฆ๐—œ๐—ข๐—ก-๐—š๐—”๐—ง๐—˜๐—— ๐— ๐—–๐—ฃ ๐—ฆ๐—˜๐—ฅ๐—ฉ๐—˜๐—ฅ I built an MCP server in a Laravel app that manages a Kong API gateway. The challenge was to ensure the MCP layer follows the same rules as the web UI and HTTP API, without creating a backdoor that skips authorization.

Here's how I did it:

I used an abstract base class to push auth checks into a single place. Each concrete tool declares the permission it needs, and the base decides whether the caller is allowed.

Key takeaways:

This approach ensures the AI is useful without being sneaky. The MCP server is a powerful new surface, and it should be the least privileged one.

Source: https://dev.to/nasrulhazim/building-a-permission-gated-mcp-server-in-laravel-without-opening-a-backdoor-3jk5