@teamnetwork-nz/teamlink-mcp-server 0.5.7 → 0.5.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/build/index.js +102 -31
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -100,37 +100,67 @@ async function put(path, body) {
100
100
  }
101
101
  }
102
102
  const server = new McpServer({ name: 'teamlink-mcp', version: pkgVersion() });
103
+ function strictTool(name, description, inputSchema, callback) {
104
+ return server.registerTool(name, {
105
+ description,
106
+ inputSchema: z.object(inputSchema).strict(),
107
+ }, callback);
108
+ }
103
109
  const allowedQueryParams = {
104
- '/accounts/search': new Set(['q', 'phone', 'exactWebsite', 'page', 'pageSize']),
110
+ '/accounts/search': new Set([
111
+ 'mode', 'q', 'csaId', 'accountId', 'alphaId', 'name', 'address', 'phone', 'website',
112
+ 'exactWebsite', 'isActive', 'isCustomer', 'isProspect', 'isSupplier', 'isBranch',
113
+ 'branchId', 'teamId', 'page', 'pageSize',
114
+ ]),
105
115
  '/accounts': new Set(['search', 'isActive', 'isCustomer', 'isProspect', 'isSupplier', 'isBranch', 'branchId', 'teamId', 'page', 'pageSize']),
106
- '/contacts/search': new Set(['q', 'accountId', 'email', 'mobile', 'businessPhone', 'isActive', 'role', 'page', 'pageSize']),
116
+ '/contacts/search': new Set([
117
+ 'mode', 'q', 'cscId', 'contactId', 'firstName', 'lastName', 'fullName', 'shortName',
118
+ 'csaId', 'accountId', 'email', 'mobile', 'businessPhone', 'isActive', 'role', 'page', 'pageSize',
119
+ ]),
107
120
  '/tasks/time-entries/search': new Set(['taskId', 'accountId', 'personId', 'type', 'q', 'dateFrom', 'dateTo', 'page', 'pageSize']),
108
121
  '/tasks/search': new Set(['q', 'accountId', 'loggedForUserId', 'assignedToUserId', 'enteredByUserId', 'callType', 'priority', 'status', 'dateFrom', 'dateTo', 'page', 'pageSize']),
122
+ '/crm/activities/search': new Set(['q', 'accountId', 'assignedToUserId', 'targetContactId', 'enteredByUserId', 'completed', 'dateDueFrom', 'dateDueTo', 'page', 'pageSize']),
123
+ '/crm/activities/time-entries/search': new Set(['activityId', 'accountId', 'personId', 'q', 'dateFrom', 'dateTo', 'page', 'pageSize']),
109
124
  '/orders/search': new Set(['q', 'advanced', 'accountId', 'branchId', 'enteredByUserId', 'authorisedByUserId', 'vendorId', 'receivedByUserId', 'approvedByUserId', 'invoicedByUserId', 'returnAuthorisedByUserId', 'creditedByUserId', 'orderType', 'dateFrom', 'dateTo', 'received', 'invoiced', 'returned', 'page', 'pageSize']),
110
- '/orders/products/search': new Set(['q', 'vendorId', 'manufacturer', 'category', 'page', 'pageSize']),
125
+ '/orders/products/search': new Set(['q', 'supplierId', 'vendorId', 'manufacturer', 'category', 'inStock', 'page', 'pageSize']),
111
126
  };
112
127
  // --- Identity ---
113
- server.tool('teamlink_whoami', 'Return the authenticated TEAMlink user context for the configured API key, including `roleClass` (CSCClass) and `homeAccountId` (CSAID — the identity key scoping staff vs customer visibility).', {}, async () => get('/me'));
128
+ strictTool('teamlink_whoami', 'Return the authenticated TEAMlink user context for the configured API key, including `roleClass` (CSCClass) and `homeAccountId` (CSAID — the identity key scoping staff vs customer visibility).', {}, async () => get('/me'));
114
129
  // --- CRM: accounts ---
