nimwire/schema
This page is generated from the module’s exported API and ## documentation comments.
Lightweight JSON Schema validation for tool boundaries.
McpHeaderBinding
Section titled “McpHeaderBinding”A tool argument path mirrored into Mcp-Param-{name}.
McpHeaderBinding = object name*: string path*: seq[string] valueType*: stringProcedures
Section titled “Procedures”validateJsonSchema
Section titled “validateJsonSchema”proc validateJsonSchema(schema: JsonNode; context = "JSON Schema") {. raises: [McpError, KeyError, Exception], tags: [RootEffect], forbids: [].}Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
schema |
JsonNode |
|
context |
inferred |
"JSON Schema" |
requireJsonSchema
Section titled “requireJsonSchema”proc requireJsonSchema(schema: JsonNode; context = "JSON Schema"): JsonNode {. raises: [McpError, Exception], tags: [RootEffect], forbids: [].}Returns: JsonNode.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
schema |
JsonNode |
|
context |
inferred |
"JSON Schema" |
mcpHeaderBindings
Section titled “mcpHeaderBindings”Return the valid statically reachable x-mcp-header annotations.
proc mcpHeaderBindings(schema: JsonNode): seq[McpHeaderBinding] {. raises: [Exception, KeyError, McpError], tags: [RootEffect], forbids: [].}Returns: seq[McpHeaderBinding].
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
schema |
JsonNode |
mcpLiteralJson
Section titled “mcpLiteralJson”Evaluate the literal subset used by %* without executing user code.
A nil result means that the expression is dynamic and will be checked at
registration time instead.
proc mcpLiteralJson(node: NimNode): JsonNode {.raises: [], tags: [], forbids: [].}Returns: JsonNode.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
node |
NimNode |
validateMcpSchemaLiteral
Section titled “validateMcpSchemaLiteral”proc validateMcpSchemaLiteral(node: NimNode; context: string) {. raises: [Exception], tags: [RootEffect], forbids: [].}Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
node |
NimNode |
|
context |
string |
validateToolName
Section titled “validateToolName”proc validateToolName(name: string) {.raises: [McpError], tags: [], forbids: [].}Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
name |
string |
validateToolPresentation
Section titled “validateToolPresentation”proc validateToolPresentation(icons, annotations: JsonNode) {. raises: [McpError, KeyError], tags: [], forbids: [].}Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
icons |
JsonNode |
|
annotations |
JsonNode |
mcpSchemaFromType
Section titled “mcpSchemaFromType”proc mcpSchemaFromType(n: NimNode): JsonNode {.raises: [KeyError, Exception], tags: [RootEffect], forbids: [].}Returns: JsonNode.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
n |
NimNode |
mcpJsonArgument
Section titled “mcpJsonArgument”proc mcpJsonArgument(arguments: JsonNode; name: string): JsonNode {. raises: [KeyError], tags: [], forbids: [].}Returns: JsonNode.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
arguments |
JsonNode |
|
name |
string |
mcpJsonDecode
Section titled “mcpJsonDecode”Decode typed tool arguments while allowing absent Option properties.
proc mcpJsonDecode[T](value: JsonNode): TType parameters: T.
Returns: T.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
value |
JsonNode |
mcpJsonEncode
Section titled “mcpJsonEncode”Encode typed results with stable, model-facing enum names.
proc mcpJsonEncode[T](value: T): JsonNodeType parameters: T.
Returns: JsonNode.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
value |
T |
validateJsonValue
Section titled “validateJsonValue”proc validateJsonValue(schema, value: JsonNode; context = "value") {. raises: [McpError, Exception, KeyError], tags: [RootEffect], forbids: [].}Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
schema |
JsonNode |
|
value |
JsonNode |
|
context |
inferred |
"value" |
Macros
Section titled “Macros”mcpJsonSchema
Section titled “mcpJsonSchema”Derive a JSON Schema for primitives, objects, enums, containers, tables, options, and nested combinations of those types.
macro mcpJsonSchema(T: typedesc): JsonNodeType parameters: T:type.
Returns: JsonNode.
Arguments
Section titled “Arguments”| Name | Type | Default |
|---|---|---|
T |
typedesc |