Skip to content

nimwire/security

This page is generated from the module’s exported API and ## documentation comments.

Small, opt-in security controls shared by transports and handlers.

Zero means unlimited for that limit.

McpSecurityLimits = object
maxLineBytes*: int
maxToolCount*: int
maxContentBytes*: int
maxConcurrentCalls*: int

View source

proc validateSecurityLimits(limits: McpSecurityLimits) {.raises: [McpError],
tags: [], forbids: [].}
Name Type Default
limits McpSecurityLimits

View source

proc newMcpSecurityLimits(maxLineBytes = 0; maxToolCount = 0;
maxContentBytes = 0; maxConcurrentCalls = 0): McpSecurityLimits {.
raises: [Exception], tags: [RootEffect], forbids: [].}

Returns: McpSecurityLimits.

Name Type Default
maxLineBytes inferred 0
maxToolCount inferred 0
maxContentBytes inferred 0
maxConcurrentCalls inferred 0

View source

proc validateJsonSize(value: JsonNode; maxBytes: int; label = "JSON value") {.
raises: [McpError], tags: [], forbids: [].}
Name Type Default
value JsonNode
maxBytes int
label inferred "JSON value"

View source

proc redactJson(value: JsonNode; sensitiveKeys: seq[string] = @[]): JsonNode {.
raises: [], tags: [], forbids: [].}

Returns: JsonNode.

Name Type Default
value JsonNode
sensitiveKeys seq[string] @[]

View source

proc redactHeaderValue(name, value: string): string {.raises: [], tags: [],
forbids: [].}

Returns: string.

Name Type Default
name string
value string

View source

proc redactBearerToken(value: string): string {.raises: [], tags: [],
forbids: [].}

Returns: string.

Name Type Default
value string

View source

proc isSafeMcpUrl(value: string; allowHttp = false): bool {.raises: [],
tags: [], forbids: [].}

Returns: bool.

Name Type Default
value string
allowHttp inferred false

View source

proc requireSafeMcpUrl(value: string; allowHttp = false): string {.
raises: [McpError], tags: [], forbids: [].}

Returns: string.

Name Type Default
value string
allowHttp inferred false

View source