McpCaller Class

Assembly: CodeEffects.Rule.Mcp.dll
Namespace: CodeEffects.Rule.Mcp

Summary

Describes the verified caller of one MCP request: the accountable user, the AI agent acting for them, and the permissions they have.

Syntax

public sealed class McpCaller

Remarks

Your MapCaller delegate of CodeEffectsMcpOptions creates one for every request, from the identity that your application's authentication verified. Build it from the signed-in person's claims and from the client the token was issued to. Never build it from what an MCP client reports about itself: no tool takes a login, password or token, and the server trusts nothing but your delegate.

The class has a public parameterless constructor. Only UserId is required.

The permissions follow the model of the Rule Repository: AccessMode says how Actions is read. With the default, ActionPermissionMode.ViewOnly, the caller has no permission at all beyond viewing the four core objects: source objects, source versions, rules and rule versions. With ActionPermissionMode.AllowAllExcept the caller may do everything except what Actions lists, and a withheld permission withholds every permission that requires it. With ActionPermissionMode.AllowOnly the caller may do only what Actions lists, and the list must be complete: a permission granted without the ones it requires is a configuration error, and the request fails with a message that says what is missing. The tools a client is offered follow this set, and the server checks it again when a tool is called.

Some actions, such as making a version live, approving and deleting, are a person's only. A caller that has an AgentId is never granted them, whatever the set says.

Properties

  • UserId

    Type: System.String

    Gets or sets the ID of the accountable user, as your application knows them. Required, and at most 256 characters. The default is an empty string, and a request whose caller has an empty UserId is refused.

  • UserName

    Type: System.String

    Gets or sets the display name of the user. Optional. The default is null. A name longer than 256 characters is truncated.

  • UserType

    Type: CodeEffects.Rule.Mcp.McpUserType

    Gets or sets who the caller is: a person, an AI agent on its own, or a service. The default is McpUserType.User.

  • AgentId

    Type: System.String

    Gets or sets the ID of the AI agent that acts for a person: the client your token was issued to, never the name the MCP client reports. Use it only with McpUserType.User; leave it null when the person acts directly, which is the default. The Rule Repository refuses a request whose agent has the same ID as the user, and one whose user is an Agent or a Service and has an AgentId.

  • AgentName

    Type: System.String

    Gets or sets the display name of the agent. Set it only together with AgentId; the Rule Repository refuses an agent name without an agent ID. The default is null.

  • AccessMode

    Type: CodeEffects.Rule.Common.Models.ActionPermissionMode

    Gets or sets how Actions is read. The default is ActionPermissionMode.ViewOnly: no permission beyond viewing. The values are ViewOnly, AllowAllExcept and AllowOnly.

  • Actions

    Type: System.Collections.Generic.ISet<CodeEffects.Rule.Common.Models.ActionPermissionType>

    Gets or sets the permissions the mode refers to: the exceptions under AllowAllExcept, or the grants under AllowOnly. The default is an empty HashSet, which ViewOnly ignores.

Example

using System.Collections.Generic;
using CodeEffects.Rule.Common.Models;
using CodeEffects.Rule.Mcp;

// Dana, signed in to an AI client: she may do everything except delete rules
var caller = new McpCaller
{
	UserId = "u-1001",
	UserName = "Dana Whitaker",
	UserType = McpUserType.User,
	AgentId = "claude-connector",
	AgentName = "Claude",
	AccessMode = ActionPermissionMode.AllowAllExcept,
	Actions = new HashSet<ActionPermissionType> { ActionPermissionType.RuleDelete }
};

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×