@teamnetwork-nz/teamlink-mcp-server 0.5.8 → 0.6.1
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/dist/env.js +7 -0
- package/dist/http-server.js +83 -0
- package/{build → dist}/index.js +67 -24
- package/dist/index.js.map +1 -0
- package/package.json +12 -9
package/dist/env.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export function parsePositiveInt(name, raw, fallback, maximum) {
|
|
2
|
+
const value = raw === undefined || raw === '' ? fallback : Number(raw);
|
|
3
|
+
if (!Number.isSafeInteger(value) || value < 1 || value > maximum) {
|
|
4
|
+
throw new Error(`${name} must be a positive integer no greater than ${maximum}`);
|
|
5
|
+
}
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { timingSafeEqual } from "node:crypto";
|
|
2
|
+
import http from "node:http";
|
|
3
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
4
|
+
const loopback = new Set(["127.0.0.1", "::1", "localhost"]);
|
|
5
|
+
const send = (res, status, body) => {
|
|
6
|
+
res.writeHead(status, { "Content-Type": "application/json" }).end(JSON.stringify(body));
|
|
7
|
+
};
|
|
8
|
+
const error = (res, status, code, message) => send(res, status, { jsonrpc: "2.0", error: { code, message }, id: null });
|
|
9
|
+
const matches = (value, expected) => {
|
|
10
|
+
if (!value?.startsWith("Bearer "))
|
|
11
|
+
return false;
|
|
12
|
+
const supplied = Buffer.from(value.slice(7));
|
|
13
|
+
const wanted = Buffer.from(expected);
|
|
14
|
+
return supplied.length === wanted.length && timingSafeEqual(supplied, wanted);
|
|
15
|
+
};
|
|
16
|
+
const readBody = (req, limit) => new Promise((resolve, reject) => {
|
|
17
|
+
const chunks = [];
|
|
18
|
+
let size = 0;
|
|
19
|
+
let oversized = false;
|
|
20
|
+
req.on("data", (chunk) => { size += chunk.length; oversized ||= size > limit; if (!oversized)
|
|
21
|
+
chunks.push(chunk); });
|
|
22
|
+
req.on("end", () => {
|
|
23
|
+
if (oversized)
|
|
24
|
+
return reject(Object.assign(new Error("Request body too large"), { statusCode: 413 }));
|
|
25
|
+
try {
|
|
26
|
+
resolve(JSON.parse(Buffer.concat(chunks).toString("utf8")));
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
reject(Object.assign(new Error("Invalid JSON body"), { statusCode: 400 }));
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
req.on("error", reject);
|
|
33
|
+
});
|
|
34
|
+
export function validateHttpOptions(o) {
|
|
35
|
+
if (!Number.isInteger(o.port) || o.port < 1 || o.port > 65535)
|
|
36
|
+
throw new Error(`Invalid HTTP port: ${o.port}`);
|
|
37
|
+
if (o.maxBodyBytes !== undefined && (!Number.isInteger(o.maxBodyBytes) || o.maxBodyBytes < 1))
|
|
38
|
+
throw new Error(`Invalid HTTP body limit: ${o.maxBodyBytes}`);
|
|
39
|
+
if (!loopback.has(o.host) && !o.bearerToken)
|
|
40
|
+
throw new Error("A bearer token is required when binding beyond loopback");
|
|
41
|
+
if (!loopback.has(o.host) && !o.allowedHosts?.length)
|
|
42
|
+
throw new Error("HTTP_ALLOWED_HOSTS is required when binding beyond loopback");
|
|
43
|
+
}
|
|
44
|
+
export function createHttpServer(factory, o) {
|
|
45
|
+
validateHttpOptions(o);
|
|
46
|
+
const hosts = new Set(o.allowedHosts?.map(v => v.toLowerCase()));
|
|
47
|
+
const origins = new Set(o.allowedOrigins?.map(v => v.toLowerCase()));
|
|
48
|
+
return http.createServer(async (req, res) => {
|
|
49
|
+
const path = new URL(req.url ?? "/", "http://localhost").pathname;
|
|
50
|
+
if (path === "/health")
|
|
51
|
+
return send(res, 200, { status: "ok", server: o.serverName });
|
|
52
|
+
if (path !== "/mcp")
|
|
53
|
+
return void res.writeHead(404).end();
|
|
54
|
+
if (hosts.size && !hosts.has((req.headers.host ?? "").toLowerCase()))
|
|
55
|
+
return error(res, 403, -32000, "Host not allowed");
|
|
56
|
+
if (req.headers.origin && !origins.has(req.headers.origin.toLowerCase()))
|
|
57
|
+
return error(res, 403, -32000, "Origin not allowed");
|
|
58
|
+
if (o.bearerToken && !matches(req.headers.authorization, o.bearerToken)) {
|
|
59
|
+
res.setHeader("WWW-Authenticate", "Bearer");
|
|
60
|
+
return error(res, 401, -32001, "Unauthorized");
|
|
61
|
+
}
|
|
62
|
+
if (req.method !== "POST") {
|
|
63
|
+
res.setHeader("Allow", "POST");
|
|
64
|
+
return error(res, 405, -32000, "Method not allowed");
|
|
65
|
+
}
|
|
66
|
+
const server = factory();
|
|
67
|
+
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
|
|
68
|
+
try {
|
|
69
|
+
const body = await readBody(req, o.maxBodyBytes ?? 1048576);
|
|
70
|
+
await server.connect(transport);
|
|
71
|
+
await transport.handleRequest(req, res, body);
|
|
72
|
+
res.once("close", () => { void transport.close(); void server.close(); });
|
|
73
|
+
}
|
|
74
|
+
catch (cause) {
|
|
75
|
+
void transport.close();
|
|
76
|
+
void server.close();
|
|
77
|
+
if (!res.headersSent) {
|
|
78
|
+
const status = cause.statusCode ?? 500;
|
|
79
|
+
error(res, status, status === 400 ? -32700 : -32603, status < 500 ? cause.message : "Internal server error");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
package/{build → dist}/index.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import 'dotenv
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
3
|
import { readFileSync } from 'node:fs';
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { dirname, join } from 'node:path';
|
|
@@ -7,6 +7,9 @@ import axios from 'axios';
|
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
9
9
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
10
|
+
import { createHttpServer } from './http-server.js';
|
|
11
|
+
import { parsePositiveInt } from './env.js';
|
|
12
|
+
dotenv.config({ quiet: true });
|
|
10
13
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
14
|
function pkgVersion() {
|
|
12
15
|
try {
|
|
@@ -25,14 +28,24 @@ function pkgVersion() {
|
|
|
25
28
|
* - TEAMLINK_API_BASE (default http://localhost:3100)
|
|
26
29
|
* - TEAMLINK_API_KEY the staff-allocated CSCApiKey used for all calls
|
|
27
30
|
*/
|
|
28
|
-
const
|
|
29
|
-
|
|
31
|
+
export const TeamlinkConfigSchema = z.object({
|
|
32
|
+
apiBase: z.string().url(),
|
|
33
|
+
apiKey: z.string().min(1, 'TEAMLINK_API_KEY is required'),
|
|
34
|
+
readWrite: z.boolean(),
|
|
35
|
+
}).strict();
|
|
30
36
|
/**
|
|
31
37
|
* Write-tool gate. Defaults to false (non-destructive/read-only) so this server
|
|
32
38
|
* is safe to point at production unless explicitly opted in. Accepts common
|
|
33
|
-
*
|
|
39
|
+
* only the case-insensitive value "true" enables writes.
|
|
34
40
|
*/
|
|
35
|
-
const
|
|
41
|
+
const teamlinkConfig = TeamlinkConfigSchema.parse({
|
|
42
|
+
apiBase: (process.env.TEAMLINK_API_BASE ?? 'http://localhost:3100').replace(/\/$/, ''),
|
|
43
|
+
apiKey: process.env.TEAMLINK_API_KEY ?? '',
|
|
44
|
+
readWrite: (process.env.TEAMLINK_READWRITE ?? '').toLowerCase() === 'true',
|
|
45
|
+
});
|
|
46
|
+
const API_BASE = teamlinkConfig.apiBase;
|
|
47
|
+
const API_KEY = teamlinkConfig.apiKey;
|
|
48
|
+
const READWRITE = teamlinkConfig.readWrite;
|
|
36
49
|
const http = axios.create({
|
|
37
50
|
baseURL: API_BASE,
|
|
38
51
|
timeout: 20_000,
|
|
@@ -82,6 +95,8 @@ async function get(path, params) {
|
|
|
82
95
|
}
|
|
83
96
|
}
|
|
84
97
|
async function post(path, body) {
|
|
98
|
+
if (!READWRITE)
|
|
99
|
+
return usageError('Write operations are disabled. Set TEAMLINK_READWRITE=true to enable them.');
|
|
85
100
|
try {
|
|
86
101
|
const r = await http.post(path, body);
|
|
87
102
|
return ok(r.data);
|
|
@@ -91,6 +106,8 @@ async function post(path, body) {
|
|
|
91
106
|
}
|
|
92
107
|
}
|
|
93
108
|
async function put(path, body) {
|
|
109
|
+
if (!READWRITE)
|
|
110
|
+
return usageError('Write operations are disabled. Set TEAMLINK_READWRITE=true to enable them.');
|
|
94
111
|
try {
|
|
95
112
|
const r = await http.put(path, body);
|
|
96
113
|
return ok(r.data);
|
|
@@ -99,12 +116,14 @@ async function put(path, body) {
|
|
|
99
116
|
return fail(e);
|
|
100
117
|
}
|
|
101
118
|
}
|
|
102
|
-
const
|
|
119
|
+
const registrations = [];
|
|
103
120
|
function strictTool(name, description, inputSchema, callback) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
121
|
+
registrations.push((server) => {
|
|
122
|
+
server.registerTool(name, {
|
|
123
|
+
description,
|
|
124
|
+
inputSchema: z.object(inputSchema).strict(),
|
|
125
|
+
}, callback);
|
|
126
|
+
});
|
|
108
127
|
}
|
|
109
128
|
const allowedQueryParams = {
|
|
110
129
|
'/accounts/search': new Set([
|
|
@@ -117,7 +136,7 @@ const allowedQueryParams = {
|
|
|
117
136
|
'mode', 'q', 'cscId', 'contactId', 'firstName', 'lastName', 'fullName', 'shortName',
|
|
118
137
|
'csaId', 'accountId', 'email', 'mobile', 'businessPhone', 'isActive', 'role', 'page', 'pageSize',
|
|
119
138
|
]),
|
|
120
|
-
'/tasks/time-entries/search': new Set(['taskId', 'accountId', 'personId', 'type', 'q', 'dateFrom', 'dateTo', 'page', 'pageSize']),
|
|
139
|
+
'/tasks/time-entries/search': new Set(['taskId', 'accountId', 'personId', 'type', 'q', 'dateFrom', 'dateTo', 'page', 'pageSize', 'includeCrm']),
|
|
121
140
|
'/tasks/search': new Set(['q', 'accountId', 'loggedForUserId', 'assignedToUserId', 'enteredByUserId', 'callType', 'priority', 'status', 'dateFrom', 'dateTo', 'page', 'pageSize']),
|
|
122
141
|
'/crm/activities/search': new Set(['q', 'accountId', 'assignedToUserId', 'targetContactId', 'enteredByUserId', 'completed', 'dateDueFrom', 'dateDueTo', 'page', 'pageSize']),
|
|
123
142
|
'/crm/activities/time-entries/search': new Set(['activityId', 'accountId', 'personId', 'q', 'dateFrom', 'dateTo', 'page', 'pageSize']),
|
|
@@ -191,14 +210,23 @@ strictTool('crm_search_contacts', 'Search contacts. `cscId` is canonical for CSC
|
|
|
191
210
|
role: z.string().optional().describe(roleDescription),
|
|
192
211
|
page: z.number().optional(), pageSize: z.number().optional(),
|
|
193
212
|
}, async (args) => get('/contacts/search', args));
|
|
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}`));
|
|
213
|
+
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. If the calling key is Admin-scoped, the response also includes `password` (CSCPassword, the legacy plaintext web-app password) — omitted entirely for every other role; not returned by crm_search_contacts.', { contactId: z.number() }, async ({ contactId }) => get(`/contacts/${contactId}`));
|
|
195
214
|
if (READWRITE) {
|
|
196
|
-
strictTool('crm_create_contact', 'Create a contact under an account (also creates the active account link).'
|
|
215
|
+
strictTool('crm_create_contact', 'Create a contact under an account (also creates the active account link). Role is gated by a staff ' +
|
|
216
|
+
'hierarchy (A > M > E > {S,T,P} > C): the calling key\'s own role must outrank the role being assigned, ' +
|
|
217
|
+
'or the call 403s (role_hierarchy_violation) — Admin keys are unrestricted, everyone else can only assign ' +
|
|
218
|
+
'a role strictly below their own tier (no same-tier assignment either, e.g. an Engineer key cannot create ' +
|
|
219
|
+
'another Engineer contact).', {
|
|
197
220
|
accountId: z.number(), firstName: z.string(), lastName: z.string(), email: z.string(),
|
|
198
221
|
mobile: z.string().optional(), businessPhone: z.string().optional(),
|
|
199
222
|
role: z.string().optional().describe(roleDescription + ' Only settable for branch accounts; forced to C otherwise.'),
|
|
200
223
|
}, async ({ accountId, ...body }) => post(`/accounts/${accountId}/contacts`, body));
|
|
201
|
-
strictTool('crm_update_contact', 'Update a contact.
|
|
224
|
+
strictTool('crm_update_contact', 'Update a contact. `active` sets CSPivotContactAccount.CSPCA_Active for the account context (the legacy ' +
|
|
225
|
+
'CSCActive column is never written). Both the contact\'s CURRENT role and the role being set to are gated ' +
|
|
226
|
+
'by the same staff hierarchy as crm_create_contact (A > M > E > {S,T,P} > C, Admin unrestricted) — the call ' +
|
|
227
|
+
'403s (role_hierarchy_violation) if the calling key cannot manage either one. Password is not settable via ' +
|
|
228
|
+
'this tool (not exposed in this schema); the REST API additionally caps password writes to Admin-outranks-target ' +
|
|
229
|
+
'and enforces 8-15 chars with upper/lower/digit.', {
|
|
202
230
|
contactId: z.number(), firstName: z.string(), lastName: z.string(), email: z.string(), mobile: z.string().optional(),
|
|
203
231
|
role: z.string().optional().describe(roleDescription),
|
|
204
232
|
active: z.boolean().optional().describe('Sets CSPCA_Active (pivot) for the account context, not CSCActive.'),
|
|
@@ -237,19 +265,20 @@ strictTool('crm_activity_search_time_entries', 'Search CRM sales activity time e
|
|
|
237
265
|
}, async (args) => get('/crm/activities/time-entries/search', args));
|
|
238
266
|
// --- Tasks / time (read) ---
|
|
239
267
|
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).', {
|
|
268
|
+
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). Response `totals` (and each row) split chargeable/OT hours into a normal figure plus a `chargeableHoursBranch`/`otHoursBranch` (and per-row `isBranch`) subtotal when the task\'s account is branch-flagged (CSAccount.CSABranch=\'Y\'): that work is productive but never billed, so it\'s reported separately from the billable total rather than folded into it.', {
|
|
241
269
|
taskId: z.number().describe('Task ID (TMTask.TMTID / TMActivity.TMA_TMTID).'),
|
|
242
270
|
personId: z.number().optional().describe('Filter by staff person who performed the work (TMActivity.TMA_CSCID).'),
|
|
243
271
|
type: z.enum(['time', 'incidentals', 'all']).optional().describe('Entry kind based on TMActivity.TMACost: time = TMACost 0, incidentals = TMACost non-zero.'),
|
|
244
272
|
}, async ({ taskId, personId, type }) => get(`/tasks/${taskId}/time-entries`, { personId, type }));
|
|
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`.', {
|
|
246
|
-
taskId: z.number().optional().describe('Filter by task ID (TMActivity.TMA_TMTID).'),
|
|
247
|
-
accountId: z.number().optional().describe('Filter by customer/account/company (CSAID). Maps through TMTask.TMT_CSAID for the task the entry belongs to.'),
|
|
273
|
+
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`. Set `includeCrm=true` (ignored if `taskId` is given) to additionally union in CRM sales-activity time (TMAType=A) sorted into the same date-ordered result, matching what the mobile Time tab and Home screen show as one merged "my time" view — those CRM rows carry `sourceType: "crmActivity"` and an `activityId` instead of a `taskId`. Response `totals` (and each row) split chargeable/OT hours into a normal figure plus a `chargeableHoursBranch`/`otHoursBranch` (and per-row `isBranch`) subtotal: hours logged against a branch-flagged account (CSAccount.CSABranch=\'Y\') are productive but never billed, so it is reported separately rather than folded into the billable total. CRM rows never carry a branch flag (always fall into the non-branch bucket).', {
|
|
274
|
+
taskId: z.number().optional().describe('Filter by task ID (TMActivity.TMA_TMTID). When set, includeCrm is ignored (a task has no CRM equivalent).'),
|
|
275
|
+
accountId: z.number().optional().describe('Filter by customer/account/company (CSAID). Maps through TMTask.TMT_CSAID for the task the entry belongs to (or CRMActivity.CRMA_CSAID for CRM rows when includeCrm=true).'),
|
|
248
276
|
personId: z.number().optional().describe('Filter by staff person who performed the work (TMActivity.TMA_CSCID).'),
|
|
249
277
|
type: z.enum(['time', 'incidentals', 'all']).optional().describe('Entry kind based on TMActivity.TMACost: time = TMACost 0, incidentals = TMACost non-zero.'),
|
|
250
278
|
q: z.string().optional().describe('Partial text match against TMActivity.TMADescription and TMActivity.TMAInternal.'),
|
|
251
279
|
dateFrom: z.string().optional().describe('Activity date range start (TMActivity.TMADate), e.g. 2026-01-01. Use this exact parameter name, not fromDate.'),
|
|
252
280
|
dateTo: z.string().optional().describe('Activity date range end (TMActivity.TMADate). Use this exact parameter name, not toDate.'),
|
|
281
|
+
includeCrm: z.boolean().optional().describe('Also include CRM sales-activity time entries (TMAType=A) in the results and totals, merged and sorted alongside task time. Ignored when taskId is set. Defaults to false (task time only).'),
|
|
253
282
|
page: z.number().optional(),
|
|
254
283
|
pageSize: z.number().optional(),
|
|
255
284
|
}, async (args) => get('/tasks/time-entries/search', args));
|
|
@@ -299,16 +328,30 @@ strictTool('product_search', 'Search the read-only product catalog. `q` splits o
|
|
|
299
328
|
inStock: z.boolean().optional().describe('true = PMPOnHand > 0; false = no stock on hand.'),
|
|
300
329
|
page: z.number().optional(), pageSize: z.number().optional(),
|
|
301
330
|
}, async (args) => get('/orders/products/search', args));
|
|
331
|
+
function createConfiguredServer() {
|
|
332
|
+
const server = new McpServer({ name: '@teamnetwork-nz/teamlink-mcp-server', version: pkgVersion() }, {
|
|
333
|
+
instructions: 'TEAMlink business operations MCP server supporting stdio and HTTP. Read-only by default; mutation tools are available only when TEAMLINK_READWRITE=true. Use the most specific search filters available and treat customer, order, invoice, and credential data as sensitive.',
|
|
334
|
+
});
|
|
335
|
+
for (const register of registrations)
|
|
336
|
+
register(server);
|
|
337
|
+
return server;
|
|
338
|
+
}
|
|
302
339
|
async function main() {
|
|
303
340
|
if (!API_KEY) {
|
|
304
|
-
|
|
341
|
+
process.stderr.write('[teamlink-mcp] WARNING: TEAMLINK_API_KEY is not set; all tool calls will fail until it is configured.\n');
|
|
342
|
+
}
|
|
343
|
+
process.stderr.write(`[teamlink-mcp] mode: ${READWRITE ? 'READ-WRITE (write tools enabled)' : 'read-only (set TEAMLINK_READWRITE=true to enable write tools)'}\n`);
|
|
344
|
+
if ((process.env.TEAMLINK_TRANSPORT ?? 'stdio') === 'http') {
|
|
345
|
+
const host = process.env.TEAMLINK_HTTP_HOST ?? '127.0.0.1';
|
|
346
|
+
const port = parsePositiveInt('TEAMLINK_HTTP_PORT', process.env.TEAMLINK_HTTP_PORT, 3000, 65535);
|
|
347
|
+
createHttpServer(createConfiguredServer, { host, port, serverName: '@teamnetwork-nz/teamlink-mcp-server', bearerToken: process.env.TEAMLINK_HTTP_BEARER_TOKEN, allowedHosts: process.env.TEAMLINK_HTTP_ALLOWED_HOSTS?.split(',').map(v => v.trim()).filter(Boolean), allowedOrigins: process.env.TEAMLINK_HTTP_ALLOWED_ORIGINS?.split(',').map(v => v.trim()).filter(Boolean), maxBodyBytes: parsePositiveInt('TEAMLINK_HTTP_MAX_BODY_BYTES', process.env.TEAMLINK_HTTP_MAX_BODY_BYTES, 1_048_576, 16_777_216) }).listen(port, host, () => process.stderr.write(`[teamlink-mcp] connected (http ${host}:${port}/mcp), proxying ${API_BASE}\n`));
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
await createConfiguredServer().connect(new StdioServerTransport());
|
|
351
|
+
process.stderr.write(`[teamlink-mcp] connected (stdio), proxying ${API_BASE}\n`);
|
|
305
352
|
}
|
|
306
|
-
console.error(`[teamlink-mcp] mode: ${READWRITE ? 'READ-WRITE (write tools enabled)' : 'read-only (set TEAMLINK_READWRITE=true to enable write tools)'}`);
|
|
307
|
-
const transport = new StdioServerTransport();
|
|
308
|
-
await server.connect(transport);
|
|
309
|
-
console.error(`[teamlink-mcp] connected (stdio), proxying ${API_BASE}`);
|
|
310
353
|
}
|
|
311
354
|
main().catch((e) => {
|
|
312
|
-
|
|
355
|
+
process.stderr.write(`[teamlink-mcp] fatal: ${e instanceof Error ? e.stack ?? e.message : String(e)}\n`);
|
|
313
356
|
process.exit(1);
|
|
314
357
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,yBAAuB;AACvB,sDAA8B;AAC9B,gDAAwB;AACxB,kDAA0B;AAC1B,+BAAoC;AAEpC,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;AACtB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,MAAM,CAAC;AACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,uBAAuB,CAAC;AAE1E,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,GAAE,CAAC,CAAC;AAChB,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,EAAE,CAAC,CAAC;AAExB,cAAc;AACd,MAAM,UAAU,GAA4C,EAAE,CAAC;AAE/D,GAAG,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IAClC,GAAG,CAAC,GAAG,CAAC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,GAAG,IAAA,SAAM,GAAE,CAAC;QAC/B,cAAc,CAAC,qBAAqB,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,IAAI,SAAS,EAAE,CAAC,CAAC;QAC3F,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,wBAAwB,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,IAAI,IAAI,EAAE,CAAC,CAAC;IAC3F,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;AAEpF,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE;IAC5B,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,oBAAoB,QAAQ,EAAE,CAAC,CAAC;AAClF,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamnetwork-nz/teamlink-mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
6
|
-
"main": "
|
|
5
|
+
"description": "MCP server exposing TEAMlink REST API tools over stdio and Streamable HTTP",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"bin": {
|
|
9
|
-
"teamlink-mcp-server": "
|
|
9
|
+
"teamlink-mcp-server": "dist/index.js"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"
|
|
12
|
+
"dist"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "tsc",
|
|
16
|
-
"
|
|
16
|
+
"test": "npm run build && node --test tests/*.test.mjs",
|
|
17
|
+
"start": "node dist/index.js",
|
|
18
|
+
"dev": "tsc --watch",
|
|
19
|
+
"typecheck": "tsc --noEmit"
|
|
17
20
|
},
|
|
18
21
|
"dependencies": {
|
|
19
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
20
23
|
"axios": "^1.4.0",
|
|
21
24
|
"dotenv": "^16.0.3",
|
|
22
|
-
"zod": "^
|
|
25
|
+
"zod": "^3.25.0"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
28
|
"@types/node": "^20.4.2",
|
|
26
29
|
"typescript": "^5.9.3"
|
|
27
30
|
},
|
|
28
31
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
32
|
+
"node": ">=20"
|
|
30
33
|
}
|
|
31
34
|
}
|