@teamnetwork-nz/teamlink-mcp-server 0.5.6 → 0.5.7
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.
- package/build/index.js +30 -3
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -41,6 +41,12 @@ const http = axios.create({
|
|
|
41
41
|
function ok(data) {
|
|
42
42
|
return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] };
|
|
43
43
|
}
|
|
44
|
+
function usageError(message, details) {
|
|
45
|
+
return {
|
|
46
|
+
content: [{ type: 'text', text: `Tool argument error: ${JSON.stringify({ message, ...details })}` }],
|
|
47
|
+
isError: true,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
44
50
|
function fail(err) {
|
|
45
51
|
if (!API_KEY) {
|
|
46
52
|
return {
|
|
@@ -57,6 +63,16 @@ function fail(err) {
|
|
|
57
63
|
};
|
|
58
64
|
}
|
|
59
65
|
async function get(path, params) {
|
|
66
|
+
const allowedParams = allowedQueryParams[path];
|
|
67
|
+
if (allowedParams && params) {
|
|
68
|
+
const unknownParams = Object.keys(params).filter((key) => !allowedParams.has(key));
|
|
69
|
+
if (unknownParams.length) {
|
|
70
|
+
return usageError(`Unknown query parameter(s): ${unknownParams.join(', ')}`, {
|
|
71
|
+
unknownParams,
|
|
72
|
+
allowedParams: [...allowedParams].sort(),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
60
76
|
try {
|
|
61
77
|
const r = await http.get(path, { params });
|
|
62
78
|
return ok(r.data);
|
|
@@ -84,6 +100,15 @@ async function put(path, body) {
|
|
|
84
100
|
}
|
|
85
101
|
}
|
|
86
102
|
const server = new McpServer({ name: 'teamlink-mcp', version: pkgVersion() });
|
|
103
|
+
const allowedQueryParams = {
|
|
104
|
+
'/accounts/search': new Set(['q', 'phone', 'exactWebsite', 'page', 'pageSize']),
|
|
105
|
+
'/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']),
|
|
107
|
+
'/tasks/time-entries/search': new Set(['taskId', 'accountId', 'personId', 'type', 'q', 'dateFrom', 'dateTo', 'page', 'pageSize']),
|
|
108
|
+
'/tasks/search': new Set(['q', 'accountId', 'loggedForUserId', 'assignedToUserId', 'enteredByUserId', 'callType', 'priority', 'status', 'dateFrom', 'dateTo', 'page', 'pageSize']),
|
|
109
|
+
'/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']),
|
|
111
|
+
};
|
|
87
112
|
// --- Identity ---
|
|
88
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'));
|
|
89
114
|
// --- CRM: accounts ---
|
|
@@ -149,12 +174,14 @@ server.tool('task_list_time_entries', 'List time/incidental entries + totals for
|
|
|
149
174
|
personId: z.number().optional().describe('Filter by staff person who performed the work (TMActivity.TMA_CSCID).'),
|
|
150
175
|
type: z.enum(['time', 'incidentals', 'all']).optional().describe('Entry kind based on TMActivity.TMACost: time = TMACost 0, incidentals = TMACost non-zero.'),
|
|
151
176
|
}, async ({ taskId, personId, type }) => get(`/tasks/${taskId}/time-entries`, { personId, type }));
|
|
152
|
-
server.tool('task_search_time_entries', 'Search task activity/time and incidentals across tasks. Supports filtering by taskId, staff performer (TMActivity.TMA_CSCID), date range, and
|
|
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`.', {
|
|
153
178
|
taskId: z.number().optional().describe('Filter by task ID (TMActivity.TMA_TMTID).'),
|
|
179
|
+
accountId: z.number().optional().describe('Filter by customer/account/company (CSAID). Maps through TMTask.TMT_CSAID for the task the entry belongs to.'),
|
|
154
180
|
personId: z.number().optional().describe('Filter by staff person who performed the work (TMActivity.TMA_CSCID).'),
|
|
155
181
|
type: z.enum(['time', 'incidentals', 'all']).optional().describe('Entry kind based on TMActivity.TMACost: time = TMACost 0, incidentals = TMACost non-zero.'),
|
|
156
|
-
|
|
157
|
-
|
|
182
|
+
q: z.string().optional().describe('Partial text match against TMActivity.TMADescription and TMActivity.TMAInternal.'),
|
|
183
|
+
dateFrom: z.string().optional().describe('Activity date range start (TMActivity.TMADate), e.g. 2026-01-01. Use this exact parameter name, not fromDate.'),
|
|
184
|
+
dateTo: z.string().optional().describe('Activity date range end (TMActivity.TMADate). Use this exact parameter name, not toDate.'),
|
|
158
185
|
page: z.number().optional(),
|
|
159
186
|
pageSize: z.number().optional(),
|
|
160
187
|
}, async (args) => get('/tasks/time-entries/search', args));
|