mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #6932] Proposal: built-in MCP endpoint so AI agents can manage the panel #4585
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4585
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sepehr071 on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6932
Proposal: built-in MCP endpoint so AI agents can manage the panel
What
Add a Model Context Protocol server to the panel at
POST /panel/api/mcp, so agents such as Claude, Cursor or VS Code Copilot can manage inbounds, clients, traffic, nodes, settings and Xray through the API token operators already use.How (proposed design)
internal/web/mcp, using the official Go SDK (github.com/modelcontextprotocol/go-sdk), stateless streamable-HTTP transport./panel/apigroup, socheckAPIAuth,enforceTokenScopeand CSRF apply unchanged. Only admin tokens can reach it; monitor / node-sync scopes are denied.Authorizationheader. No business logic is duplicated, and all state changes still go throughruntime.Runtime, so multi-node setups stay consistent.call_apitool covers the rest of/panel/api/*.endpoints.ts,make gen, OpenAPI + docs regeneration, tests perCLAUDE.md.Client config example
Questions for maintainers
I'm happy to send the PR.
@github-actions[bot] commented on GitHub (Oct 25, 2026):
This is a valid feature request, and the design you describe fits how the panel's API works today. Whether it ships built-in, and whether it is on by default, is the maintainer's decision. I can't answer your two questions for them. Note that #6658 asks for the same feature, and a collaborator (
NikanZeyaei) has already offered there to build it. Please coordinate on that thread before you start a PR so the two efforts don't collide.Checked against the default branch:
mcp/modelcontextprotocolfinds nothing outsidedocs/pnpm-lock.yaml, andgo.modhas no MCP SDK.enforceTokenScope(internal/web/controller/api.go:142) letsadminthrough with no check. Formonitor,node-syncandnode-adminit allows only routes in fixed allowlists (monitorScopeAllowat:84,nodeSyncScopeAllowat:99,nodeAdminScopeAllowat:127) and otherwise returns"this API token is not permitted to access this endpoint". A new/mcproute in no allowlist would be admin-only for tokens.checkAPIAuthfalls through tosession.IsLogin(c)(api.go:67). A session request sets noapi_token_scope, soenforceTokenScopepasses it (api.go:143-147). Your plan to forward "the caller'sAuthorizationheader" therefore needs a rule for cookie-session callers, who send no such header. The simplest rule is to reject requests without a bearer token.CSRFMiddlewarereturns early whenapi_authedis set (internal/web/middleware/security.go:42), so an MCP client sendingAuthorization: Bearer …needs no CSRF token.CLAUDE.mdrequires every state-changing inbound/client operation to go throughruntime.Runtime. Calling the existing REST handlers keeps that true without copying business logic.endpoints.tsentry pinned byTestRouteRegistryContract, thenmake gen, then copyingfrontend/public/openapi.jsontodocs/public/openapi.jsonand runningpnpm gen:api. Any new response struct also needs an entry in the openapigenStructAllowlist. Your proposal already lists most of these.Usable today without code changes: the panel serves its OpenAPI spec at
/panel/api/openapi.json(api.go:203). A generic OpenAPI-to-MCP bridge running on your own machine can use it with anadmintoken, or with amonitortoken for read-only access.Verdict: Feature request
This reply was generated automatically; a maintainer may follow up.