@tb-eng/sendkit-mcp 0.0.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/dist/index.d.ts +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -0
- package/src/index.ts +68 -0
- package/tsconfig.build.json +14 -0
- package/tsdown.config.ts +16 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { sendTelegramMessage, telegramMessageInputSchema } from "@tb-eng/sendkit-core";
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
const token = process.env.TELEGRAM_BOT_TOKEN;
|
|
6
|
+
const server = new McpServer({
|
|
7
|
+
name: "Sendkit",
|
|
8
|
+
version: "1.0.0"
|
|
9
|
+
});
|
|
10
|
+
server.registerTool("telegram", {
|
|
11
|
+
description: "Send a message to telegram",
|
|
12
|
+
inputSchema: telegramMessageInputSchema.shape
|
|
13
|
+
}, async ({ chatId, message }) => {
|
|
14
|
+
if (!token) throw new Error("TELEGRAM_BOT_TOKEN is not set");
|
|
15
|
+
if (!chatId || !message) throw new Error("ChatId and message are required");
|
|
16
|
+
try {
|
|
17
|
+
const result = await sendTelegramMessage({
|
|
18
|
+
chatId,
|
|
19
|
+
botToken: token,
|
|
20
|
+
message
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
content: [{
|
|
24
|
+
type: "text",
|
|
25
|
+
text: `Message sent to telegram, messageId:${result.chatId} and chatId: ${result.messageId}`
|
|
26
|
+
}],
|
|
27
|
+
structuredContent: result
|
|
28
|
+
};
|
|
29
|
+
} catch (error) {
|
|
30
|
+
return { content: [{
|
|
31
|
+
type: "text",
|
|
32
|
+
text: `Failed to send message to telegram ${error instanceof Error ? error.message : String(error)}`
|
|
33
|
+
}] };
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
async function main() {
|
|
37
|
+
const transport = new StdioServerTransport();
|
|
38
|
+
await server.connect(transport);
|
|
39
|
+
console.error("Sendkit MCP Server running on stdio");
|
|
40
|
+
}
|
|
41
|
+
main().catch((error) => {
|
|
42
|
+
console.error("Fatal error in main():", error);
|
|
43
|
+
process.exit(1);
|
|
44
|
+
});
|
|
45
|
+
//#endregion
|
|
46
|
+
export {};
|
|
47
|
+
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n\nimport {\n\tsendTelegramMessage,\n\ttelegramMessageInputSchema,\n} from \"@tb-eng/sendkit-core\";\n\nconst token = process.env.TELEGRAM_BOT_TOKEN;\n\nconst server = new McpServer({\n\tname: \"Sendkit\",\n\tversion: \"1.0.0\",\n});\n\nserver.registerTool(\n\t\"telegram\",\n\t{\n\t\tdescription: \"Send a message to telegram\",\n\t\tinputSchema: telegramMessageInputSchema.shape,\n\t},\n\tasync ({ chatId, message }) => {\n\t\tif (!token) {\n\t\t\tthrow new Error(\"TELEGRAM_BOT_TOKEN is not set\");\n\t\t}\n\t\tif (!chatId || !message) {\n\t\t\tthrow new Error(\"ChatId and message are required\");\n\t\t}\n\t\ttry {\n\t\t\tconst result = await sendTelegramMessage({\n\t\t\t\tchatId,\n\t\t\t\tbotToken: token,\n\t\t\t\tmessage,\n\t\t\t});\n\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `Message sent to telegram, messageId:${result.chatId} and chatId: ${result.messageId}`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tstructuredContent: result,\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\",\n\t\t\t\t\t\ttext: `Failed to send message to telegram ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t},\n);\n\nasync function main() {\n\tconst transport = new StdioServerTransport();\n\tawait server.connect(transport);\n\n\tconsole.error(\"Sendkit MCP Server running on stdio\");\n}\n\nmain().catch((error) => {\n\tconsole.error(\"Fatal error in main():\", error);\n\tprocess.exit(1);\n});\n"],"mappings":";;;;AAQA,MAAM,QAAQ,QAAQ,IAAI;AAE1B,MAAM,SAAS,IAAI,UAAU;CAC5B,MAAM;CACN,SAAS;AACV,CAAC;AAED,OAAO,aACN,YACA;CACC,aAAa;CACb,aAAa,2BAA2B;AACzC,GACA,OAAO,EAAE,QAAQ,cAAc;CAC9B,IAAI,CAAC,OACJ,MAAM,IAAI,MAAM,+BAA+B;CAEhD,IAAI,CAAC,UAAU,CAAC,SACf,MAAM,IAAI,MAAM,iCAAiC;CAElD,IAAI;EACH,MAAM,SAAS,MAAM,oBAAoB;GACxC;GACA,UAAU;GACV;EACD,CAAC;EAED,OAAO;GACN,SAAS,CACR;IACC,MAAM;IACN,MAAM,uCAAuC,OAAO,OAAO,eAAe,OAAO;GAClF,CACD;GACA,mBAAmB;EACpB;CACD,SAAS,OAAO;EACf,OAAO,EACN,SAAS,CACR;GACC,MAAM;GACN,MAAM,sCAAsC,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAClG,CACD,EACD;CACD;AACD,CACD;AAEA,eAAe,OAAO;CACrB,MAAM,YAAY,IAAI,qBAAqB;CAC3C,MAAM,OAAO,QAAQ,SAAS;CAE9B,QAAQ,MAAM,qCAAqC;AACpD;AAEA,KAAK,CAAC,CAAC,OAAO,UAAU;CACvB,QAAQ,MAAM,0BAA0B,KAAK;CAC7C,QAAQ,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tb-eng/sendkit-mcp",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsdown",
|
|
7
|
+
"pack:dry": "bun run build && bun pm pack --dry-run",
|
|
8
|
+
"prepublishOnly": "bun run build"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
24
|
+
"@tb-eng/sendkit-core": "0.0.0",
|
|
25
|
+
"zod": "^4.4.3"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
sendTelegramMessage,
|
|
6
|
+
telegramMessageInputSchema,
|
|
7
|
+
} from "@tb-eng/sendkit-core";
|
|
8
|
+
|
|
9
|
+
const token = process.env.TELEGRAM_BOT_TOKEN;
|
|
10
|
+
|
|
11
|
+
const server = new McpServer({
|
|
12
|
+
name: "Sendkit",
|
|
13
|
+
version: "1.0.0",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
server.registerTool(
|
|
17
|
+
"telegram",
|
|
18
|
+
{
|
|
19
|
+
description: "Send a message to telegram",
|
|
20
|
+
inputSchema: telegramMessageInputSchema.shape,
|
|
21
|
+
},
|
|
22
|
+
async ({ chatId, message }) => {
|
|
23
|
+
if (!token) {
|
|
24
|
+
throw new Error("TELEGRAM_BOT_TOKEN is not set");
|
|
25
|
+
}
|
|
26
|
+
if (!chatId || !message) {
|
|
27
|
+
throw new Error("ChatId and message are required");
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const result = await sendTelegramMessage({
|
|
31
|
+
chatId,
|
|
32
|
+
botToken: token,
|
|
33
|
+
message,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
content: [
|
|
38
|
+
{
|
|
39
|
+
type: "text",
|
|
40
|
+
text: `Message sent to telegram, messageId:${result.chatId} and chatId: ${result.messageId}`,
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
structuredContent: result,
|
|
44
|
+
};
|
|
45
|
+
} catch (error) {
|
|
46
|
+
return {
|
|
47
|
+
content: [
|
|
48
|
+
{
|
|
49
|
+
type: "text",
|
|
50
|
+
text: `Failed to send message to telegram ${error instanceof Error ? error.message : String(error)}`,
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
async function main() {
|
|
59
|
+
const transport = new StdioServerTransport();
|
|
60
|
+
await server.connect(transport);
|
|
61
|
+
|
|
62
|
+
console.error("Sendkit MCP Server running on stdio");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main().catch((error) => {
|
|
66
|
+
console.error("Fatal error in main():", error);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"noEmit": false,
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"declarationMap": true,
|
|
7
|
+
"sourceMap": true,
|
|
8
|
+
"outDir": "dist",
|
|
9
|
+
"rootDir": "src",
|
|
10
|
+
"types": []
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*.ts"],
|
|
13
|
+
"exclude": ["dist", "node_modules"]
|
|
14
|
+
}
|
package/tsdown.config.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineConfig } from "tsdown";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: ["src/index.ts"],
|
|
5
|
+
format: ["esm"],
|
|
6
|
+
dts: true,
|
|
7
|
+
sourcemap: true,
|
|
8
|
+
clean: true,
|
|
9
|
+
platform: "node",
|
|
10
|
+
target: "node20",
|
|
11
|
+
outDir: "dist",
|
|
12
|
+
outExtensions: () => ({ js: ".js", dts: ".d.ts" }),
|
|
13
|
+
deps: {
|
|
14
|
+
neverBundle: ["@modelcontextprotocol/sdk","@tb-eng/sendkit-core","zod"],
|
|
15
|
+
},
|
|
16
|
+
});
|