Class McpToolSpaceScopeService
ActingIdentity.spaceScope()) within that space, from the tool's
space_scope declaration (SpaceScopeDeclaration). A call that
isn't limited is never looked at.
A limited call is refused when the tool declares no space scope or a
malformed one, when it is a write (its readOnlyHint isn't true) and
the call isn't an approved proposal (Origin.PROPOSAL), or when its
arguments aren't a JSON object with distinct keys, all of them accepted,
its false-only arguments false or absent, and its space or object in the
call's space. An absent space argument of a read is filled with the call's
space when the tool says so; a write's is refused. Each refusal names the
call's space, so the model can call again within it.
A run answering in a space (ActingIdentity.READ_SCOPED_ORIGINS)
never writes under its space scope. Limiting an approved proposal to the
space it was made in is its caller's job: the identity it sends must carry
that space scope, or the proposal runs unlimited. The check runs before
any approval, so a write it lets through still goes through the "always
ask" setting, the standing approvals and the approval card: the approval
says "do it", the space scope "only here".
-
Constructor Summary
ConstructorsConstructorDescriptionMcpToolSpaceScopeService(org.springframework.beans.factory.ObjectProvider<SpaceScopeResolver> spaceScopeResolvers) -
Method Summary
Modifier and TypeMethodDescriptionenforce(String toolName, SimpleToolDefinition toolDefinition, String toolInput, ActingIdentity actingIdentity) Checks a call against the space scope of its acting identity.static booleanisReadTool(SimpleToolDefinition toolDefinition) The rule that tells a read from a write for a call limited to one space, shared with the views that show it.booleanmayEdit(SimpleToolDefinition toolDefinition, String toolInput, String userName) Tells whether a person could edit, in person, the object a write reaches, for a write whosespace_scopedeclaresspace_role: editor: the caller that runs a digital worker's write for a person asks it before letting the write run for them.
-
Constructor Details
-
McpToolSpaceScopeService
public McpToolSpaceScopeService(org.springframework.beans.factory.ObjectProvider<SpaceScopeResolver> spaceScopeResolvers) - Parameters:
spaceScopeResolvers- the contributed resolvers, looked up at each call
-
-
Method Details
-
enforce
public String enforce(String toolName, SimpleToolDefinition toolDefinition, String toolInput, ActingIdentity actingIdentity) Checks a call against the space scope of its acting identity.- Parameters:
toolName- the MCP tool nametoolDefinition- the tool's definition, may be nulltoolInput- the call's arguments as the model sent themactingIdentity- the call's acting identity, may be null- Returns:
- the arguments to run the tool with: the same string, untouched, when the call isn't limited or needs nothing filled, else the arguments with the call's space filled in
- Throws:
SpaceScopeRefusedException- when the limited call reaches, or may reach, outside its space, or is a write that isn't an approved proposal
-
mayEdit
Tells whether a person could edit, in person, the object a write reaches, for a write whosespace_scopedeclaresspace_role: editor: the caller that runs a digital worker's write for a person asks it before letting the write run for them. It reads the object's id from the arguments asenforce(String, SimpleToolDefinition, String, ActingIdentity)does and asks the declaration's resolver (SpaceScopeResolver.canEdit(String, String)).The answer has two values: a case where nobody can tell (no single resolver, arguments that can't be read, a resolver that doesn't tell or fails) is a no, like a refusal, so the write never runs for a person on a right nobody checked. The caller records the write as a proposal for the space's managers to decide, who can approve it only once the cause of the no is gone, since the approving manager is asked again.
- Parameters:
toolDefinition- the tool's definition, may be nulltoolInput- the write's argumentsuserName- the person the write would be made for- Returns:
- true only when the resolver says the person could edit the object; false for a definition that isn't an object declaration, arguments that can't be read, no id, no single resolver, a resolver that doesn't tell or fails
-
isReadTool
The rule that tells a read from a write for a call limited to one space, shared with the views that show it.- Parameters:
toolDefinition- the tool's definition, may be null- Returns:
- true when the definition says the tool only reads; a tool carrying no hint, or no definition, is a write
-