From 421b8b6b4fe1321992662bb41cb67a5b928c3958 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 28 Oct 2025 18:08:19 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20prompt=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bots/bot_father.ts | 17 ++++++++--------- bots/instance/coffee_bot.ts | 10 +++++----- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/bots/bot_father.ts b/bots/bot_father.ts index ca6b0fc1d..cc721d671 100644 --- a/bots/bot_father.ts +++ b/bots/bot_father.ts @@ -4,15 +4,14 @@ export type WorkflowInput = { input_as_text: string }; export abstract class BotFather { protected readonly allowedMcpTools = [ - "search", - "create_post", - "reply_to_post", - "reply_to_comment", - "recent_posts", - "get_post", - "list_unread_messages", - "mark_notifications_read", - "create_post", + "search", // 用于搜索帖子、内容等 + "create_post", // 创建新帖子 + "reply_to_post", // 回复帖子 + "reply_to_comment", // 回复评论 + "recent_posts", // 获取最新帖子 + "get_post", // 获取特定帖子的详细信息 + "list_unread_messages", // 列出未读消息或通知 + "mark_notifications_read", // 标记通知为已读 ]; protected readonly openisleToken = (process.env.OPENISLE_TOKEN ?? "").trim(); diff --git a/bots/instance/coffee_bot.ts b/bots/instance/coffee_bot.ts index 79d43735b..6a7d454cf 100644 --- a/bots/instance/coffee_bot.ts +++ b/bots/instance/coffee_bot.ts @@ -24,19 +24,19 @@ class CoffeeBot extends BotFather { drawTime.setHours(23, 0, 0, 0); return ` -请立即在 https://www.open-isle.com 使用 create_post 发表一篇全新帖子,遵循以下要求: +请立即在 https://www.open-isle.com 使用 create_post 发表一篇帖子,遵循以下要求: 1. 标题固定为「大家星期${weekday}早安--抽一杯咖啡」。 2. 正文包含: - 亲切的早安问候; + - 标注“领奖请私聊站长 @[nagisa]”; + - 鼓励大家留言互动。 +3. 奖品信息 - 明确奖品写作“Coffee”; - 帖子类型必须为 LOTTERY; - 奖品图片链接:https://openisle-1307107697.cos.accelerate.myqcloud.com/dynamic_assert/0d6a9b33e9ca4fe5a90540187d3f9ecb.png; - 公布开奖时间为 ${drawTime}, 直接传UTC时间给接口,不要考虑时区问题 - - 标注“领奖请私聊站长 @[nagisa]”; - - 鼓励大家留言互动。 -3. 调用 create_post 时 categoryId 固定为 10,tagIds 设为 [36]。 + - categoryId 固定为 10,tagIds 设为 [36]。 4. 帖子语言使用简体中文。 -5. 完成后只输出“已发布咖啡抽奖贴”,不额外生成总结。 `.trim(); } } From 6990aa93ed743784fa52d2533127d1bda00cf9e4 Mon Sep 17 00:00:00 2001 From: Tim <135014430+nagisa77@users.noreply.github.com> Date: Tue, 28 Oct 2025 18:32:42 +0800 Subject: [PATCH 2/4] Integrate weather MCP into Coffee Bot --- bots/bot_father.ts | 27 ++++++++++++++++++++++++++- bots/instance/coffee_bot.ts | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bots/bot_father.ts b/bots/bot_father.ts index ca6b0fc1d..7180fe022 100644 --- a/bots/bot_father.ts +++ b/bots/bot_father.ts @@ -16,8 +16,10 @@ export abstract class BotFather { ]; protected readonly openisleToken = (process.env.OPENISLE_TOKEN ?? "").trim(); + protected readonly weatherToken = (process.env.APIFY_API_TOKEN ?? "").trim(); protected readonly mcp = this.createHostedMcpTool(); + protected readonly weatherMcp = this.createWeatherMcpTool(); protected readonly agent: Agent; constructor(protected readonly name: string) { @@ -33,10 +35,18 @@ export abstract class BotFather { : "🔓 OPENISLE_TOKEN not set; authenticated MCP tools may be unavailable." ); + console.log( + this.weatherToken + ? "☁️ APIFY_API_TOKEN detected; weather MCP server will be available." + : "🌥️ APIFY_API_TOKEN not set; weather updates will be unavailable." + ); + + const tools = this.weatherMcp ? [this.mcp, this.weatherMcp] : [this.mcp]; + this.agent = new Agent({ name: this.name, instructions: this.buildInstructions(), - tools: [this.mcp], + tools, model: "gpt-4o", modelSettings: { temperature: 0.7, @@ -84,6 +94,21 @@ export abstract class BotFather { }); } + private createWeatherMcpTool(): ReturnType | null { + if (!this.weatherToken) { + return null; + } + + return hostedMcpTool({ + serverLabel: "weather_mcp_server", + serverUrl: "https://jiri-spilka--weather-mcp-server.apify.actor/mcp", + requireApproval: "never", + headers: { + Authorization: `Bearer ${this.weatherToken}`, + }, + }); + } + protected getAdditionalInstructions(): string[] { return []; } diff --git a/bots/instance/coffee_bot.ts b/bots/instance/coffee_bot.ts index 79d43735b..47a71bae7 100644 --- a/bots/instance/coffee_bot.ts +++ b/bots/instance/coffee_bot.ts @@ -14,6 +14,7 @@ class CoffeeBot extends BotFather { "正文需亲切友好,简洁明了,鼓励社区成员互动。", "开奖说明需明确告知中奖者需私聊站长 @nagisa 领取奖励。", "确保只发布一个帖子,避免重复调用 create_post。", + "使用标签为 weather_mcp_server 的 MCP 工具获取北京、上海、广州、深圳当天的天气信息,并把结果写入早安问候之后。", ]; } @@ -28,6 +29,7 @@ class CoffeeBot extends BotFather { 1. 标题固定为「大家星期${weekday}早安--抽一杯咖啡」。 2. 正文包含: - 亲切的早安问候; + - 早安问候后立即列出北京、上海、广州、深圳当天的天气信息,每行格式为“城市:天气描述,最低温~最高温”;天气需调用 weather_mcp_server 获取; - 明确奖品写作“Coffee”; - 帖子类型必须为 LOTTERY; - 奖品图片链接:https://openisle-1307107697.cos.accelerate.myqcloud.com/dynamic_assert/0d6a9b33e9ca4fe5a90540187d3f9ecb.png; From 4c0b9e744a32c0b012b2262188a9ddbbc52fedfa Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 28 Oct 2025 18:39:58 +0800 Subject: [PATCH 3/4] feat: weather mcp --- bots/bot_father.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bots/bot_father.ts b/bots/bot_father.ts index dd666341e..65b7715f6 100644 --- a/bots/bot_father.ts +++ b/bots/bot_father.ts @@ -4,6 +4,7 @@ export type WorkflowInput = { input_as_text: string }; export abstract class BotFather { protected readonly allowedMcpTools = [ + // openisle MCP tools "search", // 用于搜索帖子、内容等 "create_post", // 创建新帖子 "reply_to_post", // 回复帖子 @@ -12,6 +13,9 @@ export abstract class BotFather { "get_post", // 获取特定帖子的详细信息 "list_unread_messages", // 列出未读消息或通知 "mark_notifications_read", // 标记通知为已读 + + // third-party MCP tools + "weather_mcp_server", // 天气 MCP 工具 ]; protected readonly openisleToken = (process.env.OPENISLE_TOKEN ?? "").trim(); @@ -40,12 +44,15 @@ export abstract class BotFather { : "🌥️ APIFY_API_TOKEN not set; weather updates will be unavailable." ); - const tools = this.weatherMcp ? [this.mcp, this.weatherMcp] : [this.mcp]; + let availableTools = [this.mcp]; + if (this.weatherMcp) { + availableTools.push(this.weatherMcp); + } this.agent = new Agent({ name: this.name, instructions: this.buildInstructions(), - tools, + tools: availableTools, model: "gpt-4o", modelSettings: { temperature: 0.7, From dbc3d54fa14152070926ed519fdc4ec4d83655f7 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 28 Oct 2025 18:42:47 +0800 Subject: [PATCH 4/4] fix: should add weather mcp --- bots/bot_father.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/bots/bot_father.ts b/bots/bot_father.ts index 65b7715f6..7c4f1d9ad 100644 --- a/bots/bot_father.ts +++ b/bots/bot_father.ts @@ -44,15 +44,10 @@ export abstract class BotFather { : "🌥️ APIFY_API_TOKEN not set; weather updates will be unavailable." ); - let availableTools = [this.mcp]; - if (this.weatherMcp) { - availableTools.push(this.weatherMcp); - } - this.agent = new Agent({ name: this.name, instructions: this.buildInstructions(), - tools: availableTools, + tools: [this.mcp, this.weatherMcp], model: "gpt-4o", modelSettings: { temperature: 0.7, @@ -100,17 +95,13 @@ export abstract class BotFather { }); } - private createWeatherMcpTool(): ReturnType | null { - if (!this.weatherToken) { - return null; - } - + private createWeatherMcpTool(): ReturnType { return hostedMcpTool({ serverLabel: "weather_mcp_server", serverUrl: "https://jiri-spilka--weather-mcp-server.apify.actor/mcp", requireApproval: "never", headers: { - Authorization: `Bearer ${this.weatherToken}`, + Authorization: `Bearer ${this.weatherToken || ""}`, }, }); }