fix: should add weather mcp

This commit is contained in:
Tim
2025-10-28 18:42:47 +08:00
parent 4c0b9e744a
commit dbc3d54fa1

View File

@@ -44,15 +44,10 @@ export abstract class BotFather {
: "🌥️ APIFY_API_TOKEN not set; weather updates will be unavailable." : "🌥️ 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({ this.agent = new Agent({
name: this.name, name: this.name,
instructions: this.buildInstructions(), instructions: this.buildInstructions(),
tools: availableTools, tools: [this.mcp, this.weatherMcp],
model: "gpt-4o", model: "gpt-4o",
modelSettings: { modelSettings: {
temperature: 0.7, temperature: 0.7,
@@ -100,17 +95,13 @@ export abstract class BotFather {
}); });
} }
private createWeatherMcpTool(): ReturnType<typeof hostedMcpTool> | null { private createWeatherMcpTool(): ReturnType<typeof hostedMcpTool> {
if (!this.weatherToken) {
return null;
}
return hostedMcpTool({ return hostedMcpTool({
serverLabel: "weather_mcp_server", serverLabel: "weather_mcp_server",
serverUrl: "https://jiri-spilka--weather-mcp-server.apify.actor/mcp", serverUrl: "https://jiri-spilka--weather-mcp-server.apify.actor/mcp",
requireApproval: "never", requireApproval: "never",
headers: { headers: {
Authorization: `Bearer ${this.weatherToken}`, Authorization: `Bearer ${this.weatherToken || ""}`,
}, },
}); });
} }