MCP Weather Chat

Model Context Protocol (MCP) integration for interacting with external weather services.

Demonstrates capabilities:

  • MCP integration for external services
  • Weather API integration through protocol
  • Tool calling through MCP server
  • Extensible architecture for external data
  • MCP Integration: Model Context Protocol for external tools
  • Weather Service: Real-time weather data
  • Server Architecture: Separate MCP server
  • Tool Calling: Structured function calling for weather
  • Extensible Design: Easy addition of new services
  • Runtime: Bun
  • Language: TypeScript
  • AI Framework: agent-swarm-kit
  • Protocol: Model Context Protocol (MCP)
  • External APIs: Weather services
src/
├── config/
│ └── mcp.ts # MCP configuration
├── repl.ts # REPL interface
└── lib/
└── swarm.ts # Swarm configuration
server/
└── src/
└── index.ts # MCP server
# Install dependencies
bun install

# Start MCP server (terminal 1)
cd server && bun run src/index.ts

# Start client (terminal 2)
bun run src/repl.ts

Create a .env file:

WEATHER_API_KEY=your_weather_api_key
MCP_SERVER_URL=http://localhost:3001
OPENAI_API_KEY=your_openai_api_key
  1. Current weather: "What's the weather in Moscow?"
  2. Forecast: "Tomorrow's forecast for St. Petersburg"
  3. Comparison: "Compare weather in Moscow and London"
  4. Planning: "Should I take an umbrella in Sochi today?"
  • Standardized Protocol: Unified standard for external services
  • Type Safety: Structured data exchange
  • Extensibility: Easy addition of new tools
  • Isolation: Separate servers for different services

Excellent for:

  • Weather applications
  • Travel planning assistants
  • Outdoor activity recommendations
  • Agricultural advice systems
  • Event planning tools

MCP architecture allows adding:

  • News services
  • Stock market data
  • Translation services
  • Calendar integration
  • Maps and navigation