Published on

NetSuite MCP custom tool

Minimum working custom tool for the NetSuite AI Connector Service. Deploy with suitecloud project:deploy, then connect your AI client to /services/mcp/v1/all.

src/FileCabinet/SuiteApps/com.example.tools/tools/item_tools.js
/**
* @NApiVersion 2.1
* @NModuleScope Public
* @NScriptType CustomTool
*/
define(['N/query'], (query) => ({
getItemAvailability: async function (args) {
try {
const rows = query
.runSuiteQL({
query: `
SELECT BUILTIN.DF(ail.location) AS location,
ail.quantityonhand AS on_hand,
ail.quantityavailable AS available
FROM aggregateitemlocation ail
JOIN item i ON i.id = ail.item
WHERE i.itemid = ?`,
params: [String(args.itemId)],
})
.asMappedResults()
return { result: rows }
} catch (e) {
return { result: [], error: `getItemAvailability failed: ${e.message}` }
}
},
}))
src/FileCabinet/SuiteApps/com.example.tools/tools/item_tools_schema.json
{
"tools": [
{
"name": "getItemAvailability",
"description": "Returns on-hand and available quantity per location for one item. Use it when someone asks whether an item is in stock or where it is stocked. Input is the item name or number as users type it, not the internal ID.",
"inputSchema": {
"type": "object",
"properties": {
"itemId": { "type": "string", "description": "Item name/number, for example HDMI-2M" }
},
"required": ["itemId"]
},
"annotations": {
"title": "Item availability",
"readOnlyHint": true,
"idempotentHint": true,
"openWorldHint": false
}
}
]
}
src/Objects/custtoolset_item_tools.xml
<toolset scriptid="custtoolset_item_tools">
<name>Item Tools</name>
<scriptfile>[/SuiteApps/com.example.tools/tools/item_tools.js]</scriptfile>
<rpcschema>[/SuiteApps/com.example.tools/tools/item_tools_schema.json]</rpcschema>
<exposetoaiconnector>T</exposetoaiconnector>
</toolset>

Rules: every entry point is async; N/http, N/https, N/llm, and N/sftp are not supported; schema names must match the script exactly. Use toolset, not the deprecated tool object. Full guide: Connecting Claude to NetSuite with the AI Connector Service.