Skip to content

API MCP và Tool

MCP là nguồn Tool toàn cục để Package lựa chọn. Chỉ Super Admin sử dụng nhóm API này.

Endpoint

MethodPathScopeChức năng
GET/api/v1/mcpplatform.company.mcp.manageDanh sách MCP và Tool.
POST/api/v1/mcpplatform.company.mcp.manageTạo MCP.
GET/api/v1/mcp/{mcpId}platform.company.mcp.manageChi tiết MCP.
PUT/api/v1/mcp/{mcpId}platform.company.mcp.manageThay cấu hình MCP.
DELETE/api/v1/mcp/{mcpId}platform.company.mcp.manageXóa MCP không hoạt động và chưa được Package dùng.
POST/api/v1/mcp/{mcpId}/checkplatform.company.mcp.manageKiểm tra kết nối, không ghi Tool.
POST/api/v1/mcp/{mcpId}/syncplatform.company.mcp.manageĐọc tools/list và đồng bộ Tool.
PUT/api/v1/mcp/{mcpId}/tools/{toolId}platform.company.mcp.manageBật hoặc tắt Tool.
bash
curl --fail-with-body \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  "$NEXUS_URL/api/v1/mcp"

Tạo MCP

bash
curl --fail-with-body -X POST \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "display_name": "CRM n8n",
    "description": "Tra cứu khách hàng và đơn hàng.",
    "endpoint_url": "https://example.com/mcp",
    "auth_type": "bearer",
    "token": "replace-with-downstream-token",
    "status": "active",
    "timeout_seconds": 10
  }' \
  "$NEXUS_URL/api/v1/mcp"

auth_type nhận none hoặc bearer; status nhận active, pending_configuration hoặc disabled. Token được mã hóa và không xuất lại trong response.

Kiểm tra và đồng bộ Tool

bash
export MCP_ID="1"

curl --fail-with-body -X POST \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  "$NEXUS_URL/api/v1/mcp/$MCP_ID/check"

curl --fail-with-body -X POST \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  "$NEXUS_URL/api/v1/mcp/$MCP_ID/sync"

Bật hoặc tắt Tool

bash
export TOOL_ID="1"

curl --fail-with-body -X PUT \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"status":"active"}' \
  "$NEXUS_URL/api/v1/mcp/$MCP_ID/tools/$TOOL_ID"

Tool mới đồng bộ mặc định không tự được Package cho phép; quyền sử dụng cuối cùng vẫn đi qua Role → Package → MCP → Tool.