@fonoster/mcp 0.9.48 → 0.9.49
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/README.md +11 -3
- package/dist/index.js +0 -4
- package/dist/prompts/createCallPrompt.js +32 -8
- package/dist/schemas.d.ts +23 -1
- package/dist/schemas.js +11 -2
- package/dist/tools/createCreateCall.js +2 -1
- package/dist/tools/createCreateCallBatch.d.ts +32 -0
- package/dist/tools/createCreateCallBatch.js +109 -0
- package/dist/tools/index.js +2 -3
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -28,15 +28,23 @@ MCP Server for the Fonoster API, enabling MCP clients to interact with Fonoster'
|
|
|
28
28
|
- `app_ref` (string): The reference to the application to use for the call
|
|
29
29
|
- Returns: Call creation confirmation with reference ID
|
|
30
30
|
|
|
31
|
+
4. `create_call_batch`
|
|
32
|
+
- Creates a batch of calls from Fonoster
|
|
33
|
+
- Required inputs:
|
|
34
|
+
- `from` (string): The number to call from
|
|
35
|
+
- `to_array` (array): The numbers to call to
|
|
36
|
+
- `app_ref` (string): The reference to the application to use for the call
|
|
37
|
+
- Returns: Batch creation confirmation with reference ID
|
|
38
|
+
|
|
31
39
|
## Prompts
|
|
32
40
|
|
|
33
41
|
1. `create_call_prompt`
|
|
34
42
|
- A prompt for creating a call step by step
|
|
35
43
|
- Guides Claude through the process of:
|
|
36
|
-
- Asking the user for the number to call
|
|
44
|
+
- Asking the user for the number or numbers to call if not already provided
|
|
37
45
|
- Offering a list of available numbers using the `list_numbers` tool
|
|
38
46
|
- Asking for the application name and finding its reference
|
|
39
|
-
- Creating a call using the `create_call` tool
|
|
47
|
+
- Creating a call using the `create_call` or `create_call_batch` tool depending on the user's request
|
|
40
48
|
|
|
41
49
|
## Setup
|
|
42
50
|
|
|
@@ -101,7 +109,7 @@ WORKSPACE_ACCESS_KEY_ID="your-workspace-access-key-id" \
|
|
|
101
109
|
APIKEY_ACCESS_KEY_ID="your-apikey-access-key-id" \
|
|
102
110
|
APIKEY_ACCESS_KEY_SECRET="your-apikey-access-key_secret" \
|
|
103
111
|
npx @modelcontextprotocol/inspector \
|
|
104
|
-
node /
|
|
112
|
+
node /path/to/fonoster/mods/mcp/dist/index.js
|
|
105
113
|
```
|
|
106
114
|
|
|
107
115
|
### Troubleshooting
|
package/dist/index.js
CHANGED
|
@@ -30,12 +30,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
30
30
|
*/
|
|
31
31
|
const fs_1 = require("fs");
|
|
32
32
|
const path_1 = require("path");
|
|
33
|
-
const logger_1 = require("@fonoster/logger");
|
|
34
33
|
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
35
34
|
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
36
35
|
const index_1 = require("./prompts/index");
|
|
37
36
|
const index_2 = require("./tools/index");
|
|
38
|
-
const logger = (0, logger_1.getLogger)({ service: "mcp", filePath: __filename });
|
|
39
37
|
function main() {
|
|
40
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
39
|
// Read package.json using fs module
|
|
@@ -51,10 +49,8 @@ function main() {
|
|
|
51
49
|
yield (0, index_2.registerTools)(server);
|
|
52
50
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
53
51
|
yield server.connect(transport);
|
|
54
|
-
logger.info("Fonoster MCP Server running on stdio");
|
|
55
52
|
});
|
|
56
53
|
}
|
|
57
54
|
main().catch((error) => {
|
|
58
|
-
logger.error("Error starting MCP server:", error);
|
|
59
55
|
process.exit(1);
|
|
60
56
|
});
|
|
@@ -45,17 +45,17 @@ function createCallPrompt() {
|
|
|
45
45
|
You are a call originator that can create calls to Fonoster.
|
|
46
46
|
|
|
47
47
|
## Capabilities:
|
|
48
|
-
- You can list numbers from Fonoster by using the 'listNumbers' tool
|
|
49
|
-
- You can list applications from Fonoster by using the 'listApplications' tool
|
|
50
|
-
- You can create a call to Fonoster by using the 'createCall' tool
|
|
48
|
+
- You can list numbers from Fonoster by using the 'listNumbers' tool
|
|
49
|
+
- You can list applications from Fonoster by using the 'listApplications' tool
|
|
50
|
+
- You can create a call to Fonoster by using the 'createCall' or 'createCallBatch' tool
|
|
51
51
|
|
|
52
52
|
## Steps:
|
|
53
|
-
1. Ask the user for the number to call if not already provided
|
|
54
|
-
2. Offer the user a list of numbers to use for the call using the 'listNumbers' tool
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
1. Ask the user for the number or numbers to call if not already provided
|
|
54
|
+
2. Offer the user a list of numbers to use for the call using the 'listNumbers' tool
|
|
55
|
+
3. Then ask for the name of application and use that to find the 'ref' of the application
|
|
56
|
+
4. Create a call to the selected application using the 'createCall' or 'createCallBatch' tool depending on the user's request
|
|
57
57
|
|
|
58
|
-
## Example:
|
|
58
|
+
## Example 1:
|
|
59
59
|
User: I want to call +1234567890
|
|
60
60
|
Assistant: Here are some numbers you can use:
|
|
61
61
|
|
|
@@ -72,6 +72,30 @@ function createCallPrompt() {
|
|
|
72
72
|
|
|
73
73
|
User: That's the one. Please create the call.
|
|
74
74
|
Assistant: Call created with REF: 586d7421-542f-49cc-b1ed-dc65378da01a
|
|
75
|
+
|
|
76
|
+
## Example 2:
|
|
77
|
+
User: I want to call all the numbers on my list
|
|
78
|
+
Assistant: Great, which numbers do you want to call? Here are the numbers you can use:
|
|
79
|
+
- +1234567890
|
|
80
|
+
- +1234567891
|
|
81
|
+
- +1234567892
|
|
82
|
+
|
|
83
|
+
User: I want to use the numbers +1234567890
|
|
84
|
+
Assistant: Perfect, I will use the numbers +1234567890 for the call. Which application do you want to use? I see you have 3 applications available.
|
|
85
|
+
- My App
|
|
86
|
+
- My App 2
|
|
87
|
+
- My App 3
|
|
88
|
+
|
|
89
|
+
User: I want to use the application called "My App"
|
|
90
|
+
Assistant: Perfect, I will use "My App" for the call. Can you provide the list of numbers you want to call?
|
|
91
|
+
|
|
92
|
+
User: Here are the numbers:
|
|
93
|
+
- +1234567890
|
|
94
|
+
- +1234567891
|
|
95
|
+
- +1234567892
|
|
96
|
+
|
|
97
|
+
Assistant: Batch of 3 calls from +1234567890 initiated with ID: 1716604800000.
|
|
98
|
+
Calls are being processed asynchronously at a rate of 10 calls per minute.
|
|
75
99
|
`
|
|
76
100
|
}
|
|
77
101
|
}
|
package/dist/schemas.d.ts
CHANGED
|
@@ -41,13 +41,35 @@ declare const CreateCallSchema: z.ZodObject<{
|
|
|
41
41
|
from: z.ZodString;
|
|
42
42
|
to: z.ZodString;
|
|
43
43
|
app_ref: z.ZodString;
|
|
44
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
44
45
|
}, "strip", z.ZodTypeAny, {
|
|
45
46
|
from?: string;
|
|
46
47
|
to?: string;
|
|
47
48
|
app_ref?: string;
|
|
49
|
+
timeout?: number;
|
|
48
50
|
}, {
|
|
49
51
|
from?: string;
|
|
50
52
|
to?: string;
|
|
51
53
|
app_ref?: string;
|
|
54
|
+
timeout?: number;
|
|
52
55
|
}>;
|
|
53
|
-
|
|
56
|
+
declare const CreateCallBatchSchema: z.ZodObject<{
|
|
57
|
+
from: z.ZodString;
|
|
58
|
+
to_array: z.ZodArray<z.ZodString, "many">;
|
|
59
|
+
app_ref: z.ZodString;
|
|
60
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
calls_per_minute: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
from?: string;
|
|
64
|
+
app_ref?: string;
|
|
65
|
+
timeout?: number;
|
|
66
|
+
to_array?: string[];
|
|
67
|
+
calls_per_minute?: number;
|
|
68
|
+
}, {
|
|
69
|
+
from?: string;
|
|
70
|
+
app_ref?: string;
|
|
71
|
+
timeout?: number;
|
|
72
|
+
to_array?: string[];
|
|
73
|
+
calls_per_minute?: number;
|
|
74
|
+
}>;
|
|
75
|
+
export { ListApplicationsSchema, CreateCallSchema, ListNumbersSchema, CreateCallBatchSchema };
|
package/dist/schemas.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ListNumbersSchema = exports.CreateCallSchema = exports.ListApplicationsSchema = void 0;
|
|
3
|
+
exports.CreateCallBatchSchema = exports.ListNumbersSchema = exports.CreateCallSchema = exports.ListApplicationsSchema = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
6
6
|
* http://github.com/fonoster/fonoster
|
|
@@ -33,6 +33,15 @@ exports.ListNumbersSchema = ListNumbersSchema;
|
|
|
33
33
|
const CreateCallSchema = zod_1.z.object({
|
|
34
34
|
from: zod_1.z.string().describe("The phone number to call from"),
|
|
35
35
|
to: zod_1.z.string().describe("The phone number to call to"),
|
|
36
|
-
app_ref: zod_1.z.string().describe("The application reference to use for the call")
|
|
36
|
+
app_ref: zod_1.z.string().describe("The application reference to use for the call"),
|
|
37
|
+
timeout: zod_1.z.number().optional().describe("The timeout for the call")
|
|
37
38
|
});
|
|
38
39
|
exports.CreateCallSchema = CreateCallSchema;
|
|
40
|
+
const CreateCallBatchSchema = zod_1.z.object({
|
|
41
|
+
from: zod_1.z.string().min(1),
|
|
42
|
+
to_array: zod_1.z.array(zod_1.z.string().min(1)).min(1),
|
|
43
|
+
app_ref: zod_1.z.string().min(1),
|
|
44
|
+
timeout: zod_1.z.number().optional(),
|
|
45
|
+
calls_per_minute: zod_1.z.number().min(1).max(60).optional().default(20)
|
|
46
|
+
});
|
|
47
|
+
exports.CreateCallBatchSchema = CreateCallBatchSchema;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
import * as SDK from "@fonoster/sdk";
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
import { CreateCallBatchSchema } from "../schemas";
|
|
22
|
+
/**
|
|
23
|
+
* Creates multiple calls from Fonoster in a batch with the same from number and application
|
|
24
|
+
* @param client The Fonoster client
|
|
25
|
+
* @returns A function that creates multiple calls in a batch
|
|
26
|
+
*/
|
|
27
|
+
export declare function createCreateCallBatch(client: SDK.Client): (params: z.infer<typeof CreateCallBatchSchema>) => Promise<{
|
|
28
|
+
content: {
|
|
29
|
+
type: "text";
|
|
30
|
+
text: string;
|
|
31
|
+
}[];
|
|
32
|
+
}>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.createCreateCallBatch = createCreateCallBatch;
|
|
46
|
+
/**
|
|
47
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
48
|
+
* http://github.com/fonoster/fonoster
|
|
49
|
+
*
|
|
50
|
+
* This file is part of Fonoster
|
|
51
|
+
*
|
|
52
|
+
* Licensed under the MIT License (the "License");
|
|
53
|
+
* you may not use this file except in compliance with
|
|
54
|
+
* the License. You may obtain a copy of the License at
|
|
55
|
+
*
|
|
56
|
+
* https://opensource.org/licenses/MIT
|
|
57
|
+
*
|
|
58
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
59
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
60
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
61
|
+
* See the License for the specific language governing permissions and
|
|
62
|
+
* limitations under the License.
|
|
63
|
+
*/
|
|
64
|
+
const SDK = __importStar(require("@fonoster/sdk"));
|
|
65
|
+
const schemas_1 = require("../schemas");
|
|
66
|
+
/**
|
|
67
|
+
* Creates multiple calls from Fonoster in a batch with the same from number and application
|
|
68
|
+
* @param client The Fonoster client
|
|
69
|
+
* @returns A function that creates multiple calls in a batch
|
|
70
|
+
*/
|
|
71
|
+
function createCreateCallBatch(client) {
|
|
72
|
+
return function createCallBatch(params) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const calls = new SDK.Calls(client);
|
|
75
|
+
const validatedParams = schemas_1.CreateCallBatchSchema.parse(params);
|
|
76
|
+
const { from, to_array, app_ref, timeout, calls_per_minute } = validatedParams;
|
|
77
|
+
const batchId = Date.now().toString();
|
|
78
|
+
const createSingleCall = (to) => calls.createCall({
|
|
79
|
+
from,
|
|
80
|
+
to,
|
|
81
|
+
appRef: app_ref,
|
|
82
|
+
timeout
|
|
83
|
+
});
|
|
84
|
+
const delayBetweenCalls = Math.ceil(60000 / calls_per_minute);
|
|
85
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
86
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
87
|
+
const destinations = [...to_array];
|
|
88
|
+
while (destinations.length > 0) {
|
|
89
|
+
const to = destinations.shift();
|
|
90
|
+
createSingleCall(to).catch((error) => {
|
|
91
|
+
console.error(`Failed to create call to ${to}: ${error.message}`);
|
|
92
|
+
});
|
|
93
|
+
if (destinations.length > 0) {
|
|
94
|
+
yield delay(delayBetweenCalls);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}))();
|
|
98
|
+
return {
|
|
99
|
+
content: [
|
|
100
|
+
{
|
|
101
|
+
type: "text",
|
|
102
|
+
text: `Batch of ${to_array.length} calls from ${from} initiated with ID: ${batchId}. ` +
|
|
103
|
+
`Calls are being processed asynchronously at a rate of ${calls_per_minute} calls per minute.`
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
}
|
package/dist/tools/index.js
CHANGED
|
@@ -13,6 +13,7 @@ exports.registerTools = registerTools;
|
|
|
13
13
|
const schemas_1 = require("../schemas");
|
|
14
14
|
const createClient_1 = require("../utils/createClient");
|
|
15
15
|
const createCreateCall_1 = require("./createCreateCall");
|
|
16
|
+
const createCreateCallBatch_1 = require("./createCreateCallBatch");
|
|
16
17
|
const createListApplications_1 = require("./createListApplications");
|
|
17
18
|
const createListNumbers_1 = require("./createListNumbers");
|
|
18
19
|
/**
|
|
@@ -23,11 +24,9 @@ const createListNumbers_1 = require("./createListNumbers");
|
|
|
23
24
|
function registerTools(server) {
|
|
24
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
26
|
const client = yield (0, createClient_1.createClient)();
|
|
26
|
-
// Register the listNumbers tool
|
|
27
27
|
server.tool("list_numbers", "Returns a list of numbers from Fonoster in a table format (using markdown)", schemas_1.ListNumbersSchema.shape, (0, createListNumbers_1.createListNumbers)(client));
|
|
28
|
-
// Register the listApplications tool
|
|
29
28
|
server.tool("list_applications", "Lists applications from Fonoster in a table format (using markdown)", schemas_1.ListApplicationsSchema.shape, (0, createListApplications_1.createListApplications)(client));
|
|
30
|
-
// Register the createCall tool
|
|
31
29
|
server.tool("create_call", "Creates a call from Fonoster", schemas_1.CreateCallSchema.shape, (0, createCreateCall_1.createCreateCall)(client));
|
|
30
|
+
server.tool("create_call_batch", "Creates a batch of calls from Fonoster", schemas_1.CreateCallBatchSchema.shape, (0, createCreateCallBatch_1.createCreateCallBatch)(client));
|
|
32
31
|
});
|
|
33
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/mcp",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.49",
|
|
4
4
|
"description": "Model Context Protocol for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"prebuild": "rimraf ./dist tsconfig.tsbuildinfo",
|
|
19
19
|
"build": "tsc -b tsconfig.json",
|
|
20
|
+
"postbuild": "chmod +x ./dist/index.js",
|
|
20
21
|
"clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@fonoster/common": "^0.9.
|
|
24
|
-
"@fonoster/logger": "^0.9.
|
|
25
|
-
"@fonoster/sdk": "^0.9.
|
|
24
|
+
"@fonoster/common": "^0.9.49",
|
|
25
|
+
"@fonoster/logger": "^0.9.49",
|
|
26
|
+
"@fonoster/sdk": "^0.9.49",
|
|
26
27
|
"@modelcontextprotocol/sdk": "^1.4.0"
|
|
27
28
|
},
|
|
28
29
|
"files": [
|
|
@@ -38,5 +39,5 @@
|
|
|
38
39
|
"bugs": {
|
|
39
40
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
40
41
|
},
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "8f176f86f5ed02c7e8d87e275d14e6b34fa116bd"
|
|
42
43
|
}
|