115
- server.tool('crm_search_accounts', 'Search customer accounts by account id, name, alpha id, email domain, website, or normalized phone. Also accepts explicit phone and exactWebsite duplicate-detection style inputs. Results include selector objects for industry/source/salesStatus and named team/contact reference objects where available.', {
116
- q: z.string().describe('Search text: account ID (CSAID), account name, alpha ID, email domain, website, or phone digits.'),
117
- phone: z.string().optional().describe('Optional phone search; punctuation/spaces are ignored and partial digit matches are allowed against CSAccount.CSAPhone.'),
118
- exactWebsite: z.string().optional().describe('Optional exact website match against CSAccount.CSAWebsite.'),
130
+ strictTool('crm_search_accounts', 'Search customer accounts. `csaId` is canonical for CSAccount.CSAID; `accountId` is accepted as a compatibility alias. Default mode is standard: exact case-insensitive matches. Fuzzy mode performs partial text/phone matching and name DIFFERENCE() matching. `isActive` defaults true unless explicitly set.', {
131
+ mode: z.enum(['standard', 'fuzzy']).optional().describe('Search mode. standard=exact case-insensitive matching; fuzzy=partial matching plus DIFFERENCE() for names. Defaults to standard.'),
132
+ q: z.string().optional().describe('General search value matched against csaId, alphaId, name, address, phone, and website.'),
133
+ csaId: z.number().optional().describe('Canonical account primary key (CSAccount.CSAID).'),
134
+ accountId: z.number().optional().describe('Compatibility alias for csaId. Prefer csaId.'),
135
+ alphaId: z.string().optional(),
136
+ name: z.string().optional(),
137
+ address: z.string().optional(),
138
+ phone: z.string().optional().describe('Phone search; punctuation/spaces are ignored.'),
139
+ website: z.string().optional(),
140
+ exactWebsite: z.string().optional().describe('Compatibility alias for website. Prefer website.'),
141
+ isActive: z.boolean().optional().describe('Defaults to true if omitted.'),
142
+ isCustomer: z.boolean().optional(),
143
+ isProspect: z.boolean().optional(),
144
+ isSupplier: z.boolean().optional(),
145
+ isBranch: z.boolean().optional(),
146
+ branchId: z.string().optional(),
147
+ teamId: z.number().optional(),
119
148
  page: z.number().optional(),
120
149
  pageSize: z.number().optional(),
121
150
  }, async (args) => get('/accounts/search', args));
122
- server.tool('crm_list_accounts', 'List/filter accounts. `isActive` filters on CSAActive — only active accounts are eligible for transactional activity (orders/tasks). Results include selector objects for industry/source/salesStatus and named team/contact reference objects where available.', {
151
+ strictTool('crm_list_accounts', 'Deprecated compatibility wrapper for listing/filtering accounts. Prefer crm_search_accounts for new work. `isActive` filters on CSAActive — only active accounts are eligible for transactional activity (orders/tasks).', {
123
152
  search: z.string().optional(), isActive: z.boolean().optional(), isCustomer: z.boolean().optional(), isProspect: z.boolean().optional(),
124
- isSupplier: z.boolean().optional(), branchId: z.string().optional(), page: z.number().optional(), pageSize: z.number().optional(),
153
+ isSupplier: z.boolean().optional(), isBranch: z.boolean().optional(), branchId: z.string().optional(), teamId: z.number().optional(),
154
+ page: z.number().optional(), pageSize: z.number().optional(),
125
155
  }, async (args) => get('/accounts', args));
126
156
  // `accountId` (CSAID) is the absolute source-of-truth identity key for this account
127
157
  // and everything linked to it (contacts, orders, tasks, ...) — see lookup_selectors
128
158
  // and crm_search_accounts for how to resolve one. Response `isActive` = CSAActive:
129
159
  // only active accounts are eligible for transactional activity (orders/tasks).
130
- server.tool('crm_get_account', 'Get one account by id (CSAID). Response `isActive` (CSAActive) gates transactional eligibility for orders/tasks. Lookup-backed fields include industry/source/salesStatus {code,label}, team {teamId,name}, and accountManager/preferredEngineer/backupEngineer/bizDevManager {userId,name}.', { accountId: z.number() }, async ({ accountId }) => get(`/accounts/${accountId}`));
131
- server.tool('crm_list_account_contacts', 'List contacts linked to an account. Defaults to active-only (CSPCA_Active); pass includeInactive=true to also return deactivated contacts for historical/reporting purposes — inactive does not mean deleted.', { accountId: z.number(), includeInactive: z.boolean().optional() }, async ({ accountId, includeInactive }) => get(`/accounts/${accountId}/contacts`, { includeInactive }));
160
+ strictTool('crm_get_account', 'Get one account by id (CSAID). Response `isActive` (CSAActive) gates transactional eligibility for orders/tasks. Lookup-backed fields include industry/source/salesStatus {code,label}, team {teamId,name}, and accountManager/preferredEngineer/backupEngineer/bizDevManager {userId,name}.', { accountId: z.number() }, async ({ accountId }) => get(`/accounts/${accountId}`));
161
+ strictTool('crm_list_account_contacts', 'List contacts linked to an account. Defaults to active-only (CSPCA_Active); pass includeInactive=true to also return deactivated contacts for historical/reporting purposes — inactive does not mean deleted.', { accountId: z.number(), includeInactive: z.boolean().optional() }, async ({ accountId, includeInactive }) => get(`/accounts/${accountId}/contacts`, { includeInactive }));
132
162
  if (READWRITE) {
133
- server.tool('crm_create_account', 'Create an account. Returns duplicate-candidate warnings unless createAnyway=true.', {
163
+ strictTool('crm_create_account', 'Create an account. Returns duplicate-candidate warnings unless createAnyway=true.', {
134
164
  name: z.string(), alphaId: z.string().optional(), website: z.string().optional(), phone: z.string().optional(),
135
165
  isCustomer: z.boolean().optional(), isProspect: z.boolean().optional(), createAnyway: z.boolean().optional(),
136
166
  }, async (args) => post('/accounts', args));
@@ -143,38 +173,76 @@ if (READWRITE) {
143
173
  // TYPE) — typeFlags.isAdminContact means a client-side admin/accounts contact,
144
174
  // NOT the application admin role (role="A").
145
175
  const roleDescription = 'CSCClass web-app role: A=Administrator, C=Customer, E=Engineer, M=Business Manager, P=Partner, S=Sales, T=Account Manager.';
146
- server.tool('crm_search_contacts', 'Search contacts by contact id, names, email, mobile, business phone, account id, web-app role (CSCClass), and active pivot status.', {
147
- q: z.string().optional(), accountId: z.number().optional(), email: z.string().optional(),
148
- mobile: z.string().optional().describe('Filter by mobile phone (CSContact.CSCMobile); punctuation/spaces are ignored and partial digit matches are allowed.'),
149
- businessPhone: z.string().optional().describe('Filter by business/DDI phone (CSContact.CSCBizPhone); punctuation/spaces are ignored and partial digit matches are allowed.'),
176
+ strictTool('crm_search_contacts', 'Search contacts. `cscId` is canonical for CSContact.CSCID; `contactId` is accepted as a compatibility alias. `csaId` is canonical for account linkage; `accountId` is accepted as a compatibility alias. Default mode is standard: exact case-insensitive matches. Fuzzy mode performs partial matching.', {
177
+ mode: z.enum(['standard', 'fuzzy']).optional().describe('Search mode. standard=exact case-insensitive matching; fuzzy=partial matching. Defaults to standard.'),
178
+ q: z.string().optional().describe('General search value matched against cscId/contactId, names, email, mobile, and business phone.'),
179
+ cscId: z.number().optional().describe('Canonical contact primary key (CSContact.CSCID).'),
180
+ contactId: z.number().optional().describe('Compatibility alias for cscId. Prefer cscId.'),
181
+ firstName: z.string().optional(),
182
+ lastName: z.string().optional(),
183
+ fullName: z.string().optional(),
184
+ shortName: z.string().optional(),
185
+ csaId: z.number().optional().describe('Canonical linked account primary key (CSAccount.CSAID / CSPivotContactAccount.CSPCA_CSAID).'),
186
+ accountId: z.number().optional().describe('Compatibility alias for csaId. Prefer csaId.'),
187
+ email: z.string().optional(),
188
+ mobile: z.string().optional().describe('Mobile phone search; punctuation/spaces are ignored.'),
189
+ businessPhone: z.string().optional().describe('Business/DDI phone search; punctuation/spaces are ignored.'),
150
190
  isActive: z.boolean().optional().describe('Filter by CSPivotContactAccount.CSPCA_Active when pivot context is joined.'),
151
191
  role: z.string().optional().describe(roleDescription),
152
192
  page: z.number().optional(), pageSize: z.number().optional(),
153
193
  }, async (args) => get('/contacts/search', args));
154
- server.tool('crm_get_contact', 'Get one contact by id. Response includes `role` (CSCClass) and `typeFlags` (contact type, distinct from role), `homeAccountId` (the CSAID this contact belongs to), and `isActive` — sourced from the CSPivotContactAccount pivot (CSPCA_Active), NOT the legacy/unused CSCActive column. An inactive contact may still be returned for historical/reporting purposes.', { contactId: z.number() }, async ({ contactId }) => get(`/contacts/${contactId}`));
194
+ strictTool('crm_get_contact', 'Get one contact by id. Response includes `role` (CSCClass) and `typeFlags` (contact type, distinct from role), `homeAccountId` (the CSAID this contact belongs to), and `isActive` — sourced from the CSPivotContactAccount pivot (CSPCA_Active), NOT the legacy/unused CSCActive column. An inactive contact may still be returned for historical/reporting purposes.', { contactId: z.number() }, async ({ contactId }) => get(`/contacts/${contactId}`));
155
195
  if (READWRITE) {
156
- server.tool('crm_create_contact', 'Create a contact under an account (also creates the active account link).', {
196
+ strictTool('crm_create_contact', 'Create a contact under an account (also creates the active account link).', {
157
197
  accountId: z.number(), firstName: z.string(), lastName: z.string(), email: z.string(),
158
198
  mobile: z.string().optional(), businessPhone: z.string().optional(),
159
199
  role: z.string().optional().describe(roleDescription + ' Only settable for branch accounts; forced to C otherwise.'),
160
200
  }, async ({ accountId, ...body }) => post(`/accounts/${accountId}/contacts`, body));
161
- server.tool('crm_update_contact', 'Update a contact. Password only applied if supplied. `active` sets CSPivotContactAccount.CSPCA_Active for the account context (the legacy CSCActive column is never written).', {
201
+ strictTool('crm_update_contact', 'Update a contact. Password only applied if supplied. `active` sets CSPivotContactAccount.CSPCA_Active for the account context (the legacy CSCActive column is never written).', {
162
202
  contactId: z.number(), firstName: z.string(), lastName: z.string(), email: z.string(), mobile: z.string().optional(),
163
203
  role: z.string().optional().describe(roleDescription),
164
204
  active: z.boolean().optional().describe('Sets CSPCA_Active (pivot) for the account context, not CSCActive.'),
165
205
  }, async ({ contactId, ...body }) => put(`/contacts/${contactId}`, body));
166
206
  }
167
207
  // --- Lookups ---
168
- server.tool('lookup_selectors', 'Get options for a CSSelectors list (Industry, Source, SalesStatus, OrderType, IncomeCat, City, Country, ...).', { selectorClass: z.string() }, async ({ selectorClass }) => get(`/lookups/selectors/${encodeURIComponent(selectorClass)}`));
169
- server.tool('lookup_branches', 'List branches.', {}, async () => get('/lookups/branches'));
208
+ strictTool('lookup_selectors', 'Get options for a CSSelectors list (Industry, Source, SalesStatus, OrderType, IncomeCat, City, Country, ...).', { selectorClass: z.string() }, async ({ selectorClass }) => get(`/lookups/selectors/${encodeURIComponent(selectorClass)}`));
209
+ strictTool('lookup_branches', 'List branches.', {}, async () => get('/lookups/branches'));
210
+ // --- CRM: sales activities / time (read) ---
211
+ strictTool('crm_activity_get', 'Get one CRM sales activity by id (CRMActivity.CRMAID). Returns account, enteredBy, assignedTo, targetContact, type/subType selector labels, due/completed dates, and completed boolean.', { activityId: z.number().describe('CRM activity ID (CRMActivity.CRMAID).') }, async ({ activityId }) => get(`/crm/activities/${activityId}`));
212
+ strictTool('crm_activity_search', 'Search/filter CRM sales activities (CRMActivity). Supports customer/account, assigned-to staff, targeted-at contact, entered-by staff, completed/open state, due-date range, and free text. `completed=true` means CRMADateCompleted is not null; `completed=false` means open.', {
213
+ q: z.string().optional().describe('Free text: exact activity ID match, or partial match on description/type/subtype labels.'),
214
+ accountId: z.number().optional().describe('Filter by customer/account/company (CSAID). Maps to CRMActivity.CRMA_CSAID.'),
215
+ assignedToUserId: z.number().optional().describe('Filter by assigned staff/contact (CRMActivity.CRMAAssignedTo_CSCID).'),
216
+ targetContactId: z.number().optional().describe('Filter by targeted-at contact (CRMActivity.CRMA_CSCID_Target).'),
217
+ enteredByUserId: z.number().optional().describe('Filter by staff/contact who entered the activity (CRMActivity.CRMA_CSCID).'),
218
+ completed: z.boolean().optional().describe('true = CRMADateCompleted is not null; false = CRMADateCompleted is null; omitted = all.'),
219
+ dateDueFrom: z.string().optional().describe('Due-date range start (CRMActivity.CRMADateDue), e.g. 2026-01-01.'),
220
+ dateDueTo: z.string().optional().describe('Due-date range end (CRMActivity.CRMADateDue).'),
221
+ page: z.number().optional(),
222
+ pageSize: z.number().optional(),
223
+ }, async (args) => get('/crm/activities/search', args));
224
+ strictTool('crm_activity_list_time_entries', 'List time entries + totals for a CRM sales activity. CRM activity time is TMActivity with TMAType=A and TMA_CRMAID=CRMActivity.CRMAID.', {
225
+ activityId: z.number().describe('CRM activity ID (CRMActivity.CRMAID / TMActivity.TMA_CRMAID).'),
226
+ personId: z.number().optional().describe('Filter by staff person who performed the work (TMActivity.TMA_CSCID).'),
227
+ }, async ({ activityId, personId }) => get(`/crm/activities/${activityId}/time-entries`, { personId }));
228
+ strictTool('crm_activity_search_time_entries', 'Search CRM sales activity time entries across activities. Supports filtering by activityId, account/customer (CRMActivity.CRMA_CSAID), staff performer (TMActivity.TMA_CSCID), date range, and text in time-entry or activity descriptions.', {
229
+ activityId: z.number().optional().describe('Filter by CRM activity ID (TMActivity.TMA_CRMAID).'),
230
+ accountId: z.number().optional().describe('Filter by customer/account/company (CSAID). Maps through CRMActivity.CRMA_CSAID.'),
231
+ personId: z.number().optional().describe('Filter by staff person who performed the work (TMActivity.TMA_CSCID).'),
232
+ q: z.string().optional().describe('Partial text match against TMActivity.TMADescription, TMActivity.TMAInternal, or CRMActivity.CRMADescription.'),
233
+ dateFrom: z.string().optional().describe('Activity time-entry date range start (TMActivity.TMADate), e.g. 2026-01-01.'),
234
+ dateTo: z.string().optional().describe('Activity time-entry date range end (TMActivity.TMADate).'),
235
+ page: z.number().optional(),
236
+ pageSize: z.number().optional(),
237
+ }, async (args) => get('/crm/activities/time-entries/search', args));
170
238
  // --- Tasks / time (read) ---
171
- server.tool('task_get', 'Get a task by id. Returns account/bill-to and contact actor fields as objects with IDs and names, while retaining raw ID fields.', { taskId: z.number() }, async ({ taskId }) => get(`/tasks/${taskId}`));
172
- server.tool('task_list_time_entries', 'List time/incidental entries + totals for a task. Can filter by staff person who performed the work (TMActivity.TMA_CSCID).', {
239
+ strictTool('task_get', 'Get a task by id. Returns account/bill-to and contact actor fields as objects with IDs and names, while retaining raw ID fields.', { taskId: z.number() }, async ({ taskId }) => get(`/tasks/${taskId}`));
240
+ strictTool('task_list_time_entries', 'List time/incidental entries + totals for a task. Can filter by staff person who performed the work (TMActivity.TMA_CSCID).', {
173
241
  taskId: z.number().describe('Task ID (TMTask.TMTID / TMActivity.TMA_TMTID).'),
174
242
  personId: z.number().optional().describe('Filter by staff person who performed the work (TMActivity.TMA_CSCID).'),
175
243
  type: z.enum(['time', 'incidentals', 'all']).optional().describe('Entry kind based on TMActivity.TMACost: time = TMACost 0, incidentals = TMACost non-zero.'),
176
244
  }, async ({ taskId, personId, type }) => get(`/tasks/${taskId}/time-entries`, { personId, type }));
177
- server.tool('task_search_time_entries', 'Search task activity/time and incidentals across tasks. Supports filtering by account/customer (TMTask.TMT_CSAID), taskId, staff performer (TMActivity.TMA_CSCID), date range, entry kind, and text in public/internal descriptions. Date filters are `dateFrom`/`dateTo` only; do not use `fromDate`/`toDate`.', {
245
+ strictTool('task_search_time_entries', 'Search task activity/time and incidentals across tasks. Supports filtering by account/customer (TMTask.TMT_CSAID), taskId, staff performer (TMActivity.TMA_CSCID), date range, entry kind, and text in public/internal descriptions. Date filters are `dateFrom`/`dateTo` only; do not use `fromDate`/`toDate`.', {
178
246
  taskId: z.number().optional().describe('Filter by task ID (TMActivity.TMA_TMTID).'),
179
247
  accountId: z.number().optional().describe('Filter by customer/account/company (CSAID). Maps through TMTask.TMT_CSAID for the task the entry belongs to.'),
180
248
  personId: z.number().optional().describe('Filter by staff person who performed the work (TMActivity.TMA_CSCID).'),
@@ -185,7 +253,7 @@ server.tool('task_search_time_entries', 'Search task activity/time and incidenta
185
253
  page: z.number().optional(),
186
254
  pageSize: z.number().optional(),
187
255
  }, async (args) => get('/tasks/time-entries/search', args));
188
- server.tool('task_search', 'Search/filter tasks. Supports filtering by customer/account, logged-for contact, assigned staff member, entered-by staff member, call type, priority/severity, open/closed status, a date-logged range, and/or free text. Defaults to open tasks only unless status is set. Every filter is optional and combinable. Results include account/loggedFor/assignedTo/enteredBy objects with names, plus raw IDs.', {
256
+ strictTool('task_search', 'Search/filter tasks. Supports filtering by customer/account, logged-for contact, assigned staff member, entered-by staff member, call type, priority/severity, open/closed status, a date-logged range, and/or free text. Defaults to open tasks only unless status is set. Every filter is optional and combinable. Results include account/loggedFor/assignedTo/enteredBy objects with names, plus raw IDs.', {
189
257
  q: z.string().optional().describe('Free text: exact task ID match, or partial match on task name/description.'),
190
258
  accountId: z.number().optional().describe('Filter by customer/account/company (CSAID). Maps to TMTask.TMT_CSAID — the account the task was logged for.'),
191
259
  loggedForUserId: z.number().optional().describe('Filter by the customer contact who requested/is authorising the task (TMTask.TMTLoggedBy_CSCID).'),
@@ -199,9 +267,9 @@ server.tool('task_search', 'Search/filter tasks. Supports filtering by customer/
199
267
  page: z.number().optional(), pageSize: z.number().optional(),
200
268
  }, async (args) => get('/tasks/search', args));
201
269
  // --- Orders / PM (read) ---
202
- server.tool('order_get', 'Get an order header + totals. Returns account/bill-to and contact actor fields as objects with IDs and names, while retaining raw ID fields. `orderType` is returned as { code, label } from CSSelectors/OrderType.', { orderId: z.number() }, async ({ orderId }) => get(`/orders/${orderId}`));
203
- server.tool('order_list_items', 'List order line items.', { orderId: z.number() }, async ({ orderId }) => get(`/orders/${orderId}/items`));
204
- server.tool('order_search', 'Search/filter orders. Supports filtering by customer/account, branch, order type, a date-raised range, who entered or authorised the order, who received/approved/invoiced/returned/credited a line, received/invoiced/returned status, and/or free text (order id, invoice/credit/RA reference, or with advanced=true also notes and product codes/descriptions). Every filter is optional and combinable. Results include account/enteredBy/authorisedBy objects with names, plus raw IDs. Returned `orderType` is { code, label } resolved from CSSelectors/OrderType.', {
270
+ strictTool('order_get', 'Get an order header + totals. Returns account/bill-to and contact actor fields as objects with IDs and names, while retaining raw ID fields. `orderType` is returned as { code, label } from CSSelectors/OrderType.', { orderId: z.number() }, async ({ orderId }) => get(`/orders/${orderId}`));
271
+ strictTool('order_list_items', 'List order line items.', { orderId: z.number() }, async ({ orderId }) => get(`/orders/${orderId}/items`));
272
+ strictTool('order_search', 'Search/filter orders. Supports filtering by customer/account, branch, order type, a date-raised range, who entered or authorised the order, who received/approved/invoiced/returned/credited a line, received/invoiced/returned status, and/or free text (order id, invoice/credit/RA reference, or with advanced=true also notes and product codes/descriptions). Every filter is optional and combinable. Results include account/enteredBy/authorisedBy objects with names, plus raw IDs. Returned `orderType` is { code, label } resolved from CSSelectors/OrderType.', {
205
273
  q: z.string().optional().describe('Free text search — order id (exact), invoice/credit/RA reference (partial); with advanced=true also order notes and line product code/OEM code/descriptions.'),
206
274
  advanced: z.boolean().optional().describe('Widen `q` to also match order notes and line product code/OEM code/descriptions.'),
207
275
  accountId: z.number().optional().describe('Filter by customer/account/company (CSAID). Maps to PMOrder.PMO_CSAID.'),
@@ -222,10 +290,13 @@ server.tool('order_search', 'Search/filter orders. Supports filtering by custome
222
290
  returned: z.enum(['yes', 'no']).optional().describe('Whether at least one line has a return reason set. Same "at least one line" semantics as `received`.'),
223
291
  page: z.number().optional(), pageSize: z.number().optional(),
224
292
  }, async (args) => get('/orders/search', args));
225
- server.tool('product_search', 'Search the (read-only) product catalog. `q` splits on whitespace and requires every word to match description/code/OEM code.', {
226
- q: z.string().optional(), vendorId: z.number().optional(),
293
+ strictTool('product_search', 'Search the read-only product catalog. `q` splits on whitespace and requires every word to match as a substring in code, OEM code, description, manufacturer, or category. Filter by supplier/vendor and stock availability.', {
294
+ q: z.string().optional(),
295
+ supplierId: z.number().optional().describe('Canonical supplier/vendor account id (PMProduct.PMPVendor_CSAID).'),
296
+ vendorId: z.number().optional().describe('Compatibility alias for supplierId. Prefer supplierId.'),
227
297
  manufacturer: z.string().optional().describe('Exact match on PMPManufacturer.'),
228
298
  category: z.string().optional().describe('Exact match on PMPProductCategory_ID.'),
299
+ inStock: z.boolean().optional().describe('true = PMPOnHand > 0; false = no stock on hand.'),
229
300
  page: z.number().optional(), pageSize: z.number().optional(),
230
301
  }, async (args) => get('/orders/products/search', args));
231
302
  async function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnetwork-nz/teamlink-mcp-server",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "private": false,
5
5
  "description": "stdio MCP server exposing tools that proxy the TEAMlink REST API",
6
6
  "main": "build/index.js",