Entropic 2.11.1
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

@dg_internal

Version
1.9.4

Definition at line 106 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. @dg_internal
Version
1.9.4

Definition at line 136 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. @dg_internal
Version
1.9.4

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.

Levels are ordinal, so a key granting WRITE also satisfies a READ requirement but not the reverse — which is what makes ToolBase's WRITE default a genuine restriction on a READ-only key set.

Parameters
tool_nameFully-qualified tool name.
requiredMinimum access level needed, as declared by the tool.
Returns
true when the best-matching granted key's level is at least required; false otherwise, including when no key matches (which resolves to NONE). @req REQ-MCP-010 @req REQ-MCP-011
Version
1.9.4

Definition at line 66 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. @dg_internal
Version
1.9.4

Definition at line 80 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. @dg_internal
Version
1.9.4

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. @dg_internal
Version
1.9.4

Definition at line 117 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. @dg_internal
Version
1.9.4

Definition at line 96 of file mcp_key_set.cpp.


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