140 lines
3.0 KiB
Markdown
140 lines
3.0 KiB
Markdown
# Практические API-примеры
|
|
|
|
Здесь собраны минимальные запросы для проверки Crank без веб-интерфейса.
|
|
|
|
В примерах используется:
|
|
|
|
```text
|
|
https://crank.example.com
|
|
```
|
|
|
|
Замените адрес на свой.
|
|
|
|
## Вход
|
|
|
|
```bash
|
|
curl -i https://crank.example.com/api/auth/login \
|
|
-H 'Content-Type: application/json' \
|
|
--data '{
|
|
"email": "owner@example.com",
|
|
"password": "change-me"
|
|
}'
|
|
```
|
|
|
|
Сохраните cookie `crank_session`.
|
|
|
|
## Получить workspace
|
|
|
|
```bash
|
|
curl https://crank.example.com/api/admin/workspaces \
|
|
-b 'crank_session=<cookie_value>'
|
|
```
|
|
|
|
Для стандартной установки workspace id:
|
|
|
|
```text
|
|
ws_default
|
|
```
|
|
|
|
## Получить операции
|
|
|
|
```bash
|
|
curl https://crank.example.com/api/admin/workspaces/ws_default/operations \
|
|
-b 'crank_session=<cookie_value>'
|
|
```
|
|
|
|
После demo seed ожидается операция:
|
|
|
|
```text
|
|
frankfurter_latest_rate
|
|
```
|
|
|
|
## Запустить тест операции
|
|
|
|
```bash
|
|
curl https://crank.example.com/api/admin/workspaces/ws_default/operations/<operation_id>/test-runs \
|
|
-b 'crank_session=<cookie_value>' \
|
|
-H 'Content-Type: application/json' \
|
|
--data '{
|
|
"version": 1,
|
|
"input": {
|
|
"base": "USD",
|
|
"quote": "EUR"
|
|
}
|
|
}'
|
|
```
|
|
|
|
## Получить агентов
|
|
|
|
```bash
|
|
curl https://crank.example.com/api/admin/workspaces/ws_default/agents \
|
|
-b 'crank_session=<cookie_value>'
|
|
```
|
|
|
|
После demo seed ожидается агент:
|
|
|
|
```text
|
|
currency-rates
|
|
```
|
|
|
|
## Создать API-ключ агента
|
|
|
|
```bash
|
|
curl https://crank.example.com/api/admin/workspaces/ws_default/agents/<agent_id>/platform-api-keys \
|
|
-b 'crank_session=<cookie_value>' \
|
|
-H 'Content-Type: application/json' \
|
|
--data '{
|
|
"name": "Manual MCP test",
|
|
"scopes": ["read", "write"]
|
|
}'
|
|
```
|
|
|
|
Сохраните поле `secret`. Оно не будет показано повторно.
|
|
|
|
## Проверить MCP initialize
|
|
|
|
```bash
|
|
curl -i https://crank.example.com/mcp/v1/default/currency-rates \
|
|
-H 'Authorization: Bearer <agent_api_key>' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Accept: application/json, text/event-stream' \
|
|
--data '{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"method": "initialize",
|
|
"params": {
|
|
"protocolVersion": "2025-06-18",
|
|
"capabilities": {},
|
|
"clientInfo": {
|
|
"name": "curl",
|
|
"version": "1.0.0"
|
|
}
|
|
}
|
|
}'
|
|
```
|
|
|
|
Сохраните `MCP-Session-Id` из заголовков ответа.
|
|
|
|
## Вызвать инструмент
|
|
|
|
```bash
|
|
curl https://crank.example.com/mcp/v1/default/currency-rates \
|
|
-H 'Authorization: Bearer <agent_api_key>' \
|
|
-H 'Content-Type: application/json' \
|
|
-H 'Accept: application/json' \
|
|
-H 'MCP-Session-Id: <session_id>' \
|
|
--data '{
|
|
"jsonrpc": "2.0",
|
|
"id": 2,
|
|
"method": "tools/call",
|
|
"params": {
|
|
"name": "frankfurter_latest_rate",
|
|
"arguments": {
|
|
"base": "USD",
|
|
"quote": "EUR"
|
|
}
|
|
}
|
|
}'
|
|
```
|
|
|