nixflex-mcp 0.1.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/LICENSE +9 -0
- package/README.md +11 -0
- package/index.js +176 -0
- package/package.json +22 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nixflex Enterprises LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# nixflex-mcp
|
|
2
|
+
|
|
3
|
+
MCP server for the [Nixflex](https://nixflex.com) voice AI platform. Manage agents, calls, phone numbers and caller context from Claude Desktop, Cursor, VS Code or any MCP client.
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{ "mcpServers": { "nixflex": { "command": "npx", "args": ["-y", "nixflex-mcp"], "env": { "NIXFLEX_API_KEY": "nxf_xxx:nxfs_xxx" } } } }
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Or, with the Nixflex CLI installed: `nixflex mcp setup claude`.
|
|
10
|
+
|
|
11
|
+
Docs: https://docs.nixflex.com/mcp/overview
|
package/index.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ============================================
|
|
3
|
+
// nixflex-mcp - the Nixflex MCP server (stdio).
|
|
4
|
+
//
|
|
5
|
+
// Claude Desktop / Cursor / VS Code config:
|
|
6
|
+
// { "mcpServers": { "nixflex": { "command": "npx", "args": ["-y", "nixflex-mcp"],
|
|
7
|
+
// "env": { "NIXFLEX_API_KEY": "nxf_xxx:nxfs_xxx" } } } }
|
|
8
|
+
// or: nixflex mcp setup claude
|
|
9
|
+
//
|
|
10
|
+
// ONE DOOR: every tool is a call into the official `nixflex` SDK - the same code the CLI
|
|
11
|
+
// and the docs use, so a tool can never do something the API does not.
|
|
12
|
+
// STDIO RULE: never write to stdout. stdout IS the protocol. All logging goes to stderr.
|
|
13
|
+
// SAFETY: delete_* tools require confirm: true and return a preview otherwise. There is
|
|
14
|
+
// no delete_all. Nothing here can spend money without an explicit argument (create_call
|
|
15
|
+
// and send_sms are the only spending tools and both need every field spelled out).
|
|
16
|
+
// ============================================
|
|
17
|
+
import { McpServer } from '@modelcontextprotocol/server';
|
|
18
|
+
import { StdioServerTransport } from '@modelcontextprotocol/server/stdio';
|
|
19
|
+
import * as z from 'zod/v4';
|
|
20
|
+
import Nixflex, { NixflexError } from 'nixflex';
|
|
21
|
+
import { readFileSync } from 'node:fs';
|
|
22
|
+
import { homedir } from 'node:os';
|
|
23
|
+
import { join } from 'node:path';
|
|
24
|
+
|
|
25
|
+
const VERSION = '0.1.0';
|
|
26
|
+
const log = (...a) => process.stderr.write('[nixflex-mcp] ' + a.join(' ') + '\n');
|
|
27
|
+
|
|
28
|
+
// ---- key: env first, then the CLI's config file (so `nixflex login` is enough) ----
|
|
29
|
+
function resolveKey() {
|
|
30
|
+
if (process.env.NIXFLEX_API_KEY) return process.env.NIXFLEX_API_KEY;
|
|
31
|
+
try { return JSON.parse(readFileSync(join(homedir(), '.nixflex', 'config.json'), 'utf8')).api_key; } catch { return undefined; }
|
|
32
|
+
}
|
|
33
|
+
const key = resolveKey();
|
|
34
|
+
if (!key || !/^nxf_[a-z0-9]+:nxfs_[a-z0-9]+$/i.test(key)) {
|
|
35
|
+
log('No API key. Set NIXFLEX_API_KEY (nxf_xxx:nxfs_xxx) in the server env, or run `nixflex login`.');
|
|
36
|
+
process.exit(2);
|
|
37
|
+
}
|
|
38
|
+
const client = new Nixflex({ apiKey: key });
|
|
39
|
+
|
|
40
|
+
// ---- helpers ----
|
|
41
|
+
const text = (data) => ({ content: [{ type: 'text', text: typeof data === 'string' ? data : JSON.stringify(data, null, 2) }] });
|
|
42
|
+
const fail = (e) => {
|
|
43
|
+
const body = e instanceof NixflexError
|
|
44
|
+
? { error: { code: e.code, status: e.status, message: e.message, doc_url: e.docUrl } }
|
|
45
|
+
: { error: { message: String(e && e.message || e) } };
|
|
46
|
+
return { content: [{ type: 'text', text: JSON.stringify(body, null, 2) }], isError: true };
|
|
47
|
+
};
|
|
48
|
+
const run = (fn) => async (args) => { try { return text(await fn(args)); } catch (e) { return fail(e); } };
|
|
49
|
+
const E164 = z.string().regex(/^\+[1-9]\d{6,14}$/, 'E.164 number, e.g. +447700900123');
|
|
50
|
+
|
|
51
|
+
const server = new McpServer({ name: 'nixflex', version: VERSION });
|
|
52
|
+
|
|
53
|
+
// ---- agents ----
|
|
54
|
+
server.registerTool('list_agents', {
|
|
55
|
+
description: 'List the AI agents on this Nixflex account.',
|
|
56
|
+
inputSchema: z.object({ limit: z.number().int().min(1).max(100).optional() }),
|
|
57
|
+
}, run(({ limit }) => client.agents.list(limit ? { limit } : {})));
|
|
58
|
+
|
|
59
|
+
server.registerTool('get_agent', {
|
|
60
|
+
description: 'Get one agent by id, including its prompt and settings.',
|
|
61
|
+
inputSchema: z.object({ agent_id: z.string() }),
|
|
62
|
+
}, run(({ agent_id }) => client.agents.get(agent_id)));
|
|
63
|
+
|
|
64
|
+
server.registerTool('create_agent', {
|
|
65
|
+
description: 'Create an AI phone agent. system_prompt is the full instructions for the agent.',
|
|
66
|
+
inputSchema: z.object({
|
|
67
|
+
name: z.string(),
|
|
68
|
+
system_prompt: z.string(),
|
|
69
|
+
voice_id: z.string().optional().describe('A voice id such as Ashley or Craig'),
|
|
70
|
+
language: z.string().optional().describe('e.g. en, multi'),
|
|
71
|
+
incall_sms_enabled: z.boolean().optional().describe('Allow texting during calls (default false)'),
|
|
72
|
+
}),
|
|
73
|
+
}, run((args) => client.agents.create(args)));
|
|
74
|
+
|
|
75
|
+
server.registerTool('update_agent', {
|
|
76
|
+
description: 'Update an agent. Only the fields you pass are changed.',
|
|
77
|
+
inputSchema: z.object({
|
|
78
|
+
agent_id: z.string(),
|
|
79
|
+
name: z.string().optional(),
|
|
80
|
+
system_prompt: z.string().optional(),
|
|
81
|
+
voice_id: z.string().optional(),
|
|
82
|
+
language: z.string().optional(),
|
|
83
|
+
incall_sms_enabled: z.boolean().optional(),
|
|
84
|
+
}),
|
|
85
|
+
}, run(({ agent_id, ...rest }) => client.agents.update(agent_id, rest)));
|
|
86
|
+
|
|
87
|
+
server.registerTool('delete_agent', {
|
|
88
|
+
description: 'Delete an agent. Without confirm: true this only returns what would be deleted.',
|
|
89
|
+
inputSchema: z.object({ agent_id: z.string(), confirm: z.boolean().optional() }),
|
|
90
|
+
}, run(async ({ agent_id, confirm }) => {
|
|
91
|
+
if (!confirm) { const a = await client.agents.get(agent_id); return { would_delete: { agent_id, name: a.name }, hint: 'Call again with confirm: true to delete.' }; }
|
|
92
|
+
return client.agents.delete(agent_id);
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
// ---- calls ----
|
|
96
|
+
server.registerTool('create_call', {
|
|
97
|
+
description: 'Place an outbound phone call now. This spends account credit. prompt is what the agent should do on this call; variables fill {{placeholders}} in it.',
|
|
98
|
+
inputSchema: z.object({
|
|
99
|
+
agent_id: z.string(),
|
|
100
|
+
to_number: E164.describe('Who to call'),
|
|
101
|
+
prompt: z.string().describe('The purpose of this call, in full'),
|
|
102
|
+
from_number: E164.optional().describe('One of your numbers; defaults to the agent number'),
|
|
103
|
+
variables: z.record(z.string(), z.string()).optional(),
|
|
104
|
+
}),
|
|
105
|
+
}, run((args) => client.calls.create(args)));
|
|
106
|
+
|
|
107
|
+
server.registerTool('list_calls', {
|
|
108
|
+
description: 'Recent calls, newest first.',
|
|
109
|
+
inputSchema: z.object({ limit: z.number().int().min(1).max(100).optional(), agent_id: z.string().optional() }),
|
|
110
|
+
}, run(({ limit, agent_id }) => client.calls.list({ ...(limit ? { limit } : {}), ...(agent_id ? { agent_id } : {}) })));
|
|
111
|
+
|
|
112
|
+
server.registerTool('get_call', {
|
|
113
|
+
description: 'One call with transcript, analysis, bookings and recording URL.',
|
|
114
|
+
inputSchema: z.object({ call_id: z.string() }),
|
|
115
|
+
}, run(({ call_id }) => client.calls.get(call_id)));
|
|
116
|
+
|
|
117
|
+
// ---- numbers ----
|
|
118
|
+
server.registerTool('list_phone_numbers', {
|
|
119
|
+
description: 'Phone numbers on this account and which agent each one uses.',
|
|
120
|
+
inputSchema: z.object({ agent_id: z.string().optional() }),
|
|
121
|
+
}, run(({ agent_id }) => client.phoneNumbers.list(agent_id ? { agent_id } : {})));
|
|
122
|
+
|
|
123
|
+
// ---- caller context ----
|
|
124
|
+
server.registerTool('get_caller_context', {
|
|
125
|
+
description: 'What the agent knows about a caller on one of your numbers (name, email, location, reference, last call, open item). phone_number is YOUR number; caller_number is the customer.',
|
|
126
|
+
inputSchema: z.object({ phone_number: E164, caller_number: E164 }),
|
|
127
|
+
}, run(({ phone_number, caller_number }) => client.callers.get(phone_number, caller_number)));
|
|
128
|
+
|
|
129
|
+
server.registerTool('set_caller_context', {
|
|
130
|
+
description: 'Set what the agent should know about a caller on one of your numbers. Fields you omit are kept; pass null to remove one. last_call and open_item are engine-only.',
|
|
131
|
+
inputSchema: z.object({
|
|
132
|
+
phone_number: E164.describe('Your number'),
|
|
133
|
+
caller_number: E164.describe('The customer'),
|
|
134
|
+
name: z.string().nullable().optional().describe('Full name'),
|
|
135
|
+
email: z.string().nullable().optional(),
|
|
136
|
+
phone: z.string().nullable().optional(),
|
|
137
|
+
location: z.string().nullable().optional(),
|
|
138
|
+
reference_id: z.string().nullable().optional(),
|
|
139
|
+
preference: z.string().nullable().optional(),
|
|
140
|
+
}),
|
|
141
|
+
}, run(({ phone_number, caller_number, ...fields }) => client.callers.set(phone_number, caller_number, fields)));
|
|
142
|
+
|
|
143
|
+
server.registerTool('import_caller_context', {
|
|
144
|
+
description: 'Load up to 1,000 caller records onto one of your numbers in one go.',
|
|
145
|
+
inputSchema: z.object({
|
|
146
|
+
phone_number: E164.describe('Your number'),
|
|
147
|
+
callers: z.array(z.object({
|
|
148
|
+
caller_number: E164, name: z.string().optional(), email: z.string().optional(), phone: z.string().optional(),
|
|
149
|
+
location: z.string().optional(), reference_id: z.string().optional(), preference: z.string().optional(),
|
|
150
|
+
})).min(1).max(1000),
|
|
151
|
+
}),
|
|
152
|
+
}, run(({ phone_number, callers }) => client.callers.import(phone_number, callers)));
|
|
153
|
+
|
|
154
|
+
server.registerTool('delete_caller_context', {
|
|
155
|
+
description: 'Erase everything known about a caller on one of your numbers. Without confirm: true this only returns what would be deleted.',
|
|
156
|
+
inputSchema: z.object({ phone_number: E164, caller_number: E164, confirm: z.boolean().optional() }),
|
|
157
|
+
}, run(async ({ phone_number, caller_number, confirm }) => {
|
|
158
|
+
if (!confirm) { const r = await client.callers.get(phone_number, caller_number); return { would_delete: r.caller, hint: 'Call again with confirm: true to delete.' }; }
|
|
159
|
+
return client.callers.delete(phone_number, caller_number);
|
|
160
|
+
}));
|
|
161
|
+
|
|
162
|
+
// ---- sms + account ----
|
|
163
|
+
server.registerTool('send_sms', {
|
|
164
|
+
description: 'Send one text message from one of your numbers. This spends carrier credit.',
|
|
165
|
+
inputSchema: z.object({ agent_id: z.string(), from_number: E164, to: E164, message: z.string().max(600) }),
|
|
166
|
+
}, run((args) => client.sms.send(args)));
|
|
167
|
+
|
|
168
|
+
server.registerTool('get_usage', {
|
|
169
|
+
description: 'Usage and balance for this account.',
|
|
170
|
+
inputSchema: z.object({}),
|
|
171
|
+
}, run(() => client.usage.get()));
|
|
172
|
+
|
|
173
|
+
// ---- start ----
|
|
174
|
+
const transport = new StdioServerTransport();
|
|
175
|
+
await server.connect(transport);
|
|
176
|
+
log('ready - ' + key.split(':')[0]);
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "nixflex-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for the Nixflex voice AI platform - manage agents, calls, numbers and caller context from Claude Desktop, Cursor or any MCP client.",
|
|
5
|
+
"keywords": ["nixflex", "mcp", "model-context-protocol", "voice-ai", "phone", "claude"],
|
|
6
|
+
"homepage": "https://docs.nixflex.com/mcp/overview",
|
|
7
|
+
"repository": { "type": "git", "url": "git+https://github.com/nixflex/nixflex-mcp.git" },
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"bin": { "nixflex-mcp": "./index.js" },
|
|
11
|
+
"files": ["index.js", "README.md", "LICENSE"],
|
|
12
|
+
"engines": { "node": ">=18" },
|
|
13
|
+
"scripts": {
|
|
14
|
+
"check": "node --test tests/*.test.mjs",
|
|
15
|
+
"start": "node index.js"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@modelcontextprotocol/server": "^2.0.0",
|
|
19
|
+
"nixflex": "^0.7.0",
|
|
20
|
+
"zod": "^4.0.0"
|
|
21
|
+
}
|
|
22
|
+
}
|