Class UntrustedText

java.lang.Object
com.eqixiac.equinix.mcp.server.UntrustedText

public final class UntrustedText extends Object
The one place tool output handles text that came from a remote system: Equinix API fields (ticket references, device names, service-profile names, error messages), PeeringDB names, and the messages of failed pricing lookups. Such text reaches the calling model, which must not mistake it for instructions.

Every value written through this class is

  1. sanitised: C0/C1 control characters (newlines and tabs become a space), Unicode format characters (bidirectional overrides, zero-width characters), line/paragraph separators and unpaired surrogates are removed;
  2. bounded: values longer than MAX_FIELD_CHARS characters are cut and end with a [truncated N chars] marker;
  3. labelled: it is stored as an UntrustedText.Untrusted text node. Before the result leaves the server, McpToolAdapter collects the JSON-pointer path of every such node into a top-level "untrusted_data" block that tells the model the text is data.

Error results are sanitised and bounded the same way, and an error that carries a remote service's message says so.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A text node holding sanitised remote text.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The top-level result field that lists untrusted paths.
    static final int
    Longest engine-generated document kept (a summary or Markdown report that embeds remote names), in characters.
    static final int
    Longest error message kept, in characters.
    static final int
    Longest untrusted field value kept, in characters.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    add(com.fasterxml.jackson.databind.node.ArrayNode array, String raw)
    Appends remote text to array as a labelled, sanitised element.
    static com.fasterxml.jackson.databind.JsonNode
    A labelled, sanitised node for a long document that embeds remote text (an engine's summary or Markdown report), bounded at MAX_DOCUMENT_CHARS instead of MAX_FIELD_CHARS.
    static com.fasterxml.jackson.databind.JsonNode
    node(String raw)
     
    static void
    put(com.fasterxml.jackson.databind.node.ObjectNode parent, String field, String raw)
    Puts remote text into parent as a labelled, sanitised field.
    static String
    sanitize(String raw, int maxChars)
    Removes control, format and separator characters and bounds the length.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LABEL_FIELD

      public static final String LABEL_FIELD
      The top-level result field that lists untrusted paths.
      See Also:
    • MAX_FIELD_CHARS

      public static final int MAX_FIELD_CHARS
      Longest untrusted field value kept, in characters.
      See Also:
    • MAX_DOCUMENT_CHARS

      public static final int MAX_DOCUMENT_CHARS
      Longest engine-generated document kept (a summary or Markdown report that embeds remote names), in characters.
      See Also:
    • MAX_ERROR_CHARS

      public static final int MAX_ERROR_CHARS
      Longest error message kept, in characters.
      See Also:
  • Method Details

    • sanitize

      public static String sanitize(String raw, int maxChars)
      Removes control, format and separator characters and bounds the length.
      Parameters:
      raw - the remote text; null yields null
      maxChars - the longest result kept before the truncation marker
      Returns:
      the sanitised text
    • node

      public static com.fasterxml.jackson.databind.JsonNode node(String raw)
      Parameters:
      raw - remote text
      Returns:
      a labelled, sanitised text node, or a null node for null
    • document

      public static com.fasterxml.jackson.databind.JsonNode document(String raw)
      A labelled, sanitised node for a long document that embeds remote text (an engine's summary or Markdown report), bounded at MAX_DOCUMENT_CHARS instead of MAX_FIELD_CHARS.
      Parameters:
      raw - the document
      Returns:
      the node, or a null node for null
    • put

      public static void put(com.fasterxml.jackson.databind.node.ObjectNode parent, String field, String raw)
      Puts remote text into parent as a labelled, sanitised field.
      Parameters:
      parent - the object to write into
      field - the field name
      raw - the remote text (may be null)
    • add

      public static void add(com.fasterxml.jackson.databind.node.ArrayNode array, String raw)
      Appends remote text to array as a labelled, sanitised element.
      Parameters:
      array - the array to append to
      raw - the remote text (may be null)