Package io.meeds.mcp.server.model
Record Class ActingIdentity
java.lang.Object
java.lang.Record
io.meeds.mcp.server.model.ActingIdentity
- Record Components:
actor- the account that executes the callonBehalfOf- the person the work is for, null when an agent acts as itselfchain- the agent name ids from the entry point to the agent making the call, never null, possibly emptyorigin- what triggered the callgrantScope- what the standing-approval lookup matches against: an agent name id, or a source scope holding ":"; null for none
public record ActingIdentity(PrincipalRef actor, String onBehalfOf, List<String> chain, Origin origin, String grantScope)
extends Record
Who executes a tool call, for whom, through which agents, and on which
trigger. Immutable, and built only by platform code: a value an external
client, a model or a tool argument sends never becomes one.
The account whose permissions apply to the call is the subject():
the person the work is for, or the agent account itself when an agent acts
as itself. A call never combines two accounts' permissions. An agent account
acting for a person is a combination no entry point produces yet, so it is
refused at construction.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionActingIdentity(PrincipalRef actor, String onBehalfOf, List<String> chain, Origin origin, String grantScope) Checks the identity is complete and holds a combination some entry point produces, and freezes its chain. -
Method Summary
Modifier and TypeMethodDescriptionactor()Returns the value of theactorrecord component.static ActingIdentitychain()Returns the value of thechainrecord component.final booleanIndicates whether some other object is "equal to" this one.static ActingIdentityReturns the value of thegrantScoperecord component.final inthashCode()Returns a hash code value for this object.booleanReturns the value of theonBehalfOfrecord component.origin()Returns the value of theoriginrecord component.static ActingIdentitysubject()final StringtoString()Returns a string representation of this record class.withGrantScope(String scope) Sets the standing-approval scope, and derives the origin from it whatever the origin was: a scope starting with "schedule:" is a scheduled run, any other scope holding ":" another unattended source, and a bare agent name id leaves the origin as it is.The only derivation of the chain: an agent appended at its end.
-
Field Details
-
SOURCE_SCOPE_SEPARATOR
What a source scope holds, and an agent name id never does.- See Also:
-
SCHEDULE_SCOPE_PREFIX
The prefix of the grant scope of a scheduled agent run.- See Also:
-
AGENT_USER_SCOPE_PREFIX
The prefix of the grant scope of an agent account acting as itself.- See Also:
-
-
Constructor Details
-
ActingIdentity
public ActingIdentity(PrincipalRef actor, String onBehalfOf, List<String> chain, Origin origin, String grantScope) Checks the identity is complete and holds a combination some entry point produces, and freezes its chain.- Parameters:
actor- the account that executes the callonBehalfOf- the person the work is for, or nullchain- the agents from the entry point to the calling oneorigin- what triggered the callgrantScope- the standing-approval scope, or null- Throws:
IllegalArgumentException- when a part is missing, a chain element is not an agent name id, a person acts for someone else, or an agent account acts for a person
-
-
Method Details
-
person
- Parameters:
username- the personorigin- what triggered the call- Returns:
- the person acting for themself, with no agent in the chain and no grant scope
-
agent
- Parameters:
username- the agent account's loginagentNameId- the agent it is the account oforigin- what triggered the call- Returns:
- the agent account acting as itself, the agent alone in the chain, its grants matched by the scope "agent-user:" followed by its name id
-
external
- Parameters:
username- the user the external client's token names- Returns:
- that user acting for themself through an external MCP client
-
withHop
The only derivation of the chain: an agent appended at its end. The actor, the person the work is for and the origin are kept.- Parameters:
agentNameId- the agent that now makes the calls- Returns:
- the identity with the agent appended, whose grant scope is that agent unless this identity carries a source scope, which is kept
- Throws:
IllegalArgumentException- when the name id is blank or holds ":"
-
withGrantScope
Sets the standing-approval scope, and derives the origin from it whatever the origin was: a scope starting with "schedule:" is a scheduled run, any other scope holding ":" another unattended source, and a bare agent name id leaves the origin as it is.- Parameters:
scope- the grant scope, null for none- Returns:
- the identity with that scope and the origin it implies
-
subject
- Returns:
- the account whose permissions apply to the call: the person the work is for, else the actor itself
-
callingAgent
- Returns:
- the agent making the call, the last of the chain, or null when no agent calls
-
isSourceScope
public boolean isSourceScope()- Returns:
- true when the grant scope names a source rather than an agent
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
actor
Returns the value of theactorrecord component.- Returns:
- the value of the
actorrecord component
-
onBehalfOf
Returns the value of theonBehalfOfrecord component.- Returns:
- the value of the
onBehalfOfrecord component
-
chain
Returns the value of thechainrecord component.- Returns:
- the value of the
chainrecord component
-
origin
Returns the value of theoriginrecord component.- Returns:
- the value of the
originrecord component
-
grantScope
Returns the value of thegrantScoperecord component.- Returns:
- the value of the
grantScoperecord component
-