systemprompt-identifiers 0.2.2

Typed newtype identifiers (UserId, TraceId, AgentId, McpServerId…) for systemprompt.io AI governance infrastructure. Enforces type-safe IDs across every boundary in the MCP governance pipeline.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
crate::define_id!(AiToolCallId, schema);
crate::define_id!(McpExecutionId, generate, schema);
crate::define_id!(McpServerId, non_empty);

impl McpServerId {
    pub fn from_env() -> Result<Self, crate::error::IdValidationError> {
        let id = std::env::var("MCP_SERVICE_ID").map_err(|_| {
            crate::error::IdValidationError::invalid(
                "McpServerId",
                "MCP_SERVICE_ID environment variable not set",
            )
        })?;
        Self::try_new(id)
    }
}