Skip to content

Class: MessageContext

Communication context for AI system interactions including protocols, roles,

clients, and session information for MCP and other AI communication systems.

URI: ocsf:MessageContext

 classDiagram
    class MessageContext
    click MessageContext href "../MessageContext/"
      Entity <|-- MessageContext
        click Entity href "../Entity/"

      MessageContext : ai_role

      MessageContext : ai_role_id





        MessageContext --> "0..1 _recommended_" MessageContextAiRoleIdEnum : ai_role_id
        click MessageContextAiRoleIdEnum href "../MessageContextAiRoleIdEnum/"



      MessageContext : application





        MessageContext --> "0..1 _recommended_" ApplicationObject : application
        click ApplicationObject href "../ApplicationObject/"



      MessageContext : completion_tokens

      MessageContext : name

      MessageContext : prompt_tokens

      MessageContext : service





        MessageContext --> "0..1 _recommended_" Service : service
        click Service href "../Service/"



      MessageContext : total_tokens

      MessageContext : uid

Inheritance

Slots

Name Cardinality and Range Description Inheritance
ai_role 0..1
String
The normalized caption of the ai_role_id direct
ai_role_id 0..1 recommended
MessageContextAiRoleIdEnum
Specifies the functional role of the AI within the context of this message, direct
application 0..1 recommended
ApplicationObject
The initiating client application direct
completion_tokens 0..1
Integer
Number of tokens in the model's response/completion for this message direct
name 0..1 recommended
String
The name or identifier of the message context direct
prompt_tokens 0..1
Integer
Number of tokens in the input prompt for this message direct
service 0..1 recommended
Service
The server or service handling the request direct
total_tokens 0..1
Integer
Total number of tokens used for this message (prompt + completion) direct
uid 0..1 recommended
String
The unique identifier of the message context direct

Usages

used by used in type used
AiOperationProfile message_context range MessageContext
ApiActivity message_context range MessageContext
DatastoreActivity message_context range MessageContext
ProcessActivity message_context range MessageContext

Rules

Rule Applied Preconditions Postconditions Elseconditions
any_of [{'slot_conditions': {'application': {'required': True}}}, {'slot_conditions': {'service': {'required': True}}}]

In Subsets

Aliases

  • Message Context

See Also

Notes

Identifier and Mapping Information

Annotations

property value
ocsf_constraints {"at_least_one": ["application", "service"]}

Schema Source

Mappings

Mapping Type Mapped Value
self ocsf:MessageContext
native ocsf:MessageContext

LinkML Source

Direct

name: MessageContext
annotations:
  ocsf_constraints:
    tag: ocsf_constraints
    value: '{"at_least_one": ["application", "service"]}'
description: 'Communication context for AI system interactions including protocols,
  roles,

  clients, and session information for MCP and other AI communication systems.'
notes:
- 'OWASP AI Security and Privacy Guide - Agent Security 

  https://owasp.org/www-project-ai-security-and-privacy-guide/'
- Model Context Protocol (MCP) Specification — https://modelcontextprotocol.io/
in_subset:
- objects_subset
from_schema: https://w3id.org/lmodel/ocsf
see_also:
- https://owasp.org/www-project-ai-security-and-privacy-guide/
- https://modelcontextprotocol.io/
aliases:
- Message Context
is_a: Entity
slots:
- ai_role
- ai_role_id
- application
- completion_tokens
- name
- prompt_tokens
- service
- total_tokens
- uid
slot_usage:
  ai_role_id:
    name: ai_role_id
    description: 'Specifies the functional role of the AI within the context of this
      message,

      such as retrieving information, assisting reasoning, executing a tool, or

      generating content.'
    range: MessageContextAiRoleIdEnum
    recommended: true
  application:
    name: application
    description: 'The initiating client application. In AI systems, this represents
      the

      client-side application or framework that initiates requests (e.g., LangChain

      application, web browser, mobile app, SDK implementation).'
    recommended: true
  completion_tokens:
    name: completion_tokens
    description: Number of tokens in the model's response/completion for this message.
  name:
    name: name
    description: 'The name or identifier of the message context. In AI systems, this
      could be the

      conversation ID, session name, thread identifier, or interaction name (e.g.,

      ''user-session-123'', ''conversation-abc'', ''chat-thread-456'').'
  prompt_tokens:
    name: prompt_tokens
    description: Number of tokens in the input prompt for this message.
  service:
    name: service
    description: 'The server or service handling the request. In AI systems, this
      represents the

      AI service, API endpoint, or agent that processes and responds to requests

      (e.g., OpenAI API service, Claude API service, internal AI model service).'
    recommended: true
  total_tokens:
    name: total_tokens
    description: Total number of tokens used for this message (prompt + completion).
  uid:
    name: uid
    description: 'The unique identifier of the message context. This could be a session
      ID,

      conversation ID, or other unique identifier that allows correlation of messages

      within the same context.'
