Has anyone created a custom tool that connects fro...
# ai-netsuite
b
Has anyone created a custom tool that connects from chatGPT? I am having trouble getting one to show under the actions? It has no problem showing up for claude though
s
do your tools specify an
outputSchema
- for some reason the NS help seems to have been recently updated and mentions that is required for ChatGPT
b
Yeah, I am basically attempting to replicate the "getCurrentUser" functionality from this blog: https://timdietrich.me/blog/netsuite-ai-current-user-information/ But no luck it just doesn't work, when i setup the connection in chatgpt it connects but there is nothing listed under actions, and then when i add the connection directly in the chat and ask it to run the mcp tools getCurrentUser it doesn't get a response. and here is my json:
Copy code
{
  "tools": [
    {
      "name": "getCurrentUser",
      "description": "Provides information about the NetSuite user that is using the AI client.",
      "inputSchema": {
        "type": "object",
        "properties": {},
        "required": [],
        "additionalProperties": false,
        "nullable": []
      },
      "outputSchema": {
        "type": "object",
        "properties": {
          "id": {
            "type": [
              "string",
              "number",
              "null"
            ],
            "description": "Internal ID"
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "User's name"
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "description": "Email address"
          },
          "role": {
            "type": [
              "string",
              "number",
              "null"
            ],
            "description": "Role or role ID"
          },
          "location": {
            "type": [
              "string",
              "number",
              "null"
            ],
            "description": "Location ID"
          },
          "department": {
            "type": [
              "string",
              "number",
              "null"
            ],
            "description": "Department ID"
          },
          "subsidiary": {
            "type": [
              "string",
              "number",
              "null"
            ],
            "description": "Subsidiary ID"
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Error message if execution fails"
          }
        },
        "required": [
          "id",
          "name"
        ],
        "additionalProperties": false,
        "nullable": [
          "email",
          "role",
          "location",
          "department",
          "subsidiary",
          "error"
        ]
      },
      "annotations": {
        "title": "Get Current User",
        "readOnlyHint": true,
        "idempotentHint": true,
        "openWorldHint": false
      }
    }
  ]
}
🤷 1
m
Array and Object datatypes are not allowed in the schema definition file (as per NS Docs). Only String, Number, and Boolean are allowed.
s
@Mohammad Sharaf Ali can you link where that restriction is documented? There is no such limitation in the MCP protocol or OpenRPC so that would mean NS AI Connector is not MCP compliant.
b
@Mohammad Sharaf Ali is it possible for you to share a minimal working example of a custom tool being used on chatGPT? I haven't seen a working example of it anywhere, and even in NS's docs it shows some reference samples but they don't actually work for chatGPT
m
If you are using ChatGPT, defining which schema properties are nullable is required. The following sample is the JSON schema definition for the custom tools when using ChatGPT.
Copy code
{
  "tools": [
    {
      "name": "add",
      "description": "Add two numbers together",
      "inputSchema": {
        "type": "object",
        "properties": {
          "a": {
            "type": "number",
            "description": "First addend"
          },
          "b": {
            "type": "number",
            "description": "Second addend"
          }
        },
        "required": [
          "a",
          "b"
        ],
        "nullable": []
      },
      "outputSchema": {
        "type": "object",
        "properties": {
          "result": {
            "type": "number",
            "description": "Value of adding the two input numbers"
          },
          "error": {
            "type": "string",
            "description": "Error message if execution fails"
          }
        },
        "required": [
          "result"
        ],
        "nullable": [
          "error"
        ]
      },
      "annotations": {
        "title": "Add Numbers",
        "readOnlyHint": true,
        "idempotentHint": true,
        "openWorldHint": false
      }
    }
  ]
}
b
I appreciate the response, however I was already aware of the docs and I did try this but it doesn't work. It appears that the connection to ChatGPT doesn't actually work yet, even though there are mentions of it in the docs.
m
Try the following sample I did and it should work.
f3_add_reverse_tool.js
Copy code
/**
 * exampletools.jsc
 * @NApiVersion 2.1
 * @NModuleScope Public
 */

