feat(mcp): add a built-in MCP server at /panel/api/mcp (#6956)

AI agents (Claude, Cursor, VS Code) can manage the panel through a stateless streamable-HTTP MCP endpoint. Every tool re-enters the router with the caller's credentials, so authentication, token scopes, CSRF and runtime.Runtime dispatch apply exactly as for the REST API; a restricted token scope is refused, log text is fenced as untrusted data, and each tool call is written to the panel log.

The endpoint hands an API token's whole reach to the agent that holds it, so it is off by default: a panel answers 404 until the MCP server is enabled under Settings -> Security -> API Token (the mcpEnable setting).
This commit is contained in:
Sepehr Radmard
2026-11-25 00:32:22 +03:30
committed by GitHub
parent 3f2a2195a8
commit ac31455d99
45 changed files with 2702 additions and 4 deletions
@@ -0,0 +1,39 @@
---
title: MCP
description: Model Context Protocol endpoint for AI agents (Claude, Cursor, VS
Code). Point an MCP client at this URL with an admin Bearer token; restricted
token scopes are refused.
full: true
_openapi:
preload:
- ./public/openapi.json
toc:
- depth: 2
title: 'Stateless streamable-HTTP MCP endpoint (JSON-RPC 2.0). Exposes panel
tools for inbounds, clients, server, Xray, nodes, hosts and settings;
each tool call runs the matching /panel/api route with the caller’s
credentials. Off by default: answers 404 until the MCP server is enabled
under Settings → Security → API Token.'
url: '#stateless-streamable-http-mcp-endpoint-json-rpc-20-exposes-panel-tools-for-inbounds-clients-server-xray-nodes-hosts-and-settings-each-tool-call-runs-the-matching-panelapi-route-with-the-callers-credentials-off-by-default-answers-404-until-the-mcp-server-is-enabled-under-settings--security--api-token'
structuredData:
headings:
- content: 'Stateless streamable-HTTP MCP endpoint (JSON-RPC 2.0). Exposes panel
tools for inbounds, clients, server, Xray, nodes, hosts and settings;
each tool call runs the matching /panel/api route with the caller’s
credentials. Off by default: answers 404 until the MCP server is
enabled under Settings → Security → API Token.'
id: stateless-streamable-http-mcp-endpoint-json-rpc-20-exposes-panel-tools-for-inbounds-clients-server-xray-nodes-hosts-and-settings-each-tool-call-runs-the-matching-panelapi-route-with-the-callers-credentials-off-by-default-answers-404-until-the-mcp-server-is-enabled-under-settings--security--api-token
contents: []
---
{/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */}
export default function Layout(props) {
const { OpenAPIPage } = props.components ?? {};
return (
<>
{props.children}
<OpenAPIPage document="./public/openapi.json" webhooks={[]} operations={[{"path":"/panel/api/mcp","method":"post"}]} showTitle />
</>
);
}
@@ -15,6 +15,7 @@
"hosts",
"nodes",
"backup",
"mcp",
"websocket"
]
}
+68
View File
@@ -152,6 +152,9 @@
"ldapVlessField": {
"type": "string"
},
"mcpEnable": {
"type": "boolean"
},
"networkTrafficInterface": {
"example": "eth0",
"type": "string"
@@ -721,6 +724,7 @@
"ldapUserAttr",
"ldapUserFilter",
"ldapVlessField",
"mcpEnable",
"networkTrafficInterface",
"networkTrafficMode",
"nodeDownThreshold",
@@ -1041,6 +1045,9 @@
"ldapVlessField": {
"type": "string"
},
"mcpEnable": {
"type": "boolean"
},
"networkTrafficInterface": {
"example": "eth0",
"type": "string"
@@ -1620,6 +1627,7 @@
"ldapUserAttr",
"ldapUserFilter",
"ldapVlessField",
"mcpEnable",
"networkTrafficInterface",
"networkTrafficMode",
"nodeDownThreshold",
@@ -5562,6 +5570,10 @@
"name": "Backup",
"description": "Operations that interact with the configured Telegram bot."
},
{
"name": "MCP",
"description": "Model Context Protocol endpoint for AI agents (Claude, Cursor, VS Code). Point an MCP client at this URL with an admin Bearer token; restricted token scopes are refused."
},
{
"name": "Settings",
"description": "Panel configuration and user credentials. All endpoints live under /panel/api/setting and require a logged-in session or Bearer token."
@@ -14605,6 +14617,62 @@
}
}
},
"/panel/api/mcp": {
"post": {
"tags": [
"MCP"
],
"summary": "Stateless streamable-HTTP MCP endpoint (JSON-RPC 2.0). Exposes panel tools for inbounds, clients, server, Xray, nodes, hosts and settings; each tool call runs the matching /panel/api route with the caller’s credentials. Off by default: answers 404 until the MCP server is enabled under Settings → Security → API Token.",
"operationId": "post_panel_api_mcp",
"parameters": [
{
"name": "toolsets",
"in": "query",
"required": false,
"description": "Comma-separated tool groups to expose: inbounds, clients, server, panel. Omit for all. call_api and get_openapi_spec are always included.",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object"
},
"example": {
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}
}
}
},
"responses": {
"200": {
"description": "Successful response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"msg": {
"type": "string"
},
"obj": {}
}
}
}
}
}
}
}
},
"/panel/api/setting/all": {
"post": {
"tags": [