rules:
- postconditions:
    any_of:
    - slot_conditions:
        application:
          name: application
          required: true
    - slot_conditions:
        service:
          name: service
          required: true
  description: 'OCSF at_least_one: at least one of [''application'', ''service'']
    must be set.'

Induced

name: MessageContext
annotations:
  ocsf_constraints:
    tag: ocsf_constraints
    value: '{"at_least_one": ["application", "service"]}'
description: 'Communication context for AI system interactions including protocols,
  roles,

  clients, and session information for MCP and other AI communication systems.'
notes:
- 'OWASP AI Security and Privacy Guide - Agent Security 

  https://owasp.org/www-project-ai-security-and-privacy-guide/'
- Model Context Protocol (MCP) Specification — https://modelcontextprotocol.io/
in_subset:
- objects_subset
from_schema: https://w3id.org/lmodel/ocsf
see_also:
- https://owasp.org/www-project-ai-security-and-privacy-guide/
- https://modelcontextprotocol.io/
aliases:
- Message Context
is_a: Entity
slot_usage:
  ai_role_id:
    name: ai_role_id
    description: 'Specifies the functional role of the AI within the context of this
      message,

      such as retrieving information, assisting reasoning, executing a tool, or

      generating content.'
    range: MessageContextAiRoleIdEnum
    recommended: true
  application:
    name: application
    description: 'The initiating client application. In AI systems, this represents
      the

      client-side application or framework that initiates requests (e.g., LangChain

      application, web browser, mobile app, SDK implementation).'
    recommended: true
  completion_tokens:
    name: completion_tokens
    description: Number of tokens in the model's response/completion for this message.
  name:
    name: name
    description: 'The name or identifier of the message context. In AI systems, this
      could be the

      conversation ID, session name, thread identifier, or interaction name (e.g.,

      ''user-session-123'', ''conversation-abc'', ''chat-thread-456'').'
  prompt_tokens:
    name: prompt_tokens
    description: Number of tokens in the input prompt for this message.
  service:
    name: service
    description: 'The server or service handling the request. In AI systems, this
      represents the

      AI service, API endpoint, or agent that processes and responds to requests

      (e.g., OpenAI API service, Claude API service, internal AI model service).'
    recommended: true
  total_tokens:
    name: total_tokens
    description: Total number of tokens used for this message (prompt + completion).
  uid:
    name: uid
    description: 'The unique identifier of the message context. This could be a session
      ID,

      conversation ID, or other unique identifier that allows correlation of messages

      within the same context.'