define([], function() {
  return {
    add: function (args) {
      try {
        const a = args["a"];
        const b = args["b"];
        return {
          result: a+b
        };
      } catch(e) {
        return {
          result: "",
          error: "There was an error executin the tool: " + e
        }
      }
    },
    reverseText: function (args) {
      try {
        const text = args["text"];
        return {
          result: text.split('').reverse().join('')
        };
      } catch(e) {
        return {
          result: "",
          error: "There was an error executin the tool: " + e
        }
      }
    }
  }
});
f3_add_reverse_tool_schema.json
Copy code
{
  "tools": [
    {
      "name": "add",
      "description": "Add two numbers together",
      "inputSchema": {
        "type": "object",
        "properties": {
          "a": {
            "type": "number",
            "description": "First addend"
          },
          "b": {
            "type": "number",
            "description": "Second addend"
          }
        },
        "required": [
          "a",
          "b"
        ]
      },
      "outputSchema": {
        "type": "object",
        "properties": {
          "result": {
            "type": "number",
            "description": "Value of adding the two input numbers"
          },
          "error": {
            "type": "string",
            "description": "Error message if execution fails"
          }
        },
        "required": [
          "result"
        ]
      },
      "annotations": {
        "title": "Add Numbers",
        "readOnlyHint": true,
        "idempotentHint": true,
        "openWorldHint": false
      }
    },
    {
      "name": "reverseText",
      "description": "Reverses a given text string",
      "inputSchema": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string",
            "description": "Text to reverse"
          }
        },
        "required": [
          "text"
        ]
      },
      "outputSchema": {
        "type": "object",
        "properties": {
          "result": {
            "type": "string",
            "description": "Value of reversing the input text value"
          },
          "error": {
            "type": "string",
            "description": "Error message if execution fails"
          }
        },
        "required": [
          "result"
        ]
      },
      "annotations": {
        "title": "Reverse Text",
        "readOnlyHint": true,
        "idempotentHint": true,
        "openWorldHint": false
      }
    }
  ]
}
customtool_f3_add_reverse_tool.xml
Copy code
<tool scriptid="customtool_f3_add_reverse_tool">
  <name>Add Reverse Sample Tool Testing</name>
  <scriptfile>[/SuiteScripts/F3_NS_SKD_Customizations/custom_tools/f3_add_reverse_tool.js]</scriptfile>
  <rpcschema>[/SuiteScripts/F3_NS_SKD_Customizations/custom_tools/f3_add_reverse_tool_schema.json]</rpcschema>
  <exposeto3rdpartyagents>T</exposeto3rdpartyagents>
  <permission></permission>
</tool>
Attaching two screenshots for ref.
b
Hmm it still doesn't work for me. I noticed in your other thread you mentioned turning on "Developer Mode" which I am not seeing in my account ( we're on an Enterprise plan ) and i see that dev mode is a beta feature for only Pro and Plus at the moment so I think that's where the disconnect is happening
m
Check this if it helps: Connect using ChatGPT
s
Interesting that your response example includes
result
and
error
properties when they are technicall mutually exclusive. I think empirical evidence so far suggests that some AI clients and servers are sloppy with the MCP implementation.
👎 1
actually, that's not quite right above- you have it at the tool level (result and error, nested essentially relative to the top level openrpc definition of same?) I guess there's nothing stopping from having result = { result, error } and have additional logic know to process that app level (as opposed to OpenRPC protocol level) error? Still, OpenRPC is designed for remote procedures to return either a result or an error at the top level.
m
@Shawn Talbert, sharing another sample tool schema that was recently created. It uses the
nullable
property as suggested in the NetSuite docs specifically for ChatGPT, and it works perfectly without any issues.
Copy code
{
  "tools": [
    {
      "name": "getSalesOrderInfo",
      "description": "Retrieve comprehensive information about a specific sales order, including header fields, line items with expected ship dates, tax details, and additional metadata like department and location. Each line item includes expected ship date from the line or falls back to header ship date",
      "inputSchema": {
        "type": "object",
        "properties": {
          "orderId": {
            "type": "string",
            "description": "The internal ID of the sales order to retrieve detailed information for"
          }
        },
        "required": [
          "orderId"
        ],
        "nullable": []
      },
      "outputSchema": {
        "type": "object",
        "properties": {
          "result": {
            "type": "string",
            "description": "JSON stringified sales order data containing comprehensive details, or empty string if error occurred"
          },
          "error": {
            "type": "string",
            "description": "Error message if execution fails, or empty string if successful"
          }
        },
        "required": [
          "result"
        ],
        "nullable": [
          "error"
        ]
      },
      "annotations": {
        "title": "Get Sales Order Information",
        "readOnlyHint": true,
        "idempotentHint": true,
        "openWorldHint": false
      }
    }
  ]
}
b
The key distinction here is you being able to run it in Developer Mode which is only available for Pro and Plus accounts and not for Enterprise yet. Dev mode exposes the MCP as a callable tool to the user, while Enterprise only allows for "search" which is not what it sounds like. The "search" is just a "searchable source" so you can read what the connector exposes like the json schema and it can be used to help you but you don't get access to actually call any tools. Seems like you could possibly do this through Actions on a custom GPT if your on an enterprise plan, but I haven't tried that yet
m
To summarise: • Developer Mode (available on Pro/Plus) gives full MCP client support — i.e. both read and write access to connected tools • In contrast, in Enterprise plans connectors are disabled by default and admins control which connectors (and what operations) users can use
1
m
I checked @Mohammad Sharaf Ali’s and it works on my side.
1