Class ::nsmcp::Protocol

::nsmcp::Protocol[i] create ... \
           [ -authorizer:required authorizer:required ] \
           [ -registry:required registry:required ] \
           [ -versions (default "2025-03-26 2025-06-18 2025-11-25") ]

Defined in /usr/local/ns/tcl/nsmcp/protocol.tcl

Class Relations

  • class: ::nx::Class[i]
  • superclass: ::nsmcp::Object[i]

Methods (to be applied on instances)

  • dispatch (scripted, public)

     <instance of nsmcp::Protocol[i]> dispatch context method params

    Dispatch an authenticated MCP protocol method. Handle initialization and tool operations using the configured registry and request authorizer.

    Parameters:
    context (required)
    Authenticated request context carrying the principal, grants and selected server.
    method (required)
    MCP protocol method or HTTP method, depending on the adapter.
    params (required)
    Rooted typed JSON-RPC parameters.
    Returns:
    The rooted JSON protocol result or notification result.

    Testcases:
    No testcase defined.
  • error (scripted, public)

     <instance of nsmcp::Protocol[i]> error id code message

    Encode a JSON-RPC error response. Preserve the typed request identifier while constructing the standard error envelope.

    Parameters:
    id (required)
    Typed request or retained evidence identifier.
    code (required)
    JSON-RPC error code.
    message (required)
    Diagnostic message text.
    Returns:
    Serialized JSON for the error response.

    Testcases:
    No testcase defined.
  • handle (scripted, public)

     <instance of nsmcp::Protocol[i]> handle context body

    Parse and handle one JSON-RPC request body. Enforce JSON structure and size bounds, then encode protocol errors or dispatch results.

    Parameters:
    context (required)
    Authenticated request context carrying the principal, grants and selected server.
    body (required)
    Serialized HTTP or JSON-RPC request body.
    Returns:
    The serialized protocol response.

    Testcases:
    No testcase defined.
  • supports (scripted, public)

     <instance of nsmcp::Protocol[i]> supports version

    Check whether an MCP protocol version is supported. Compare the requested version with the configured version list.

    Parameters:
    version (required)
    Requested MCP protocol-version string.
    Returns:
    True for a supported version, otherwise false.

    Testcases:
    No testcase defined.