attributes:
  ai_role:
    name: ai_role
    description: The normalized caption of the <code>ai_role_id</code>.
    from_schema: https://w3id.org/lmodel/ocsf
    aliases:
    - AI Role
    rank: 1000
    alias: ai_role
    owner: MessageContext
    domain_of:
    - MessageContext
    range: string
  ai_role_id:
    name: ai_role_id
    annotations:
      sibling:
        tag: sibling
        value: ai_role
    description: 'Specifies the functional role of the AI within the context of this
      message,

      such as retrieving information, assisting reasoning, executing a tool, or

      generating content.'
    from_schema: https://w3id.org/lmodel/ocsf
    aliases:
    - AI Role ID
    rank: 1000
    alias: ai_role_id
    owner: MessageContext
    domain_of:
    - MessageContext
    range: MessageContextAiRoleIdEnum
    recommended: true
  application:
    name: application
    description: 'The initiating client application. In AI systems, this represents
      the

      client-side application or framework that initiates requests (e.g., LangChain

      application, web browser, mobile app, SDK implementation).'
    from_schema: https://w3id.org/lmodel/ocsf
    aliases:
    - Application
    rank: 1000
    alias: application
    owner: MessageContext
    domain_of:
    - MessageContext
    - ApplicationSecurityPostureFinding
    range: ApplicationObject
    recommended: true
  completion_tokens:
    name: completion_tokens
    description: Number of tokens in the model's response/completion for this message.
    from_schema: https://w3id.org/lmodel/ocsf
    aliases:
    - Completion Tokens
    rank: 1000
    alias: completion_tokens
    owner: MessageContext
    domain_of:
    - MessageContext
    range: integer
  name:
    name: name
    description: 'The name or identifier of the message context. In AI systems, this
      could be the

      conversation ID, session name, thread identifier, or interaction name (e.g.,

      ''user-session-123'', ''conversation-abc'', ''chat-thread-456'').'
    from_schema: https://w3id.org/lmodel/ocsf
    aliases:
    - Name
    rank: 1000
    alias: name
    owner: MessageContext
    domain_of:
    - AnalysisTarget
    - Observable
    - Os
    - Osint
    - Package
    - Parameter
    - PrivilegeInfo
    - San
    - Scim
    - Script
    - ServicePrivilegeAnalysis
    - SoftwareComponent
    - Sso
    - StartupItem
    - ThreatActor
    - Token
    - Entity
    - Resource
    - Account
    - Agent
    - AiModel
    - Aircraft
    - Analytic
    - ApplicationObject
    - Assessment
    - AutonomousSystem
    - Campaign
    - Check
    - CisBenchmark
    - CisBenchmarkResult
    - CisControl
    - ClassifierDetails
    - Container
    - D3fTactic
    - D3fTechnique
    - Database
    - Databucket
    - DomainContact
    - Edge
    - Endpoint
    - Enrichment
    - EnvironmentVariable
    - Evidences
    - Extension
    - Feature
    - File
    - Graph
    - Group
    - HttpCookie
    - HttpHeader
    - Idp
    - Image
    - Job
    - Kernel
    - KeyValueObject
    - LoadBalancer
    - Logger
    - Malware
    - ManagedEntity
    - MessageContext
    - Metric
    - Mitigation
    - NetworkInterface
    - Node
    - Organization
    - PeripheralDevice
    - Policy
    - ProcessEntity
    - Product
    - QueryInfo
    - Reporter
    - ResourceDetails
    - Rule
    - Scan
    - Service
    - SubTechnique
    - Table
    - Tactic
    - Technique
    - Trait
    - TransformationInfo
    - UnmannedAerialSystem
    - User
    - WebResource
    - Device
    - FtpActivity
    - RegValue
    - WinResource
    - WinService
    - PrefetchQuery
    range: string
    recommended: true
  prompt_tokens:
    name: prompt_tokens
    description: Number of tokens in the input prompt for this message.
    from_schema: https://w3id.org/lmodel/ocsf
    aliases:
    - Prompt Tokens
    rank: 1000
    alias: prompt_tokens
    owner: MessageContext
    domain_of:
    - MessageContext
    range: integer
  service:
    name: service
    description: 'The server or service handling the request. In AI systems, this
      represents the

      AI service, API endpoint, or agent that processes and responds to requests

      (e.g., OpenAI API service, Claude API service, internal AI model service).'
    from_schema: https://w3id.org/lmodel/ocsf
    aliases:
    - Service
    rank: 1000
    alias: service
    owner: MessageContext
    domain_of:
    - QueryEvidence
    - Span
    - Trace
    - Api
    - MessageContext
    - ServiceQuery
    - Authentication
    range: Service
    recommended: true
  total_tokens:
    name: total_tokens
    description: Total number of tokens used for this message (prompt + completion).
    from_schema: https://w3id.org/lmodel/ocsf
    aliases:
    - Total Tokens
    rank: 1000
    alias: total_tokens
    owner: MessageContext
    domain_of:
    - MessageContext
    range: integer
  uid:
    name: uid
    description: 'The unique identifier of the message context. This could be a session
      ID,

      conversation ID, or other unique identifier that allows correlation of messages

      within the same context.'
    from_schema: https://w3id.org/lmodel/ocsf
    aliases:
    - Unique ID
    rank: 1000
    alias: uid
    owner: MessageContext
    domain_of:
    - Osint
    - Package
    - ProgrammaticCredential
    - RelatedEvent
    - Request
    - Sbom
    - Scim
    - Script
    - Session
    - Span
    - Sso
    - Ticket
    - Token
    - Trace
    - Entity
    - Resource
    - Account
    - Advisory
    - Agent
    - AiModel
    - Aircraft
    - Analytic
    - ApplicationObject
    - Assessment
    - Certificate
    - Check
    - ClassifierDetails
    - Container
    - Cve
    - Cwe
    - D3fTactic
    - D3fTechnique
    - DataClassification
    - Database
    - Databucket
    - DomainContact
    - Edge
    - Email
    - Endpoint
    - Evidences
    - Extension
    - Feature
    - File
    - FindingObject
    - FindingInfo
    - Graph
    - Group
    - HttpRequest
    - Idp
    - Image
    - KbArticle
    - LoadBalancer
    - Logger
    - Malware
    - ManagedEntity
    - MessageContext
    - Metadata
    - Mitigation
    - NetworkConnectionInfo
    - NetworkEndpoint
    - NetworkInterface
    - Node
    - Organization
    - PeripheralDevice
    - Policy
    - ProcessEntity
    - Product
    - QueryInfo
    - Reporter
    - Rule
    - Scan
    - Service
    - SubTechnique
    - Table
    - Tactic
    - Technique
    - Trait
    - TransformationInfo
    - UnmannedAerialSystem
    - User
    - WebResource
    - Device
    - WinResource
    range: string
    recommended: true
rules:
- postconditions:
    any_of:
    - slot_conditions:
        application:
          name: application
          required: true
    - slot_conditions:
        service:
          name: service
          required: true
  description: 'OCSF at_least_one: at least one of [''application'', ''service'']
    must be set.'