send-to-poke-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 +21 -0
- package/README.md +72 -0
- package/bin/send-to-poke-mcp +2 -0
- package/dist/index.js +123 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Konark Mangudkar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# send-to-poke-mcp
|
|
2
|
+
|
|
3
|
+
Minimal MCP server for sending messages to Poke via the inbound webhook.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- Single MCP tool: `send_to_poke`
|
|
7
|
+
- Sends a message to Poke using the inbound webhook
|
|
8
|
+
- Structured tool output with normalized response
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
- Node.js >= 18
|
|
12
|
+
- `POKE_API_KEY` environment variable
|
|
13
|
+
|
|
14
|
+
## MCP client config
|
|
15
|
+
Add the following config to your MCP client:
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"mcpServers": {
|
|
19
|
+
"send-to-poke": {
|
|
20
|
+
"command": "npx",
|
|
21
|
+
"args": ["-y", "send-to-poke-mcp"],
|
|
22
|
+
"env": {
|
|
23
|
+
"POKE_API_KEY": "your-api-key-here"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Local development
|
|
31
|
+
```bash
|
|
32
|
+
npm install
|
|
33
|
+
npm run build
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Smoke test (optional)
|
|
37
|
+
```bash
|
|
38
|
+
POKE_API_KEY=your-api-key-here npm run build
|
|
39
|
+
POKE_API_KEY=your-api-key-here npm run smoke-test
|
|
40
|
+
```
|
|
41
|
+
Note: this test requires network access and may fail in restricted environments.
|
|
42
|
+
|
|
43
|
+
## MCP Tool
|
|
44
|
+
### `send_to_poke`
|
|
45
|
+
Send a message to Poke.
|
|
46
|
+
|
|
47
|
+
**Input**
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"message": "string",
|
|
51
|
+
"include_raw_response": false
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Output**
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"status": "sent",
|
|
59
|
+
"http_status": 200,
|
|
60
|
+
"response": {},
|
|
61
|
+
"raw_response": ""
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Environment Variables
|
|
66
|
+
- `POKE_API_KEY` (required)
|
|
67
|
+
- `POKE_BASE_URL` (default: `https://poke.com`)
|
|
68
|
+
- `POKE_TIMEOUT` (default: `30000`)
|
|
69
|
+
|
|
70
|
+
## Notes
|
|
71
|
+
- Tool responses are returned as MCP `structuredContent` (with a text fallback for display).
|
|
72
|
+
- This project is not affiliated with Interaction Co.
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
const DEFAULT_BASE_URL = "https://poke.com";
|
|
5
|
+
const DEFAULT_TIMEOUT_MS = 30000;
|
|
6
|
+
const SendToPokeInputBaseSchema = z.object({
|
|
7
|
+
message: z.string().min(1).describe("Message to send to Poke"),
|
|
8
|
+
include_raw_response: z
|
|
9
|
+
.boolean()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe("Include raw response text for debugging"),
|
|
12
|
+
});
|
|
13
|
+
const SendToPokeInputSchema = SendToPokeInputBaseSchema.superRefine((data, ctx) => {
|
|
14
|
+
if (data.message.trim().length === 0) {
|
|
15
|
+
ctx.addIssue({
|
|
16
|
+
code: z.ZodIssueCode.custom,
|
|
17
|
+
message: "message cannot be empty",
|
|
18
|
+
path: ["message"],
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const SendToPokeOutputSchema = z.object({
|
|
23
|
+
status: z.literal("sent"),
|
|
24
|
+
http_status: z.number(),
|
|
25
|
+
response: z.unknown(),
|
|
26
|
+
raw_response: z.string().optional(),
|
|
27
|
+
});
|
|
28
|
+
async function fetchWithTimeout(url, options, timeoutMs) {
|
|
29
|
+
const controller = new AbortController();
|
|
30
|
+
const timeoutId = setTimeout(() => controller.abort(), timeoutMs);
|
|
31
|
+
try {
|
|
32
|
+
const response = await fetch(url, { ...options, signal: controller.signal });
|
|
33
|
+
const text = await response.text();
|
|
34
|
+
return { response, text };
|
|
35
|
+
}
|
|
36
|
+
finally {
|
|
37
|
+
clearTimeout(timeoutId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const server = new McpServer({
|
|
41
|
+
name: "send-to-poke-mcp",
|
|
42
|
+
version: "0.1.0",
|
|
43
|
+
});
|
|
44
|
+
server.registerTool("send_to_poke", {
|
|
45
|
+
title: "Send to Poke",
|
|
46
|
+
description: "Send a message to Poke using the inbound webhook.",
|
|
47
|
+
inputSchema: SendToPokeInputBaseSchema,
|
|
48
|
+
outputSchema: SendToPokeOutputSchema,
|
|
49
|
+
annotations: {
|
|
50
|
+
readOnlyHint: false,
|
|
51
|
+
idempotentHint: false,
|
|
52
|
+
openWorldHint: true,
|
|
53
|
+
},
|
|
54
|
+
}, async (args) => {
|
|
55
|
+
try {
|
|
56
|
+
const parsedArgs = SendToPokeInputSchema.parse(args);
|
|
57
|
+
const apiKey = process.env.POKE_API_KEY;
|
|
58
|
+
if (!apiKey) {
|
|
59
|
+
throw new Error("POKE_API_KEY is required");
|
|
60
|
+
}
|
|
61
|
+
const baseUrl = process.env.POKE_BASE_URL ?? DEFAULT_BASE_URL;
|
|
62
|
+
const timeoutMs = Number.parseInt(process.env.POKE_TIMEOUT ?? String(DEFAULT_TIMEOUT_MS), 10);
|
|
63
|
+
const message = parsedArgs.message.trim();
|
|
64
|
+
const url = `${baseUrl}/api/v1/inbound-sms/webhook`;
|
|
65
|
+
const { response, text } = await fetchWithTimeout(url, {
|
|
66
|
+
method: "POST",
|
|
67
|
+
headers: {
|
|
68
|
+
Authorization: `Bearer ${apiKey}`,
|
|
69
|
+
"Content-Type": "application/json",
|
|
70
|
+
},
|
|
71
|
+
body: JSON.stringify({ message }),
|
|
72
|
+
}, timeoutMs);
|
|
73
|
+
if (!response.ok) {
|
|
74
|
+
throw new Error(`Poke API error ${response.status}: ${text}`);
|
|
75
|
+
}
|
|
76
|
+
let parsedBody = text;
|
|
77
|
+
if (text) {
|
|
78
|
+
try {
|
|
79
|
+
parsedBody = JSON.parse(text);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
parsedBody = text;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const payload = {
|
|
86
|
+
status: "sent",
|
|
87
|
+
http_status: response.status,
|
|
88
|
+
response: parsedBody,
|
|
89
|
+
...(parsedArgs.include_raw_response ? { raw_response: text } : {}),
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
structuredContent: payload,
|
|
93
|
+
content: [
|
|
94
|
+
{
|
|
95
|
+
type: "text",
|
|
96
|
+
text: JSON.stringify(payload, null, 2),
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
103
|
+
console.error("send_to_poke failed", message);
|
|
104
|
+
return {
|
|
105
|
+
content: [
|
|
106
|
+
{
|
|
107
|
+
type: "text",
|
|
108
|
+
text: JSON.stringify({ error: message, status: "failed" }, null, 2),
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
isError: true,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
async function main() {
|
|
116
|
+
const transport = new StdioServerTransport();
|
|
117
|
+
await server.connect(transport);
|
|
118
|
+
console.error("send-to-poke-mcp running on stdio");
|
|
119
|
+
}
|
|
120
|
+
main().catch((error) => {
|
|
121
|
+
console.error("Fatal error", error);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "send-to-poke-mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "MCP server for sending messages to Poke via webhook",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/konarkm/send-to-poke-mcp.git"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/konarkm/send-to-poke-mcp#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/konarkm/send-to-poke-mcp/issues"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"send-to-poke-mcp": "bin/send-to-poke-mcp"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"bin"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc -p tsconfig.json",
|
|
24
|
+
"dev": "tsx src/index.ts",
|
|
25
|
+
"prepublishOnly": "npm run build",
|
|
26
|
+
"smoke-test": "tsx scripts/smoke-test.ts",
|
|
27
|
+
"start": "node dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"mcp",
|
|
31
|
+
"mcp-server",
|
|
32
|
+
"poke",
|
|
33
|
+
"webhook",
|
|
34
|
+
"messaging"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@modelcontextprotocol/sdk": "^1.18.2",
|
|
38
|
+
"zod": "^3.23.8"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^22.12.0",
|
|
42
|
+
"tsx": "^4.19.2",
|
|
43
|
+
"typescript": "^5.7.3"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18"
|
|
47
|
+
}
|
|
48
|
+
}
|