MCP server overview
Casdoor has a built-in Model Context Protocol (MCP) server at /api/mcp. MCP clients, such as AI assistants and automation tools, call it to manage applications, users, and other Casdoor objects, without using the REST API directly.
MCP is a protocol on top of JSON-RPC 2.0 through which a client discovers the tools of a server and calls them.
Casdoor works with MCP in two directions:
- As an MCP server: Casdoor offers its own management functions as tools. The pages of this section describe this server.
- As a registry of external MCP servers: Casdoor stores the MCP servers that your organization uses, with their tokens and the tools that you allow. See Register an external MCP server.
Connect to the Casdoor MCP server
The endpoint /api/mcp accepts POST requests with JSON-RPC 2.0 payloads. Before a client calls tools, it completes the initialization handshake.
-
The client sends
initialize:POST /api/mcp
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {
"name": "my-client",
"version": "1.0.0"
}
}
} -
Casdoor answers with its capabilities:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2024-11-05",
"capabilities": {
"tools": {
"listChanged": true
}
},
"serverInfo": {
"name": "Casdoor MCP Server",
"version": "1.0.0"
}
}
} -
The client confirms that it is ready:
POST /api/mcp
{
"jsonrpc": "2.0",
"method": "notifications/initialized"
}
MCP client libraries perform the handshake for you. To connect a specific client, see:
Register an external MCP server
-
In the Casdoor admin console, open the MCP Servers page and add a server.
-
Fill in the following fields:
フィールド 説明 Name Unique identifier for this server entry 表示名 Human-readable label shown in the UI URL The external MCP server's endpoint Application Casdoor application associated with this server (used for auth context) Token Bearer token used to authenticate with the external server Tools List of tools fetched from the server; each tool can be individually allowed or blocked -
Save the server. Casdoor fetches the list of tools from the server and stores it.