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 nonespaceScope- the id of the only space the call may reach, null when the call isn't limited to a space
public record ActingIdentity(PrincipalRef actor, String onBehalfOf, List<String> chain, Origin origin, String grantScope, Long spaceScope)
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.
A call may be limited to the content of one space, its spaceScope():
an answer an agent posts in a space must not carry what only the person it
reads for can see elsewhere. The limit is kept by every derivation of the
identity, and the origins that post their answer in a space
(READ_SCOPED_ORIGINS) can't be built without it.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe prefix of the grant scope of an agent account acting as itself, followed by the account's login.static final StringWhat follows an agent account's grant scope, then a space id, when its grants are the ones given to it in that space.The origins whose answer is posted in a space, read by every member of it: an identity of one of them is always limited to that space, and only reads there:Origin.PROPOSAL, an approved proposal, is the only origin a write runs under while limited to a space.static final StringThe prefix of the grant scope of a scheduled agent run.static final StringWhat a source scope holds, and an agent name id never does. -
Constructor Summary
ConstructorsConstructorDescriptionActingIdentity(PrincipalRef actor, String onBehalfOf, List<String> chain, Origin origin, String grantScope) Deprecated, for removal: This API element is subject to removal in a future version.ActingIdentity(PrincipalRef actor, String onBehalfOf, List<String> chain, Origin origin, String grantScope, Long spaceScope) 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 ActingIdentitystatic 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 ActingIdentitystatic ActingIdentityReturns the value of thespaceScoperecord component.subject()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
-
READ_SCOPED_ORIGINS
The origins whose answer is posted in a space, read by every member of it: an identity of one of them is always limited to that space, and only reads there:Origin.PROPOSAL, an approved proposal, is the only origin a write runs under while limited to a space. -
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, followed by the account's login.- See Also:
-
AGENT_USER_SPACE_SEPARATOR
What follows an agent account's grant scope, then a space id, when its grants are the ones given to it in that space.- See Also:
-
-
Constructor Details
-
ActingIdentity
public ActingIdentity(PrincipalRef actor, String onBehalfOf, List<String> chain, Origin origin, String grantScope, Long spaceScope) 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 nullspaceScope- the only space the call may reach, or null- Throws:
IllegalArgumentException- when a part is missing, a chain element is not an agent name id, a person acts for someone else, an agent account acts for a person, the space scope isn't a space id, or an origin ofREAD_SCOPED_ORIGINScomes without a space scope
-
ActingIdentity
@Deprecated(since="7.3.0", forRemoval=true) public ActingIdentity(PrincipalRef actor, String onBehalfOf, List<String> chain, Origin origin, String grantScope) Deprecated, for removal: This API element is subject to removal in a future version.use the canonical constructor, which states the space scope, orwithHop(String)/withGrantScope(String)to derive an identity: a copy built with this one silently drops a space scope. Since 7.3.0, kept for the add-ons built against the previous signature, for removal once none calls it.Builds an identity limited to no space, whatever the identity it is derived from was limited to.- 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- as the canonical constructor does, an origin ofREAD_SCOPED_ORIGINSincluded, since it needs a space scope
-
-
Method Details
-
person
- Parameters:
username- the personorigin- what triggered the call, not one ofREAD_SCOPED_ORIGINS- Returns:
- the person acting for themself, with no agent in the chain, no grant scope and no space scope
-
person
- Parameters:
username- the personorigin- what triggered the callspaceScope- the only space the call may reach, or null- Returns:
- the person acting for themself, with no agent in the chain and no grant scope, limited to that space
-
agent
- Parameters:
username- the agent account's loginagentNameId- the agent it is the account oforigin- what triggered the call, not one ofREAD_SCOPED_ORIGINS- Returns:
- the agent account acting as itself, the agent alone in the chain, its grants matched by the scope "agent-user:" followed by its login, with no space scope
-
agent
public static ActingIdentity agent(String username, String agentNameId, Origin origin, Long spaceScope) - Parameters:
username- the agent account's loginagentNameId- the agent it is the account oforigin- what triggered the callspaceScope- the only space the call may reach, or null- Returns:
- the agent account acting as itself, the agent alone in the chain, its grants matched by the scope "agent-user:" followed by its login, limited to that space
-
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, the origin and the space scope are kept, so an agent called by a limited one is limited the same way.- 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. The space scope is kept.- 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
-
hashCode
-
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
-
onBehalfOf
Returns the value of theonBehalfOfrecord component.- Returns:
- the value of the
onBehalfOfrecord component
-
chain
-
origin
-
grantScope
Returns the value of thegrantScoperecord component.- Returns:
- the value of the
grantScoperecord component
-
spaceScope
Returns the value of thespaceScoperecord component.- Returns:
- the value of the
spaceScoperecord component
-
withHop(String)/withGrantScope(String)to derive an identity: a copy built with this one silently drops a space scope.