Перейти до основного вмісту

Довідник інструментів MCP

MCP-сервер Casdoor пропонує інструменти для керування об'єктами Casdoor. На цій сторінці описано, як переглянути список інструментів, як їх викликати та що вони повертають.

Перегляд інструментів​

Викличте tools/list:

POST /api/mcp
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/list"
}

Той набір інструментів, який містить відповідь, залежить від способу автентифікації запиту:

AuthenticationTools in the response
NoneAll tools, so that clients can discover them. Calling a tool still requires authentication
Session cookieAll tools
Access tokenThe 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"]
}
}
]
}
}

Інструменти додатків​

ToolDescription
get_applicationsGets all applications of an organization
get_applicationGets one application
add_applicationCreates an application
update_applicationChanges an application
delete_applicationDeletes 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"
}
}
}
}

Інструменти користувача​

Інструменти користувача працюють так само, як інструменти додатків.

ToolArgumentsDescription
get_usersownerLists all users of an organization
get_userid, or owner and email, or owner and phoneGets one user
add_useruser objectCreates a user
update_userid and user objectChanges a user
delete_useruser objectDeletes a user

Інші інструменти​

З комерційною або корпоративною ліцензією сервер також має інструменти для organization, provider, role, permission, group, cert та token, інструменти для налаштування додатка для app та підключення стороннього входу, пробний запуск (dry run) кожної зміни, запис про те, що змінили агенти, а також затвердження та відкат змін. Див. Let AI agents manage Casdoor. Для області видимості (scope), яку потребує кожен інструмент, див. scope reference.

Формат результату​

Успішний виклик повертає результат як вміст (content):

{
"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
}
}

Помилки самого протоколу, наприклад відсутня область (scope), є помилками JSON-RPC. Дивіться обробка помилок MCP.

Дивіться також​