MCP工具参考
Casdoor MCP 服务器提供了管理 Casdoor 对象的工具。本页介绍如何列出这些工具、如何调用它们以及它们的返回值。
列出工具
调用 tools/list:
POST /api/mcp
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list"
}
响应中包含哪些工具取决于请求的身份验证方式:
| Authentication | Tools in the response |
|---|---|
| None | All tools, so that clients can discover them. Calling a tool still requires authentication |
| Session cookie | All tools |
| Access token | The tools that the scopes of the token allow |
每个工具都带有描述和输入模式:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"tools": [
{
"name": "get_applications",
"description": "Get all applications for a specific owner",
"inputSchema": {
"type": "object",
"properties": {
"owner": {
"type": "string",
"description": "The owner of applications"
}
},
"required": ["owner"]
}
}
]
}
}
应用工具
| Tool | Description |
|---|---|
get_applications | Gets all applications of an organization |
get_application | Gets one application |
add_application | Creates an application |
update_application | Changes an application |
delete_application | Deletes an application |
使用 tools/call、工具名称及其参数来调用工具。
get_applications:
{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "get_applications",
"arguments": {
"owner": "my-org"
}
}
}
get_application:
{
"jsonrpc": "2.0",
"id": 4,
"method": "tools/call",
"params": {
"name": "get_application",
"arguments": {
"id": "my-org/my-app"
}
}
}
add_application:
{
"jsonrpc": "2.0",
"id": 5,
"method": "tools/call",
"params": {
"name": "add_application",
"arguments": {
"application": {
"owner": "my-org",
"name": "new-app",
"displayName": "New Application",
"organization": "my-org"
}
}
}
}
update_application:
{
"jsonrpc": "2.0",
"id": 6,
"method": "tools/call",
"params": {
"name": "update_application",
"arguments": {
"id": "my-org/my-app",
"application": {
"owner": "my-org",
"name": "my-app",
"displayName": "Updated Name"
}
}
}
}
delete_application:
{
"jsonrpc": "2.0",
"id": 7,
"method": "tools/call",
"params": {
"name": "delete_application",
"arguments": {
"application": {
"owner": "my-org",
"name": "old-app"
}
}
}
}
用户工具
用户工具的工作方式与应用工具相同。
| Tool | Arguments | Description |
|---|---|---|
get_users | owner | Lists all users of an organization |
get_user | id, or owner and email, or owner and phone | Gets one user |
add_user | user object | Creates a user |
update_user | id and user object | Changes a user |
delete_user | user object | Deletes a user |
其他工具
使用商业或企业许可证时,服务器还提供用于组织、提供商、角色、权限、群组、证书和令牌的工具,用于为应用配置应用并连接第三方登录的工具,每项更改的试运行功能,记录智能体所做更改的功能,以及更改的批准和回滚功能。请参阅 让 AI 智能体管理 Casdoor。有关每个工具所需的范围,请参阅 范围参考。
结果格式
成功的调用会将结果作为内容返回:
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"content": [
{
"type": "text",
"text": "[{\"name\":\"app1\",\"displayName\":\"App 1\"}]"
}
]
}
}
当工具执行失败时,结果包含 isError 标志:
{
"jsonrpc": "2.0",
"id": 5,
"result": {
"content": [
{
"type": "text",
"text": "application quota is exceeded"
}
],
"isError": true
}
}
协议本身的错误(例如缺少作用域)是 JSON-RPC 错误。请参阅 MCP 错误处理。