Handles environment configuration for the MCP server, managing settings like API URLs and model selection.
Provides source control integration for cloning and managing the MCP server codebase.
Hosts the MCP server repository for distribution and collaboration.
Uses Node.js as the runtime environment for the MCP server, with v18+ required for operation.
Manages dependencies and provides scripts for running, testing, and diagnosing the MCP server.
Leverages Ollama's LLM capabilities to provide weather information through a 'get-weather' tool that retrieves weather data for any city.
Implements the MCP server using TypeScript for type-safe code organization and structure.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Weather MCP Serverwhat's the forecast for Tokyo tomorrow?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐ฆ๏ธ Weather MCP Server Demo
A Model Context Protocol (MCP) compatible server that provides weather information using Ollama's LLM capabilities. This server exposes a get-weather tool that can be used by MCP clients to retrieve weather information for any city.
๐ Prerequisites
Node.js v18+
Ollama installed and running locally
Ollama model:
llama3(or configure your preferred model)
Related MCP server: OpenWeatherMap MCP Server
๐ Complete Setup & Installation
โ Step 1: Clone and Install
git clone https://github.com/codewith1984/weather-mcp-server-typescript.git
cd weather-mcp-server
npm installโ๏ธ Step 2: Setup Environment
# Copy environment template
cp .env.example .envEdit the .env file to contain:
OLLAMA_API_URL=http://localhost:11434/api/generate
OLLAMA_MODEL=llama3๐ค Step 3: Install and Setup Ollama
# Install Ollama (if not already installed)
# Visit https://ollama.com/ for installation instructions
# Start Ollama service
ollama serve
# In another terminal, pull the model
ollama pull llama3
# Verify Ollama is working
curl http://localhost:11434/api/versionStep 4: Test Ollama Connection
# Test if Ollama can generate responses
curl http://localhost:11434/api/generate -d '{
"model": "llama3",
"prompt": "Hello world",
"stream": false
}'Step 5: Run Diagnostics
# Run diagnostic to check if everything is working
npm run diagnose๐ฏ Running the MCP Server
Start the Server
npm startExpected output:
๐ MCP Weather Server starting... ๐ก Ollama URL: http://localhost:11434/api/generate ๐ค Model: llama3 โ MCP Server connected and ready!
๐ Testing with MCP Inspector
Method 1: CLI Inspector
# Install MCP Inspector globally
npm install -g @modelcontextprotocol/inspector
# Run inspector
mcp-inspector
# Follow the web interface instructionsโ๏ธ Configuration
Environment Variables (.env file)
OLLAMA_API_URL=http://localhost:11434/api/generate
OLLAMA_MODEL=llama3Performance Tuning
The server is optimized for quick responses:
15-second timeout for HTTP requests Aggressive Ollama parameters for faster generation Fallback from HTTP API to CLI if needed
##๐ง Troubleshooting
Quick Diagnosis
# Run the diagnostic script
npm run diagnoseCommon Issues & Solutions
Issue: "Request timed out" errors
# Check if Ollama is running
ps aux | grep ollama
# Start Ollama if not running
ollama serve
# Check if model is available
ollama list | grep llama3
# If model not found, pull it
ollama pull llama3Issue: "Request timed out" errors
# Check if Ollama is running
ps aux | grep ollama
# Start Ollama if not running
ollama serve
# Check if model is available
ollama list | grep llama3
# If model not found, pull it
ollama pull llama3Issue: "Model not found" errors
# List available models
ollama list
# Pull the required model
ollama pull llama3
# Or try a smaller model for faster responses
ollama pull llama3:8bIssue: Connection errors
# Verify Ollama is accessible
curl http://localhost:11434/api/version
# Check if port 11434 is open
netstat -an | grep 11434
# Restart Ollama service
pkill ollama
ollama serveIssue: MCP Inspector connection fails
# Make sure your server is running
npm start
# Check the working directory path is correct
pwd
# Verify tsx is available
npm list tsxPerformance Tips
# Use a smaller model for faster responses
ollama pull llama3:8b
# Update .env to use the smaller model
echo "OLLAMA_MODEL=llama3:8b" >> .env
# Monitor system resources
top -p $(pgrep ollama)๐ Project Structure
weather-mcp-server/
โโโ .env # Environment configuration
โโโ .env.example # Environment template
โโโ .gitignore # Git ignore rules
โโโ main.ts # MCP server implementation
โโโ ollamaClient.ts # Ollama API client
โโโ diagnose.ts # Diagnostic tool
โโโ package.json # Dependencies and scripts
โโโ tsconfig.json # TypeScript configuration
โโโ README.md # This fileโ Success Checklist
Complete this checklist to ensure everything is working:
Node.js v18+ installed Ollama installed and running (ollama serve) Model downloaded (ollama pull llama3) Project dependencies installed (npm install) Environment configured (.env file exists) Diagnostic passes (npm run diagnose) MCP server starts successfully (npm start) MCP Inspector connects successfully Weather tool responds to test quer
๐ Quick Start Commands
# Complete setup in one go
git clone https://github.com/your-username/weather-mcp-server.git
cd weather-mcp-server
npm install
cp .env.example .env
ollama serve &
ollama pull llama3
npm run diagnose
npm start๐ค Contributing
Fork the repository
Create a feature branch: git checkout -b feature-name
Make your changes
Test with MCP Inspector
Submit a pull request
Resources
Looking for Admin?
Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.