include/entropic/mcp/mcp_authorization.h

← API

include/entropic/mcp/mcp_authorization.h

entropic::MCPAuthorizationManager

Per-identity MCP authorization with runtime grant/revoke.

void entropic::MCPAuthorizationManager::register_identity(const std::string &identity_name)

Register an empty key set for an identity.

After registration, the identity has ZERO authorized tools.

Parameters
  • identity_name — Identity/tier name.

bool entropic::MCPAuthorizationManager::is_enforced(const std::string &identity_name) const

Check if an identity has authorization enforcement enabled.

Check if an identity has enforcement enabled. Enforcement is opt-in per identity: registering a key set is what turns it on, which allows incremental adoption.

Parameters
  • identity_name — Identity/tier name.
Returns
  • true if the identity has a registered MCPKeySet.
  • true when a key set is registered for the identity; false when none is, in which case every authorization check passes.

entropic_error_t entropic::MCPAuthorizationManager::grant(const std::string &identity_name, const std::string &pattern, MCPAccessLevel level)

Grant a tool key to an identity.

Parameters
  • identity_name — Target identity.
  • pattern — Tool pattern string.
  • level — Access level to grant.
  • pattern — Tool pattern.
  • level — Access level.
Returns
  • ENTROPIC_OK on success. ENTROPIC_ERROR_IDENTITY_NOT_FOUND if identity not registered.
  • ENTROPIC_OK or ENTROPIC_ERROR_IDENTITY_NOT_FOUND.

entropic_error_t entropic::MCPAuthorizationManager::revoke(const std::string &identity_name, const std::string &pattern)

Revoke a tool key from an identity.

Parameters
  • identity_name — Target identity.
  • pattern — Tool pattern string.
  • pattern — Tool pattern.
Returns
  • ENTROPIC_OK on success. ENTROPIC_ERROR_IDENTITY_NOT_FOUND if identity not registered.
  • ENTROPIC_OK or ENTROPIC_ERROR_IDENTITY_NOT_FOUND.

bool entropic::MCPAuthorizationManager::check_access(const std::string &identity_name, const std::string &tool_name, MCPAccessLevel required_level) const

Check if a tool call is authorized for an identity.

Opt-in but default-deny once enabled: an unregistered identity passes everything, a registered one passes only what its key set grants at the tool's own declared level.

Parameters
  • identity_name — Caller identity.
  • tool_name — Fully-qualified tool name.
  • required_level — Minimum access level needed.
  • required_level — Minimum access level, from the tool's required_access_level().
Returns
  • true if authorized (or if identity has no key set).
  • true when the identity has no registered key set, or its key set grants at least required_level for the tool; false otherwise. Both outcomes are logged.

entropic_error_t entropic::MCPAuthorizationManager::grant_from(const std::string &granter_name, const std::string &grantee_name, const std::string &pattern, MCPAccessLevel level)

One identity grants a key to another identity.

One identity grants a key to another.

Parameters
  • granter_name — Identity performing the grant.
  • grantee_name — Identity receiving the key.
  • pattern — Tool pattern to grant.
  • level — Access level to grant.
  • granter_name — Granting identity.
  • grantee_name — Receiving identity.
  • pattern — Tool pattern.
  • level — Access level.
Returns
  • ENTROPIC_OK on success. ENTROPIC_ERROR_IDENTITY_NOT_FOUND if either not registered. ENTROPIC_ERROR_PERMISSION_DENIED if granter lacks the key.
  • ENTROPIC_OK, NOT_FOUND, or PERMISSION_DENIED.

std::vector< MCPKey > entropic::MCPAuthorizationManager::list_keys(const std::string &identity_name) const

List all keys for an identity.

Parameters
  • identity_name — Identity to query.
Returns
  • Vector of MCPKey entries, or empty if not registered.
  • Vector of MCPKey entries.

std::string entropic::MCPAuthorizationManager::serialize_all() const

Serialize all identity key sets to JSON.

Returns
  • JSON object: {"identity_name": [key_array], ...}
  • JSON object string.

bool entropic::MCPAuthorizationManager::deserialize_all(const std::string &json)

Deserialize all identity key sets from JSON.

Parameters
  • json — JSON object string.
Returns
true if parsed successfully.

void entropic::MCPAuthorizationManager::unregister_identity(const std::string &identity_name)

Remove an identity's key set (disables enforcement).

Remove an identity's key set.

Parameters
  • identity_name — Identity to unregister.