
mastra weather agent api
基于 Mastra 框架开发的天气信息获取代理工具,支持城市天气查询。
Repository Info
About This Server
基于 Mastra 框架开发的天气信息获取代理工具,支持城市天气查询。
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
Mastra Weather Agent
Bu proje, Mastra framework kullanarak geliştirilmiş bir hava durumu agent'idir. MCP Weather Server API'sini kullanarak şehirlerin hava durumu bilgilerini getirir.
🚀 Özellikler
- ☁️ Basit hava durumu sorgulama
- 📊 Detaylı hava durumu raporları
- 🌡️ Sıcaklık bazlı öneriler
- 🌍 Türkçe dil desteği
- 🤖 Mastra framework entegrasyonu
- 💬 Interactive CLI modu
📋 Gereksinimler
- Node.js (v16 veya üzeri)
- npm veya yarn
- TypeScript
🛠️ Kurulum
1. Projeyi klonlayın veya dosyaları oluşturun
mkdir mastra-weather-agent
cd mastra-weather-agent
2. Paket yöneticisini başlatın
npm init -y
3. Bağımlılıkları yükleyin
npm install @mastra/core dotenv
npm install -D @types/node typescript ts-node
4. TypeScript yapılandırmasını yapın
Yukarıdaki tsconfig.json dosyasını projenizin kök dizinine ekleyin.
5. Kaynak kodlarını oluşturun
mkdir -p src/agents
Daha sonra yukarıdaki dosyaları ilgili dizinlere yerleştirin:
src/agents/WeatherAgent.tssrc/index.ts
6. Environment dosyasını hazırlayın
cp .env.example .env
🚦 Çalıştırma
Geliştirme Modu
npm run dev
Build ve Çalıştırma
npm run build
npm start
Interactive Mod
npm run dev -- --interactive
# veya
npm run dev -- -i
📖 Kullanım Örnekleri
Programatik Kullanım
import WeatherAgent from './agents/WeatherAgent';
const weatherAgent = new WeatherAgent();
// Basit hava durumu
const weather = await weatherAgent.getWeather('Istanbul');
console.log(weather);
// Detaylı hava durumu
const detailedWeather = await weatherAgent.getDetailedWeather('Ankara');
console.log(detailedWeather);
CLI Kullanımı
Interactive modda çalıştırdığınızda:
🌤️ Interactive Weather Agent
💡 Şehir adı girin (çıkmak için "exit" yazın)
Şehir adı: Istanbul
🌤️ **Istanbul Hava Durumu:**
📍 Şehir: Istanbul
🌡️ Sıcaklık: 22°C
☁️ Durum: Partly cloudy
📅 Tarih: 28.05.2025
🏗️ Proje Yapısı
mastra-weather-agent/
├── src/
│ ├── agents/
│ │ └── WeatherAgent.ts # Ana weather agent sınıfı
│ └── index.ts # Ana uygulama dosyası
├── dist/ # Build çıktıları
├── .env.example # Environment variables örneği
├── .env # Environment variables (create this)
├── package.json # Proje bağımlılıkları
├── tsconfig.json # TypeScript konfigürasyonu
└── README.md # Bu dosya
🔧 Scripts
npm run build- TypeScript kodlarını JavaScript'e derlernpm run start- Build edilmiş uygulamayı çalıştırırnpm run dev- Geliştirme modunda çalıştırırnpm run clean- Build dosyalarını temizler
🌐 API Bilgileri
Bu proje MCP Weather Server API'sini kullanır:
- Base URL:
https://smithery.ai/server/@isdaniel/mcp_weather_server/ - Endpoint:
/weather?city={cityName} - Method: GET
- Response Format: JSON
🎯 Agent Yetenekleri
getWeather(city: string)
Belirtilen şehir için basit hava durumu bilgisi getirir.
getDetailedWeather(city: string)
Belirtilen şehir için detaylı hava durumu raporu oluşturur.
getInfo()
Agent hakkında bilgi verir.
🔧 Özelleştirme
Yeni Tool Ekleme
WeatherAgent.ts dosyasında tools objesine yeni araçlar ekleyebilirsiniz:
const tools = {
// Mevcut araçlar...
newTool: {
description: "Yeni aracın açıklaması",
parameters: {
// Parametreler...
},
execute: async (params) => {
// Aracın işlevi...
},
},
};
Model Değiştirme
Agent yapılandırmasında farklı bir model kullanabilirsiniz:
const config: AgentConfig = {
// Diğer ayarlar...
model: "gpt-4" as any, // veya başka bir model
};
🐛 Hata Ayıklama
Yaygın sorunlar ve çözümleri:
- API Erişim Hatası: İnternet bağlantınızı kontrol edin
- Şehir Bulunamadı: Şehir adını İngilizce veya Türkçe karakterlerle deneyin
- Build Hatası:
npm run cleançalıştırıp tekrar build edin
📄 Lisans
MIT License
🤝 Katkıda Bulunma
- Fork edin
- Feature branch oluşturun (
git checkout -b feature/amazing-feature) - Commit edin (
git commit -m 'Add amazing feature') - Push edin (
git push origin feature/amazing-feature) - Pull Request oluşturun
📞 İletişim
Sorularınız için GitHub Issues kullanabilirsiniz.
⭐ Bu projeyi beğendiyseniz yıldız vermeyi unutmayın!
Quick Start
Clone the repository
git clone https://github.com/seheremir/mastra-weather-agent-apiInstall dependencies
cd mastra-weather-agent-api
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.