Expose ITAM devices on MCP, CLI, and n8n
Devices were only available through GraphQL and the agent API. Add list/get/revoke/delete/set-owner across MCP, prb, and n8n, with latest postures nested on list and get responses. Signed-off-by: Ludovic Vielle <ludovic@probo.com>
This commit is contained in:
@@ -245,6 +245,7 @@ func NewServer(cfg Config) (*Server, error) {
|
||||
cfg.AccessReview,
|
||||
cfg.CookieBanner,
|
||||
cfg.RiskManagement,
|
||||
cfg.ITAM,
|
||||
cfg.TokenSecret,
|
||||
cfg.File,
|
||||
cfg.BaseURL,
|
||||
|
||||
@@ -199,6 +199,10 @@ func (r *mutationResolver) CreateDevice(ctx context.Context, input types.CreateD
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, itam.ErrInvalidOwnerProfile) {
|
||||
return nil, gqlutils.Invalid(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot create device", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
@@ -277,6 +281,10 @@ func (r *mutationResolver) SetDeviceOwner(ctx context.Context, input types.SetDe
|
||||
return nil, gqlutils.NotFound(ctx, err)
|
||||
}
|
||||
|
||||
if errors.Is(err, itam.ErrInvalidOwnerProfile) {
|
||||
return nil, gqlutils.Invalid(ctx, err)
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot set device owner", log.Error(err))
|
||||
|
||||
return nil, gqlutils.Internal(ctx)
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
"go.probo.inc/probo/pkg/filemanager"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
"go.probo.inc/probo/pkg/itam"
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
"go.probo.inc/probo/pkg/prosemirror"
|
||||
"go.probo.inc/probo/pkg/resourcealias"
|
||||
@@ -47,6 +48,10 @@ import (
|
||||
"go.probo.inc/probo/pkg/thirdparty"
|
||||
)
|
||||
|
||||
// maxDeviceListSize caps the listDevices page size: with include_postures the
|
||||
// resolver runs one posture query per returned device.
|
||||
const maxDeviceListSize = 100
|
||||
|
||||
type Resolver struct {
|
||||
proboSvc *probo.Service
|
||||
management *management.Service
|
||||
@@ -57,6 +62,7 @@ type Resolver struct {
|
||||
accessReview *accessreview.Service
|
||||
cookieBanner *cookiebanner.Service
|
||||
riskManagement *riskmanagement.Service
|
||||
itamSvc *itam.Service
|
||||
logger *log.Logger
|
||||
fileManager *filemanager.Service
|
||||
baseURL *baseurl.BaseURL
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
"go.probo.inc/probo/pkg/itam"
|
||||
"go.probo.inc/probo/pkg/mail"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
@@ -7422,3 +7423,182 @@ func (r *Resolver) RequestSCIMEventExportTool(ctx context.Context, req *mcp.Call
|
||||
ExportJobID: logExport.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) ListDevicesTool(ctx context.Context, req *mcp.CallToolRequest, input *types.ListDevicesInput) (*mcp.CallToolResult, types.ListDevicesOutput, error) {
|
||||
scope, err := r.Authorize(ctx, input.OrganizationID, itam.ActionDeviceList)
|
||||
if err != nil {
|
||||
return nil, types.ListDevicesOutput{}, err
|
||||
}
|
||||
|
||||
pageOrderBy := page.OrderBy[coredata.DeviceOrderField]{
|
||||
Field: coredata.DeviceOrderFieldCreatedAt,
|
||||
Direction: page.OrderDirectionDesc,
|
||||
}
|
||||
|
||||
if input.OrderBy != nil {
|
||||
pageOrderBy = page.OrderBy[coredata.DeviceOrderField]{
|
||||
Field: input.OrderBy.Field,
|
||||
Direction: input.OrderBy.Direction,
|
||||
}
|
||||
}
|
||||
|
||||
size := input.Size
|
||||
if size != nil && *size > maxDeviceListSize {
|
||||
size = new(maxDeviceListSize)
|
||||
}
|
||||
|
||||
cursor := types.NewCursor(size, input.Cursor, pageOrderBy)
|
||||
|
||||
devicePage, err := r.itamSvc.ListForOrganizationID(ctx, scope, input.OrganizationID, cursor)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot list devices", log.Error(err))
|
||||
|
||||
return nil, types.ListDevicesOutput{}, fmt.Errorf("internal server error")
|
||||
}
|
||||
|
||||
includePostures := input.IncludePostures != nil && *input.IncludePostures
|
||||
|
||||
var postureScope *coredata.Scope
|
||||
|
||||
if includePostures && len(devicePage.Data) > 0 {
|
||||
deviceIDs := make([]gid.GID, 0, len(devicePage.Data))
|
||||
for _, d := range devicePage.Data {
|
||||
deviceIDs = append(deviceIDs, d.ID)
|
||||
}
|
||||
|
||||
postureScope, err = r.AuthorizeBatch(ctx, deviceIDs, itam.ActionDevicePostureList)
|
||||
if err != nil {
|
||||
return nil, types.ListDevicesOutput{}, err
|
||||
}
|
||||
}
|
||||
|
||||
posturesByDeviceID := make(map[gid.GID]coredata.DevicePostures, len(devicePage.Data))
|
||||
for _, d := range devicePage.Data {
|
||||
if postureScope == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
postures, err := r.itamSvc.GetLatestPostures(ctx, postureScope, d.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load latest device postures", log.Error(err))
|
||||
|
||||
return nil, types.ListDevicesOutput{}, fmt.Errorf("internal server error")
|
||||
}
|
||||
|
||||
posturesByDeviceID[d.ID] = postures
|
||||
}
|
||||
|
||||
return nil, types.NewListDevicesOutput(devicePage, posturesByDeviceID), nil
|
||||
}
|
||||
|
||||
func (r *Resolver) GetDeviceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.GetDeviceInput) (*mcp.CallToolResult, types.GetDeviceOutput, error) {
|
||||
scope, err := r.Authorize(ctx, input.ID, itam.ActionDeviceGet)
|
||||
if err != nil {
|
||||
return nil, types.GetDeviceOutput{}, err
|
||||
}
|
||||
|
||||
device, err := r.itamSvc.GetDevice(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, types.GetDeviceOutput{}, fmt.Errorf("resource not found")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot get device", log.Error(err))
|
||||
|
||||
return nil, types.GetDeviceOutput{}, fmt.Errorf("internal server error")
|
||||
}
|
||||
|
||||
var postures coredata.DevicePostures
|
||||
|
||||
if input.IncludePostures != nil && *input.IncludePostures {
|
||||
postureScope, err := r.Authorize(ctx, input.ID, itam.ActionDevicePostureList)
|
||||
if err != nil {
|
||||
return nil, types.GetDeviceOutput{}, err
|
||||
}
|
||||
|
||||
postures, err = r.itamSvc.GetLatestPostures(ctx, postureScope, device.ID)
|
||||
if err != nil {
|
||||
r.logger.ErrorCtx(ctx, "cannot load latest device postures", log.Error(err))
|
||||
|
||||
return nil, types.GetDeviceOutput{}, fmt.Errorf("internal server error")
|
||||
}
|
||||
}
|
||||
|
||||
return nil, types.GetDeviceOutput{
|
||||
Device: types.NewDevice(device, postures),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) RevokeDeviceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.RevokeDeviceInput) (*mcp.CallToolResult, types.RevokeDeviceOutput, error) {
|
||||
scope, err := r.Authorize(ctx, input.ID, itam.ActionDeviceRevoke)
|
||||
if err != nil {
|
||||
return nil, types.RevokeDeviceOutput{}, err
|
||||
}
|
||||
|
||||
device, err := r.itamSvc.RevokeDevice(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, types.RevokeDeviceOutput{}, fmt.Errorf("resource not found")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot revoke device", log.Error(err))
|
||||
|
||||
return nil, types.RevokeDeviceOutput{}, fmt.Errorf("internal server error")
|
||||
}
|
||||
|
||||
return nil, types.RevokeDeviceOutput{
|
||||
Device: types.NewDevice(device, nil),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) DeleteDeviceTool(ctx context.Context, req *mcp.CallToolRequest, input *types.DeleteDeviceInput) (*mcp.CallToolResult, types.DeleteDeviceOutput, error) {
|
||||
scope, err := r.Authorize(ctx, input.ID, itam.ActionDeviceDelete)
|
||||
if err != nil {
|
||||
return nil, types.DeleteDeviceOutput{}, err
|
||||
}
|
||||
|
||||
device, err := r.itamSvc.DeleteDevice(ctx, scope, input.ID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, types.DeleteDeviceOutput{}, fmt.Errorf("resource not found")
|
||||
}
|
||||
|
||||
if errors.Is(err, itam.ErrDeviceNotDeletable) {
|
||||
return nil, types.DeleteDeviceOutput{}, fmt.Errorf("device cannot be deleted")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot delete device", log.Error(err))
|
||||
|
||||
return nil, types.DeleteDeviceOutput{}, fmt.Errorf("internal server error")
|
||||
}
|
||||
|
||||
return nil, types.DeleteDeviceOutput{
|
||||
DeletedDeviceID: device.ID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *Resolver) SetDeviceOwnerTool(ctx context.Context, req *mcp.CallToolRequest, input *types.SetDeviceOwnerInput) (*mcp.CallToolResult, types.SetDeviceOwnerOutput, error) {
|
||||
scope, err := r.Authorize(ctx, input.ID, itam.ActionDeviceAssignOwner)
|
||||
if err != nil {
|
||||
return nil, types.SetDeviceOwnerOutput{}, err
|
||||
}
|
||||
|
||||
device, err := r.itamSvc.SetDeviceOwner(ctx, scope, input.ID, input.OwnerID)
|
||||
if err != nil {
|
||||
if errors.Is(err, coredata.ErrResourceNotFound) {
|
||||
return nil, types.SetDeviceOwnerOutput{}, fmt.Errorf("resource not found")
|
||||
}
|
||||
|
||||
if errors.Is(err, itam.ErrInvalidOwnerProfile) {
|
||||
return nil, types.SetDeviceOwnerOutput{}, fmt.Errorf("owner_id must reference a membership profile of the device organization")
|
||||
}
|
||||
|
||||
r.logger.ErrorCtx(ctx, "cannot set device owner", log.Error(err))
|
||||
|
||||
return nil, types.SetDeviceOwnerOutput{}, fmt.Errorf("internal server error")
|
||||
}
|
||||
|
||||
return nil, types.SetDeviceOwnerOutput{
|
||||
Device: types.NewDevice(device, nil),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -2872,6 +2872,319 @@ components:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Deleted asset ID
|
||||
|
||||
DeviceState:
|
||||
type: string
|
||||
description: Device lifecycle state. PENDING means an enrollment token was issued but the agent has never checked in; ACTIVE means the agent is heartbeating; REVOKED means enrollment was revoked.
|
||||
enum:
|
||||
- PENDING
|
||||
- ACTIVE
|
||||
- REVOKED
|
||||
go.probo.inc/mcpgen/type: go.probo.inc/probo/pkg/coredata.DeviceState
|
||||
|
||||
DevicePlatform:
|
||||
type: string
|
||||
enum:
|
||||
- DARWIN
|
||||
- LINUX
|
||||
- FREEBSD
|
||||
- WINDOWS
|
||||
go.probo.inc/mcpgen/type: go.probo.inc/probo/pkg/coredata.DevicePlatform
|
||||
|
||||
DevicePostureStatus:
|
||||
type: string
|
||||
description: Posture check verdict. PASS and FAIL are compliance outcomes; UNKNOWN means the agent could not determine a result; NOT_APPLICABLE means the check does not apply on this host or platform (for example no screen-lock tool on a headless Linux host).
|
||||
enum:
|
||||
- PASS
|
||||
- FAIL
|
||||
- UNKNOWN
|
||||
- NOT_APPLICABLE
|
||||
go.probo.inc/mcpgen/type: go.probo.inc/probo/pkg/coredata.DevicePostureStatus
|
||||
|
||||
DevicePostureValueKind:
|
||||
type: string
|
||||
description: Machine-readable observation class for a posture value. Use kind to interpret text and number; kind is not the compliance verdict (see status). SECONDS and MIN_PASSWORD_LENGTH carry a value in number; TEXT carries a literal in text; other kinds are self-describing (ON, OFF, IMMEDIATE, CONFIGURED, NONE, UNKNOWN).
|
||||
enum:
|
||||
- ON
|
||||
- OFF
|
||||
- IMMEDIATE
|
||||
- SECONDS
|
||||
- MIN_PASSWORD_LENGTH
|
||||
- CONFIGURED
|
||||
- NONE
|
||||
- TEXT
|
||||
- UNKNOWN
|
||||
go.probo.inc/mcpgen/type: go.probo.inc/probo/pkg/coredata.DevicePostureValueKind
|
||||
|
||||
DeviceOrderField:
|
||||
type: string
|
||||
enum:
|
||||
- CREATED_AT
|
||||
- UPDATED_AT
|
||||
- HOSTNAME
|
||||
- LAST_SEEN_AT
|
||||
go.probo.inc/mcpgen/type: go.probo.inc/probo/pkg/coredata.DeviceOrderField
|
||||
|
||||
DeviceOrderBy:
|
||||
type: object
|
||||
required:
|
||||
- field
|
||||
- direction
|
||||
properties:
|
||||
field:
|
||||
$ref: "#/components/schemas/DeviceOrderField"
|
||||
description: Device order field
|
||||
direction:
|
||||
$ref: "#/components/schemas/OrderDirection"
|
||||
description: Device order direction
|
||||
|
||||
DevicePostureValue:
|
||||
type: object
|
||||
required:
|
||||
- kind
|
||||
- text
|
||||
properties:
|
||||
kind:
|
||||
$ref: "#/components/schemas/DevicePostureValueKind"
|
||||
description: Machine-readable observation class (ON, OFF, TEXT, SECONDS, and so on). Interpret text and number based on kind; this is not the compliance verdict.
|
||||
text:
|
||||
type: string
|
||||
description: Literal posture value when kind is TEXT (for example an OS version or engine name). Often empty for non-TEXT kinds.
|
||||
number:
|
||||
type:
|
||||
- integer
|
||||
- "null"
|
||||
description: Numeric posture value when kind is SECONDS (delay) or MIN_PASSWORD_LENGTH (character count); null otherwise.
|
||||
|
||||
DevicePosture:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- device_id
|
||||
- check_key
|
||||
- status
|
||||
- value
|
||||
- observed_at
|
||||
properties:
|
||||
id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Device posture ID
|
||||
device_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Device ID
|
||||
check_key:
|
||||
type: string
|
||||
description: Posture check identifier (for example DISK_ENCRYPTION, SCREEN_LOCK, FIREWALL_ENABLED, TIME_SYNC, OS_VERSION, AUTO_UPDATE, PASSWORD_POLICY, REMOTE_LOGIN, MALWARE_PROTECTION).
|
||||
status:
|
||||
$ref: "#/components/schemas/DevicePostureStatus"
|
||||
description: Posture check verdict (PASS, FAIL, UNKNOWN, or NOT_APPLICABLE). NOT_APPLICABLE means the check does not apply on this host or platform.
|
||||
value:
|
||||
$ref: "#/components/schemas/DevicePostureValue"
|
||||
description: Observed posture value for this check_key; use value.kind to interpret value.text and value.number.
|
||||
observed_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Observation timestamp
|
||||
|
||||
Device:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- organization_id
|
||||
- state
|
||||
- latest_postures
|
||||
- created_at
|
||||
- updated_at
|
||||
properties:
|
||||
id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Device ID
|
||||
organization_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Organization ID
|
||||
state:
|
||||
$ref: "#/components/schemas/DeviceState"
|
||||
description: Device lifecycle state (PENDING, ACTIVE, or REVOKED).
|
||||
hostname:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: Device hostname
|
||||
serial_number:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: Device serial number
|
||||
hardware_uuid:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: Device hardware UUID
|
||||
platform:
|
||||
anyOf:
|
||||
- $ref: "#/components/schemas/DevicePlatform"
|
||||
- type: "null"
|
||||
description: Device platform
|
||||
os_version:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: Operating system version
|
||||
agent_version:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
description: Agent version
|
||||
owner_id:
|
||||
anyOf:
|
||||
- type: string
|
||||
$ref: "#/components/schemas/GID"
|
||||
- type: "null"
|
||||
description: MembershipProfile GID of the device owner, or null when unassigned.
|
||||
enrolled_at:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
format: date-time
|
||||
description: Enrollment timestamp
|
||||
last_seen_at:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
format: date-time
|
||||
description: Last agent heartbeat timestamp; use as the staleness signal. Null while the device is still PENDING.
|
||||
revoked_at:
|
||||
type:
|
||||
- string
|
||||
- "null"
|
||||
format: date-time
|
||||
description: Time of the first revoke. Set once and kept on subsequent revokeDevice calls.
|
||||
latest_postures:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/DevicePosture"
|
||||
description: Newest posture result per check_key when include_postures was true on listDevices or getDevice; otherwise empty. Also empty for PENDING devices that have never reported.
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Creation timestamp
|
||||
updated_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Update timestamp
|
||||
|
||||
ListDevicesInput:
|
||||
type: object
|
||||
required:
|
||||
- organization_id
|
||||
properties:
|
||||
organization_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Organization ID
|
||||
order_by:
|
||||
$ref: "#/components/schemas/DeviceOrderBy"
|
||||
description: Device order by
|
||||
size:
|
||||
type: integer
|
||||
description: Number of devices to return in this page.
|
||||
cursor:
|
||||
$ref: "#/components/schemas/CursorKey"
|
||||
description: Opaque cursor from a previous next_cursor; omit on the first page.
|
||||
include_postures:
|
||||
type: boolean
|
||||
description: When true, include each device's latest posture check results. Requires the itam:device-posture:list permission and runs one extra query per device.
|
||||
|
||||
ListDevicesOutput:
|
||||
type: object
|
||||
required:
|
||||
- devices
|
||||
properties:
|
||||
next_cursor:
|
||||
$ref: "#/components/schemas/CursorKey"
|
||||
description: Cursor for the next page; pass as cursor on the next listDevices call. Absent when there are no more results.
|
||||
devices:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Device"
|
||||
|
||||
GetDeviceInput:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
properties:
|
||||
id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Device ID
|
||||
include_postures:
|
||||
type: boolean
|
||||
description: When true, include the device's latest posture check results. Requires the itam:device-posture:list permission.
|
||||
|
||||
GetDeviceOutput:
|
||||
type: object
|
||||
required:
|
||||
- device
|
||||
properties:
|
||||
device:
|
||||
$ref: "#/components/schemas/Device"
|
||||
|
||||
RevokeDeviceInput:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
properties:
|
||||
id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Device ID
|
||||
|
||||
RevokeDeviceOutput:
|
||||
type: object
|
||||
required:
|
||||
- device
|
||||
properties:
|
||||
device:
|
||||
$ref: "#/components/schemas/Device"
|
||||
|
||||
DeleteDeviceInput:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
properties:
|
||||
id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Device ID
|
||||
|
||||
DeleteDeviceOutput:
|
||||
type: object
|
||||
required:
|
||||
- deleted_device_id
|
||||
properties:
|
||||
deleted_device_id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Deleted device ID
|
||||
|
||||
SetDeviceOwnerInput:
|
||||
type: object
|
||||
required:
|
||||
- id
|
||||
- owner_id
|
||||
properties:
|
||||
id:
|
||||
$ref: "#/components/schemas/GID"
|
||||
description: Device ID
|
||||
owner_id:
|
||||
anyOf:
|
||||
- type: string
|
||||
$ref: "#/components/schemas/GID"
|
||||
- type: "null"
|
||||
description: MembershipProfile GID belonging to the same organization as the device, or null to clear the owner. Required; omitting the field is invalid.
|
||||
|
||||
SetDeviceOwnerOutput:
|
||||
type: object
|
||||
required:
|
||||
- device
|
||||
properties:
|
||||
device:
|
||||
$ref: "#/components/schemas/Device"
|
||||
|
||||
DataClassification:
|
||||
type: string
|
||||
enum:
|
||||
@@ -13204,6 +13517,66 @@ tools:
|
||||
$ref: "#/components/schemas/DeleteAssetInput"
|
||||
outputSchema:
|
||||
$ref: "#/components/schemas/DeleteAssetOutput"
|
||||
- name: listDevices
|
||||
title: List Devices
|
||||
description: "List ITAM devices for an organization. Devices cannot be created through the MCP API: enrollment issues a one-shot token that the agent installer exchanges (there is no createDevice tool). Device states: PENDING (enrollment token issued, agent has never checked in), ACTIVE (agent heartbeating), REVOKED (enrollment revoked). Use last_seen_at as the staleness signal. latest_postures is empty unless include_postures is true; when loaded it holds the newest result per check_key and is empty for PENDING devices. Page with size and cursor; when next_cursor is present, pass it as cursor on the next call."
|
||||
hints:
|
||||
readonly: true
|
||||
destructive: false
|
||||
idempotent: true
|
||||
openWorld: false
|
||||
inputSchema:
|
||||
$ref: "#/components/schemas/ListDevicesInput"
|
||||
outputSchema:
|
||||
$ref: "#/components/schemas/ListDevicesOutput"
|
||||
- name: getDevice
|
||||
title: Get Device
|
||||
description: "Get one ITAM device by ID (soft-deleted devices are not returned). Same state machine as listDevices: PENDING (enrollment token issued, agent has never checked in), ACTIVE (agent heartbeating), REVOKED (enrollment revoked). Use last_seen_at as the staleness signal. latest_postures is empty unless include_postures is true; when loaded it holds the newest result per check_key and is empty for PENDING devices."
|
||||
hints:
|
||||
readonly: true
|
||||
destructive: false
|
||||
idempotent: true
|
||||
openWorld: false
|
||||
inputSchema:
|
||||
$ref: "#/components/schemas/GetDeviceInput"
|
||||
outputSchema:
|
||||
$ref: "#/components/schemas/GetDeviceOutput"
|
||||
- name: revokeDevice
|
||||
title: Revoke Device
|
||||
description: "Irreversibly revoke a device enrollment. Immediately invalidates the device agent API key so the agent stops authenticating and reporting; there is no un-revoke tool. Safe to call more than once: state stays REVOKED and revoked_at keeps its original value. Call this before deleteDevice."
|
||||
hints:
|
||||
readonly: false
|
||||
destructive: true
|
||||
idempotent: true
|
||||
openWorld: false
|
||||
inputSchema:
|
||||
$ref: "#/components/schemas/RevokeDeviceInput"
|
||||
outputSchema:
|
||||
$ref: "#/components/schemas/RevokeDeviceOutput"
|
||||
- name: deleteDevice
|
||||
title: Delete Device
|
||||
description: "Soft-delete a device. The device must already be REVOKED — call revokeDevice first, otherwise the call fails with the error device cannot be deleted. After success the device stops appearing in listDevices/getDevice; enrollment tokens for the device are removed. Eligible orphan rows are later hard-deleted by the ITAM garbage collector."
|
||||
hints:
|
||||
readonly: false
|
||||
destructive: true
|
||||
idempotent: true
|
||||
openWorld: false
|
||||
inputSchema:
|
||||
$ref: "#/components/schemas/DeleteDeviceInput"
|
||||
outputSchema:
|
||||
$ref: "#/components/schemas/DeleteDeviceOutput"
|
||||
- name: setDeviceOwner
|
||||
title: Set Device Owner
|
||||
description: "Set or clear the owner of an ITAM device. owner_id is required: pass a MembershipProfile GID belonging to the same organization as the device to assign, or null to clear. Omitting the field is invalid."
|
||||
hints:
|
||||
readonly: false
|
||||
destructive: false
|
||||
idempotent: true
|
||||
openWorld: false
|
||||
inputSchema:
|
||||
$ref: "#/components/schemas/SetDeviceOwnerInput"
|
||||
outputSchema:
|
||||
$ref: "#/components/schemas/SetDeviceOwnerOutput"
|
||||
- name: listData
|
||||
title: List Data
|
||||
description: List all data for the organization
|
||||
|
||||
100
pkg/server/api/mcp/v1/types/device.go
Normal file
100
pkg/server/api/mcp/v1/types/device.go
Normal file
@@ -0,0 +1,100 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/gid"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
func NewDevicePostureValue(v coredata.DevicePostureValue) *DevicePostureValue {
|
||||
return &DevicePostureValue{
|
||||
Kind: v.Kind,
|
||||
Text: v.Text,
|
||||
Number: v.Number,
|
||||
}
|
||||
}
|
||||
|
||||
func NewDevicePosture(p *coredata.DevicePosture) *DevicePosture {
|
||||
value := coredata.ParseDevicePostureValue(p.CheckKey, p.Evidence)
|
||||
|
||||
return &DevicePosture{
|
||||
ID: p.ID,
|
||||
DeviceID: p.DeviceID,
|
||||
CheckKey: p.CheckKey,
|
||||
Status: p.Status,
|
||||
Value: NewDevicePostureValue(value),
|
||||
ObservedAt: p.ObservedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func NewDevicePostures(ps coredata.DevicePostures) []*DevicePosture {
|
||||
out := make([]*DevicePosture, 0, len(ps))
|
||||
for _, p := range ps {
|
||||
out = append(out, NewDevicePosture(p))
|
||||
}
|
||||
|
||||
return out
|
||||
}
|
||||
|
||||
func NewDevice(d *coredata.Device, postures coredata.DevicePostures) *Device {
|
||||
return &Device{
|
||||
ID: d.ID,
|
||||
OrganizationID: d.OrganizationID,
|
||||
State: d.State,
|
||||
Hostname: d.Hostname,
|
||||
SerialNumber: d.SerialNumber,
|
||||
HardwareUUID: d.HardwareUUID,
|
||||
Platform: d.Platform,
|
||||
OsVersion: d.OSVersion,
|
||||
AgentVersion: d.AgentVersion,
|
||||
OwnerID: d.OwnerID,
|
||||
EnrolledAt: d.EnrolledAt,
|
||||
LastSeenAt: d.LastSeenAt,
|
||||
RevokedAt: d.RevokedAt,
|
||||
LatestPostures: NewDevicePostures(postures),
|
||||
CreatedAt: d.CreatedAt,
|
||||
UpdatedAt: d.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
func NewListDevicesOutput(
|
||||
devicePage *page.Page[*coredata.Device, coredata.DeviceOrderField],
|
||||
posturesByDeviceID map[gid.GID]coredata.DevicePostures,
|
||||
) ListDevicesOutput {
|
||||
devices := make([]*Device, 0, len(devicePage.Data))
|
||||
for _, d := range devicePage.Data {
|
||||
devices = append(devices, NewDevice(d, posturesByDeviceID[d.ID]))
|
||||
}
|
||||
|
||||
var nextCursor *page.CursorKey
|
||||
|
||||
if len(devicePage.Data) > 0 {
|
||||
cursorKey := devicePage.Data[len(devicePage.Data)-1].CursorKey(devicePage.Cursor.OrderBy.Field)
|
||||
nextCursor = &cursorKey
|
||||
}
|
||||
|
||||
return ListDevicesOutput{
|
||||
NextCursor: nextCursor,
|
||||
Devices: devices,
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import (
|
||||
"go.probo.inc/probo/pkg/cookiebanner"
|
||||
"go.probo.inc/probo/pkg/filemanager"
|
||||
"go.probo.inc/probo/pkg/iam"
|
||||
"go.probo.inc/probo/pkg/itam"
|
||||
"go.probo.inc/probo/pkg/probo"
|
||||
"go.probo.inc/probo/pkg/resourcealias"
|
||||
"go.probo.inc/probo/pkg/riskmanagement"
|
||||
@@ -54,6 +55,7 @@ func NewMux(
|
||||
accessReviewSvc *accessreview.Service,
|
||||
cookieBannerSvc *cookiebanner.Service,
|
||||
riskManagementSvc *riskmanagement.Service,
|
||||
itamSvc *itam.Service,
|
||||
tokenSecret string,
|
||||
fileManagerSvc *filemanager.Service,
|
||||
baseURL *baseurl.BaseURL,
|
||||
@@ -72,6 +74,7 @@ func NewMux(
|
||||
accessReview: accessReviewSvc,
|
||||
cookieBanner: cookieBannerSvc,
|
||||
riskManagement: riskManagementSvc,
|
||||
itamSvc: itamSvc,
|
||||
logger: logger,
|
||||
fileManager: fileManagerSvc,
|
||||
baseURL: baseURL,
|
||||
|
||||
Reference in New Issue
Block a user