A simple MCP (Model Context Protocol) server template that acts as middleware for a weather API. Built on Gadget.dev for serverless deployment.
When connected to an MCP client (like Claude Desktop or Cursor), you can ask for the weather at any location and the MCP server will fetch and return current conditions.
This is a simplified MCP server with no bells and whistles, intended for educational purposes.
- A free Gadget.dev account
- A free API key from Visual Crossing
- Go to gadget.new
- Select the ChatGPT app template
- Select "Yes, enable auth" option
- Click Continue
- Name your app (this can be changed later)
- Change the language from TypeScript (default) to JavaScript
Copy the mcp.js file from the /api/ folder in this repo and replace the mcp.js file in the /api/ folder in your Gadget app.
Alternatively, you can fork this entire app by using the Gadget CLI to sync your app's files locally and replace them with the files in this repo. This README doesn't cover all the steps for this approach.
- Go to Settings in your Gadget app
- Click Environment Variables
- Add a new variable named
WEATHER_API_KEY - Go to your Visual Crossing account page and copy your API key
- Paste the API key into the environment variable value field
- Click Save
Add this MCP server to your MCP client config (e.g., Claude Desktop, Cursor). Replace your-gadget-app-name with your actual Gadget app name:
{
"mcpServers": {
"weather-checker": {
"url": "https://your-gadget-app-name--development.gadget.app/mcp",
"transport": "http"
}
}
}Once connected, call the getCurrentWeather tool with a location:
"What's the weather in Victoria BC?"
The MCP server will return current conditions including temperature, humidity, wind speed, and more.
Gadget development environments are paused after 60 minutes of inactivity. To keep your MCP server always available, publish your app to production in Gadget.
- Add your environment variables in the production environment
- Update your MCP config URL by removing
--development:
{
"mcpServers": {
"weather-checker": {
"url": "https://your-gadget-app-name.gadget.app/mcp",
"transport": "http"
}
}
}Got questions? Reach out to @ralfelfving