Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic::MCPKeySet Class Reference

Per-identity set of authorized MCP tool keys. More...

#include <entropic/mcp/mcp_key_set.h>

Public Member Functions

void grant (const std::string &pattern, MCPAccessLevel level)
 Grant a tool key with an access level.
 
bool revoke (const std::string &pattern)
 Revoke a tool key entirely.
 
bool has_access (const std::string &tool_name, MCPAccessLevel required) const
 Check if a specific tool is authorized at the required level.
 
std::vector< MCPKeylist () const
 List all granted keys.
 
size_t size () const
 Number of granted keys.
 
void clear ()
 Remove all granted keys.
 
std::string serialize () const
 Serialize key set to JSON string.
 
bool deserialize (const std::string &json)
 Deserialize key set from JSON string.
 

Detailed Description

Per-identity set of authorized MCP tool keys.

Manages a map of tool patterns to access levels. Pattern matching uses three-tier resolution (exact → server wildcard → full wildcard) with O(1) lookup per tier.

Version
1.9.4

Definition at line 44 of file mcp_key_set.h.

Member Function Documentation

◆ clear()

void entropic::MCPKeySet::clear ( )

Remove all granted keys.

Version
1.9.4

Definition at line 98 of file mcp_key_set.cpp.

◆ deserialize()

bool entropic::MCPKeySet::deserialize ( const std::string &  json)

Deserialize key set from JSON string.

Parameters
jsonJSON array string (same format as serialize output).
Returns
true if parsed successfully.
Version
1.9.4

Replaces all current keys with the deserialized set. Invalid entries are logged as WARNING and skipped.

Parameters
jsonJSON array string.
Returns
true if parsed successfully.

Definition at line 128 of file mcp_key_set.cpp.

◆ grant()

void entropic::MCPKeySet::grant ( const std::string &  pattern,
MCPAccessLevel  level 
)

Grant a tool key with an access level.

Parameters
patternTool pattern string.
levelAccess level to grant.
Version
1.9.4

If the pattern already exists, the level is updated (not additive). Granting READ to a pattern that had WRITE downgrades it.

Parameters
patternTool pattern string.
levelAccess level to grant.

Definition at line 24 of file mcp_key_set.cpp.

◆ has_access()

bool entropic::MCPKeySet::has_access ( const std::string &  tool_name,
MCPAccessLevel  required 
) const

Check if a specific tool is authorized at the required level.

Parameters
tool_nameFully-qualified tool name (e.g., "filesystem.read_file").
requiredMinimum access level needed.
Returns
true if authorized.
Version
1.9.4

Resolution order (most specific wins):

  1. Exact match on tool_name
  2. Server wildcard (e.g., "filesystem.*" matches "filesystem.read_file")
  3. Full wildcard ("*")
  4. No match → denied

Access level comparison: granted >= required means authorized.

Parameters
tool_nameFully-qualified tool name.
requiredMinimum access level needed.
Returns
true if authorized.

Definition at line 58 of file mcp_key_set.cpp.

◆ list()

std::vector< MCPKey > entropic::MCPKeySet::list ( ) const

List all granted keys.

Returns
Vector of MCPKey entries.
Version
1.9.4
Returns
Vector of MCPKey entries.

Definition at line 72 of file mcp_key_set.cpp.

◆ revoke()

bool entropic::MCPKeySet::revoke ( const std::string &  pattern)

Revoke a tool key entirely.

Parameters
patternTool pattern string to revoke.
Returns
true if pattern was found and removed.
Version
1.9.4
Parameters
patternTool pattern string to revoke.
Returns
true if pattern was found and removed.

Definition at line 39 of file mcp_key_set.cpp.

◆ serialize()

std::string entropic::MCPKeySet::serialize ( ) const

Serialize key set to JSON string.

Returns
JSON array: [{"pattern":"...", "level":"WRITE"}, ...]
Version
1.9.4
Returns
JSON array of {pattern, level} objects.

Definition at line 109 of file mcp_key_set.cpp.

◆ size()

size_t entropic::MCPKeySet::size ( ) const

Number of granted keys.

Returns
Key count.
Version
1.9.4
Returns
Key count.

Definition at line 88 of file mcp_key_set.cpp.


The documentation for this class was generated from the following files: