@teamnetwork-nz/teamlink-mcp-server 0.2.0 → 0.3.0
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 +20 -9
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -15,6 +15,12 @@ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
|
|
|
15
15
|
*/
|
|
16
16
|
const API_BASE = (process.env.TEAMLINK_API_BASE ?? 'http://localhost:3100').replace(/\/$/, '');
|
|
17
17
|
const API_KEY = process.env.TEAMLINK_API_KEY ?? '';
|
|
18
|
+
/**
|
|
19
|
+
* Write-tool gate. Defaults to false (non-destructive/read-only) so this server
|
|
20
|
+
* is safe to point at production unless explicitly opted in. Accepts common
|
|
21
|
+
* truthy strings; anything else (including unset) is treated as false.
|
|
22
|
+
*/
|
|
23
|
+
const READWRITE = /^(1|true|yes|on)$/i.test(process.env.TEAMLINK_READWRITE ?? '');
|
|
18
24
|
const http = axios.create({
|
|
19
25
|
baseURL: API_BASE,
|
|
20
26
|
timeout: 20_000,
|
|
@@ -76,18 +82,22 @@ server.tool('crm_list_accounts', 'List/filter accounts.', {
|
|
|
76
82
|
}, async (args) => get('/accounts', args));
|
|
77
83
|
server.tool('crm_get_account', 'Get one account by id.', { accountId: z.number() }, async ({ accountId }) => get(`/accounts/${accountId}`));
|
|
78
84
|
server.tool('crm_list_account_contacts', 'List active contacts linked to an account.', { accountId: z.number() }, async ({ accountId }) => get(`/accounts/${accountId}/contacts`));
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
if (READWRITE) {
|
|
86
|
+
server.tool('crm_create_account', 'Create an account. Returns duplicate-candidate warnings unless createAnyway=true.', {
|
|
87
|
+
name: z.string(), alphaId: z.string().optional(), website: z.string().optional(), phone: z.string().optional(),
|
|
88
|
+
isCustomer: z.boolean().optional(), isProspect: z.boolean().optional(), createAnyway: z.boolean().optional(),
|
|
89
|
+
}, async (args) => post('/accounts', args));
|
|
90
|
+
}
|
|
83
91
|
// --- CRM: contacts ---
|
|
84
92
|
server.tool('crm_search_contacts', 'Search contacts by name/email/phone.', { q: z.string().optional(), accountId: z.number().optional(), email: z.string().optional(), page: z.number().optional(), pageSize: z.number().optional() }, async (args) => get('/contacts/search', args));
|
|
85
93
|
server.tool('crm_get_contact', 'Get one contact by id.', { contactId: z.number() }, async ({ contactId }) => get(`/contacts/${contactId}`));
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
if (READWRITE) {
|
|
95
|
+
server.tool('crm_create_contact', 'Create a contact under an account (also creates the active account link).', {
|
|
96
|
+
accountId: z.number(), firstName: z.string(), lastName: z.string(), email: z.string(),
|
|
97
|
+
mobile: z.string().optional(), businessPhone: z.string().optional(), role: z.string().optional(),
|
|
98
|
+
}, async ({ accountId, ...body }) => post(`/accounts/${accountId}/contacts`, body));
|
|
99
|
+
server.tool('crm_update_contact', 'Update a contact. Password only applied if supplied.', { contactId: z.number(), firstName: z.string(), lastName: z.string(), email: z.string(), mobile: z.string().optional(), role: z.string().optional(), active: z.boolean().optional() }, async ({ contactId, ...body }) => put(`/contacts/${contactId}`, body));
|
|
100
|
+
}
|
|
91
101
|
// --- Lookups ---
|
|
92
102
|
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)}`));
|
|
93
103
|
server.tool('lookup_branches', 'List branches.', {}, async () => get('/lookups/branches'));
|
|
@@ -102,6 +112,7 @@ async function main() {
|
|
|
102
112
|
if (!API_KEY) {
|
|
103
113
|
console.error('[teamlink-mcp] WARNING: TEAMLINK_API_KEY is not set; all tool calls will fail until it is configured.');
|
|
104
114
|
}
|
|
115
|
+
console.error(`[teamlink-mcp] mode: ${READWRITE ? 'READ-WRITE (write tools enabled)' : 'read-only (set TEAMLINK_READWRITE=true to enable write tools)'}`);
|
|
105
116
|
const transport = new StdioServerTransport();
|
|
106
117
|
await server.connect(transport);
|
|
107
118
|
console.error(`[teamlink-mcp] connected (stdio), proxying ${API_BASE}`);
|