Logo : Weather MCP Server with GitHub OAuth & Location Management

Weather MCP Server with GitHub OAuth & Location Management

Communauté
f

This project demonstrates an advanced Model Context Protocol (MCP) server with GitHub OAuth authentication, personalized location management, and weather data retrieval using Open-Meteo's free API.

Éditeurf
Dépôtkomunite-mcp-bootcamp-weather-mcp
LangueJavaScript
Forks
1
Étoiles
11
Outils disponibles
0
Type de transportstdio, streamable-http
Catégories
Liens
  • Connectez des outils à vos workflows IA

    Weather MCP Server with GitHub OAuth & Location Management propose des fonctionnalités MCP utilisables par les clients et agents IA compatibles.

  • Outils disponibles : 0

    Parcourez ci-dessous les actions que le client peut appeler, avec leurs noms et descriptions lorsque le serveur les fournit.

  • Configuration prête à copier

    Utilisez les extraits fournis pour configurer ce serveur dans votre client MCP préféré.

  • Indicateurs de popularité du dépôt open source

    Dépôt associé : 11 étoiles et 1 fork.

Weather MCP Server with GitHub OAuth & Location Management

This project demonstrates an advanced Model Context Protocol (MCP) server with GitHub OAuth authentication, personalized location management, and weather data retrieval using Open-Meteo's free API.

Features

  • 🔐 GitHub OAuth 2.0 Authentication: Secure authentication using GitHub Apps
  • 📍 Personal Location Management: Save and manage custom location labels (e.g., "home", "office")
  • 🌤️ Smart Weather Queries: Check weather using saved labels or direct location names
  • 💾 SQLite Database: Persistent storage for users and their locations
  • 🆓 Free Weather API: Uses Open-Meteo API - no API key required!
  • 🔄 Streamable HTTP Transport: Modern HTTP transport with MCP SDK
  • 🛠️ Multiple Tools: Weather lookup, location management (add, list, delete), user info
  • 👤 User Profiles: Automatic user creation from GitHub profile data with profile retrieval

Prerequisites

  • Node.js (v18 or higher recommended)
  • GitHub Account
  • GitHub OAuth App (instructions below)
  • OpenAI API Key (optional, for the client example)

Setup

1. Install dependencies:

bash
npm install

2. Create GitHub OAuth App:

  1. Go to GitHub Developer Settings
  2. Click "New OAuth App"
  3. Fill in the application details:
    • Application name: Weather MCP Server (or your preferred name)
    • Homepage URL: http://localhost:3000
    • Authorization callback URL: http://localhost:3000/oauth/callback
  4. Click "Register application"
  5. Copy your Client ID
  6. Click "Generate a new client secret" and copy it

3. Configure Environment Variables:

bash
cp .env.example .env

Edit .env and add your GitHub OAuth credentials:

bash
GITHUB_CLIENT_ID=your_github_client_id_here
GITHUB_CLIENT_SECRET=your_github_client_secret_here
GITHUB_REDIRECT_URI=http://localhost:3000/oauth/callback
PORT=3000

4. Start the MCP server:

bash
node server.js

The server will start on http://127.0.0.1:3000

5. Authenticate with GitHub:

  1. Open your browser and visit: http://localhost:3000/oauth/login
  2. Click "Authorize" to connect with GitHub
  3. Copy the access token displayed on the success page
  4. Use this token in the Authorization header: Bearer <your-token>

6. Configure Claude Desktop

Add the configuration to your Claude Desktop config file:

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json

Windows: %APPDATA%\Claude\claude_desktop_config.json

Option A: Automatic OAuth (Recommended)

json
{
  "mcpServers": {
    "weather-server": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "http://127.0.0.1:3000/mcp"
      ]
    }
  }
}

Claude Desktop will automatically discover the OAuth endpoints and open your browser for authentication. Just authorize with GitHub when prompted!

Option B: Manual Token

json
{
  "mcpServers": {
    "weather-server": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "http://127.0.0.1:3000/mcp",
        "--header",
        "Authorization: Bearer YOUR_GITHUB_ACCESS_TOKEN",
        "--no-auth"
      ]
    }
  }
}

First get your token by visiting http://localhost:3000/oauth/login, then replace YOUR_GITHUB_ACCESS_TOKEN with your token.

Usage Examples

Once connected via Claude Desktop, you can:

Basic Weather Queries

  • "What is the weather like in San Francisco?"
  • "Tell me the current weather in Tokyo"
  • "How's the weather in Paris?"

Save Personal Locations

  • "Save my home location as New York"
  • "Add my office location as San Francisco"
  • "Save the gym location as 123 Main Street, Boston"

Query Using Saved Labels

  • "What's the weather at home?"
  • "How's the weather at the office?"
  • "Check the weather at the gym"

Manage Locations

  • "List all my saved locations"
  • "Show my locations"
  • "Delete my home location"

User Profile

  • "Who am I?"
  • "Show my profile"
  • "What's my GitHub username?"

How It Works

  1. OAuth Flow: User authenticates via GitHub OAuth 2.0
  2. Token Exchange: Server exchanges authorization code for access token
  3. User Creation: Server creates or updates user profile from GitHub data
  4. Authentication: Client sends Bearer token in Authorization header
  5. Token Validation: Server validates token against SQLite database
  6. Session Creation: Server creates authenticated session with user context
  7. Tool Discovery: Client discovers available MCP tools from server
  8. Tool Execution:
    • Weather queries resolve location labels to actual addresses
    • Location management stores data per-user in database
    • All operations are scoped to the authenticated user
  9. Weather Data: Server fetches real-time weather from Open-Meteo API
  10. Response: Results returned to client with user-specific context

Architecture

      User Browser
           │
           │ 1. Visit /oauth/login
           ▼
    GitHub OAuth Server
           │
           │ 2. Authorization
           ▼
      /oauth/callback
           │
           │ 3. Access Token
           ▼
┌─────────────────────────────────────────────┐
│        Claude Desktop / MCP Client          │
│  (with Authorization: Bearer token)         │
└─────────────────┬───────────────────────────┘
                  │ Streamable HTTP + Auth
                  ▼
┌─────────────────────────────────────────────┐
│           server.js (MCP Server)            │
│  ┌───────────────────────────────────────┐  │
│  │  OAuth Authentication (auth.js)       │  │
│  │           ↓                           │  │
│  │  Token Validation Middleware          │  │
│  │           ↓                           │  │
│  │  Session Management (per-user)        │  │
│  │           ↓                           │  │
│  │  MCP Tools:                           │  │
│  │  - get_current_weather                │  │
│  │  - add_location                       │  │
│  │  - list_locations                     │  │
│  │  - delete_location                    │  │
│  └───────────────────────────────────────┘  │
│                 ↓                           │
│  ┌───────────────────────────────────────┐  │
│  │     SQLite Database (weather.db)      │  │
│  │  - users (with GitHub data)           │  │
│  │  - locations                          │  │
│  └───────────────────────────────────────┘  │
└─────────────────┬───────────────────────────┘
                  │
                  ▼
         Open-Meteo Weather API

MCP Tools

1. get_current_weather

Fetches real-time weather data for any location or saved label.

  • Parameters:
    • location (string): Location name or saved label (e.g., "New York", "home")
    • unit (enum): Temperature unit - "celsius" or "fahrenheit" (default: celsius)
  • Returns: Temperature, condition, humidity, wind speed, pressure, cloud cover
  • Special: Automatically resolves saved location labels to addresses

2. add_location

Save a location with a custom label for quick access.

  • Parameters:
    • label (string): Custom label (e.g., "home", "office", "gym")
    • location (string): Actual location name or address
  • Returns: Confirmation message
  • Note: Replaces existing label if it already exists

3. list_locations

Display all saved locations for the authenticated user.

  • Parameters: None
  • Returns: List of all saved locations with their labels

4. delete_location

Remove a saved location by its label.

  • Parameters:
    • label (string): Label of the location to delete
  • Returns: Confirmation or error message

5. get_user_info

Get information about the currently logged-in user.

  • Parameters: None
  • Returns: User profile with GitHub username, name, email, avatar URL, and user ID

Project Structure

komunite-bootcamp-mcp/
├── server.js              # MCP HTTP server with OAuth
├── database.js            # SQLite database operations
├── auth.js                # GitHub OAuth authentication
├── index.js               # OpenAI function calling example (legacy)
├── .env.example           # Environment variables template
├── .env                   # Your environment variables (create this)
├── package.json           # Dependencies and scripts
├── weather.db             # SQLite database (created on first run)
└── README.md             # This file

Database Schema

Users Table

sql
CREATE TABLE users (
  id TEXT PRIMARY KEY,
  github_id TEXT UNIQUE,
  github_username TEXT,
  github_email TEXT,
  name TEXT,
  avatar_url TEXT,
  access_token TEXT,
  refresh_token TEXT,
  token_expires_at DATETIME,
  auth_token TEXT UNIQUE,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
)

Locations Table

sql
CREATE TABLE locations (
  id TEXT PRIMARY KEY,
  user_id TEXT NOT NULL,
  label TEXT NOT NULL,
  location_name TEXT NOT NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
  UNIQUE(user_id, label)
)

Security Features

  • GitHub OAuth 2.0: Industry-standard OAuth authentication flow
  • PKCE (RFC 7636): Proof Key for Code Exchange with S256 for public clients
  • Dynamic Client Registration (RFC 7591): Automatic client registration
  • State Parameter: CSRF protection with state verification
  • Bearer Token Authentication: All MCP endpoints require valid authentication
  • Token Validation: Access tokens validated against database
  • User Isolation: Each user can only access their own locations
  • Session Management: Secure session handling with user context
  • Database Constraints: Foreign key constraints ensure data integrity
  • Automatic Token Expiration: Token expiry tracking for enhanced security

Customization

Adding Custom MCP Tools

  1. Open server.js
  2. Register a new tool after existing tools:
javascript
sessionServer.tool(
  'your_tool_name',
  'Tool description',
  {
    param1: z.string().describe('Parameter description'),
  },
  async ({ param1 }) => {
    const userId = sessionUsers[transport.sessionId]?.id;
    // Your tool logic here
    return {
      content: [{ type: 'text', text: 'Result' }],
    };
  }
);
  1. The tool will automatically be discovered by clients

API Endpoints

OAuth Discovery Endpoints (RFC 8414 & RFC 9728)

  • GET /.well-known/oauth-authorization-server - OAuth 2.0 Authorization Server Metadata
  • GET /.well-known/oauth-protected-resource - OAuth 2.0 Protected Resource Metadata

OAuth Endpoints (Standards-Compliant)

  • POST /oauth/register - Dynamic Client Registration (RFC 7591)
  • GET /oauth/authorize - OAuth 2.0 Authorization Endpoint
  • POST /oauth/token - OAuth 2.0 Token Endpoint
  • POST /oauth/revoke - OAuth 2.0 Token Revocation (RFC 7009)
  • GET /oauth/login - Manual OAuth flow (browser-based)
  • GET /oauth/callback - OAuth callback handler
  • GET /oauth/me - Returns current user info (requires authentication)

MCP Endpoints

  • POST /mcp - Main MCP endpoint for tool calls
  • GET /mcp - Server-Sent Events for notifications
  • DELETE /mcp - Session termination

Utility Endpoints

  • GET /health - Health check endpoint

Notes

  • Based on the Model Context Protocol (MCP) specification
  • Uses @modelcontextprotocol/sdk for MCP server implementation
  • Streamable HTTP transport: Modern HTTP transport with session management
  • SQLite Database: Lightweight, file-based database with better-sqlite3
  • GitHub OAuth 2.0: Secure authentication via GitHub Apps
  • Uses Open-Meteo API - free and open-source weather API
  • No API key required for weather data!
  • Per-user location management with database isolation
  • Automatic label resolution for convenient weather queries
  • User profiles automatically created from GitHub data

Logout / Revoke Access

To logout from OAuth when using Claude Desktop:

Option 1: Clear mcp-remote Cache

bash
rm -rf ~/.cache/mcp-remote/auth/

Option 2: Manual Token Revocation

bash
curl -X POST http://localhost:3000/oauth/revoke \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "token=YOUR_ACCESS_TOKEN"

Then clear the cache and restart Claude Desktop.

Troubleshooting

Token Expired

If you get authentication errors, your GitHub token may have expired:

  1. Visit http://localhost:3000/oauth/login again
  2. Get a new access token
  3. Update your Claude Desktop configuration with the new token

Testing with cURL

You can test the API directly with cURL:

bash
# Check OAuth server metadata:
curl http://localhost:3000/.well-known/oauth-authorization-server

# Check protected resource metadata:
curl http://localhost:3000/.well-known/oauth-protected-resource

# Get your access token first by visiting:
open http://localhost:3000/oauth/login

# Then test the authenticated endpoint:
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  http://localhost:3000/oauth/me

References

Installation

TypingMind
{
  "mcpServers": {
    "komunite-mcp-bootcamp-weather-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "http://127.0.0.1:3000/mcp"
      ]
    }
  }
}

Utilisez le serveur MCP Weather MCP Server with GitHub OAuth & Location Management avec plusieurs modèles IA

TypingMind connecte les outils MCP au niveau de l’espace de travail. Une fois Weather MCP Server with GitHub OAuth & Location Management connecté, vous pouvez donc l’utiliser avec différents modèles IA dans TypingMind sans avoir à le configurer séparément pour chaque modèle. Vous pouvez exécuter le serveur MCP localement sur votre appareil ou vous connecter à un serveur MCP distant via son URL.

Option 1 : utiliser le connecteur local

Choisissez cette méthode si le serveur MCP doit accéder à des fichiers locaux, à des applications ou à des ressources privées sur votre ordinateur.

1

Ouvrir les paramètres MCP

Dans TypingMind, accédez à « Paramètres », puis à « Paramètres avancés » et à « Model Context Protocol », et choisissez « Configurer le connecteur ».

  1. Ouvrez TypingMind dans votre navigateur.
  2. Cliquez sur l’icône Paramètres.
  3. Accédez aux paramètres avancés.
  4. Ouvrez la section Model Context Protocol.
  5. Cliquez sur « Configurer le connecteur » et choisissez « Cet appareil ».
Écran de configuration du connecteur MCP de TypingMind avec l’option « Cet appareil » sélectionnée
2

Exécuter la commande du connecteur

Choisissez « Cet appareil », copiez la commande depuis TypingMind et exécutez-la dans Terminal. Laissez le processus en cours d’exécution pendant que vous utilisez MCP.

  1. Copiez la commande de configuration affichée par TypingMind.
  2. Ouvrez Terminal sur macOS ou Windows Terminal sur Windows.
  3. Collez et exécutez la commande.
  4. Autorisez l’installation du paquet si Terminal vous demande de confirmer.
  5. Gardez la fenêtre de Terminal ouverte et le processus en cours d’exécution pendant que vous utilisez les outils MCP.
3

Ajouter Weather MCP Server with GitHub OAuth & Location Management en tant que serveur

Lorsque le connecteur est à l’état « Prêt », cliquez sur « Modifier les serveurs » et collez la configuration du serveur MCP.

  1. Attendez que le connecteur soit à l’état « Prêt ».
  2. Cliquez sur « Modifier les serveurs ».
  3. Collez la configuration du serveur MCP Weather MCP Server with GitHub OAuth & Location Management.
  4. Enregistrez la liste des serveurs.
  5. Actualisez la page si vous souhaitez vérifier que le connecteur est toujours prêt.
Paramètres MCP de TypingMind affichant un serveur actif et le bouton « Modifier les serveurs »
{
  "mcpServers": {
    "komunite-mcp-bootcamp-weather-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "weather-mcp-server"
      ]
    }
  }
}
4

Utiliser la connexion avec différents modèles

Enregistrez la liste des serveurs, ouvrez « Plugins », activez les outils MCP de Weather MCP Server with GitHub OAuth & Location Management, puis sélectionnez un modèle IA compatible dans TypingMind et utilisez les outils dans une discussion ou attribuez-les à un agent IA.

  1. Ouvrez la page Plugins dans TypingMind.
  2. Activez les outils MCP de Weather MCP Server with GitHub OAuth & Location Management.
  3. Démarrez une discussion et choisissez le modèle IA que vous souhaitez utiliser.
  4. Utilisez les outils MCP dans la discussion ou attribuez-les à un agent IA.
  5. Passez à un autre modèle IA selon vos besoins sans rétablir la connexion MCP.
Discussion TypingMind utilisant des outils MCP activés avec un modèle d’IA sélectionné
Pouvez-vous utiliser Weather MCP Server with GitHub OAuth & Location Management pour m’aider dans cette tâche ?
Weather MCP Server with GitHub OAuth & Location Management
Bien sûr. Je l’ai lu.
Voici ce que j’ai trouvé avec Weather MCP Server with GitHub OAuth & Location Management.

Option 2 : ajouter l’URL d’un serveur MCP

Choisissez cette méthode si Weather MCP Server with GitHub OAuth & Location Management est déjà hébergé à distance ou si votre équipe souhaite partager un même connecteur entre plusieurs utilisateurs.

1

Ouvrir la section « Connecteurs MCP »

Dans TypingMind, accédez à « Plugins », ouvrez « Connecteurs MCP », puis choisissez « Ajouter une URL ».

  1. Ouvrez TypingMind dans votre navigateur.
  2. Accédez à la section Plugins.
  3. Ouvrez la section « Connecteurs MCP ».
  4. Cliquez sur « Ajouter une URL ».
Formulaire TypingMind d’ajout de l’URL d’un serveur MCP personnalisé
2

Coller l’URL du serveur

Saisissez http://127.0.0.1:3000/mcp dans le champ « URL du serveur ». Ajoutez un nom de connexion, une description, une icône, des en-têtes HTTP personnalisés ou les paramètres du client OAuth si le serveur les exige.

  1. Collez http://127.0.0.1:3000/mcp dans le champ « URL du serveur ».
  2. Saisissez un nom de connexion pour Weather MCP Server with GitHub OAuth & Location Management.
  3. Si vous le souhaitez, ajoutez une description et une icône pour identifier plus facilement la connexion.
  4. Ajoutez des en-têtes HTTP personnalisés ou les informations du client OAuth si le serveur exige une authentification.
3

Créer la connexion

Cliquez sur « Créer la connexion », puis revenez à la liste des plugins et vérifiez que la nouvelle connexion MCP est active.

  1. Cliquez sur « Créer la connexion ».
  2. Revenez à la liste des connecteurs MCP.
  3. Vérifiez que la connexion Weather MCP Server with GitHub OAuth & Location Management apparaît comme active.
  4. Actualisez la liste des plugins si la connexion n’apparaît pas immédiatement.
4

Changer de modèle sans rétablir la connexion MCP

Démarrez une discussion avec votre modèle préféré, activez les outils de Weather MCP Server with GitHub OAuth & Location Management depuis « Plugins » et passez à un autre modèle selon vos besoins. La connexion MCP reste disponible dans l’espace de travail TypingMind.

  1. Démarrez une nouvelle discussion dans TypingMind.
  2. Sélectionnez le modèle IA que vous souhaitez utiliser.
  3. Activez les outils de Weather MCP Server with GitHub OAuth & Location Management depuis la section Plugins.
  4. Demandez au modèle d’utiliser l’outil si nécessaire.
  5. Passez à un autre modèle IA et réutilisez la même connexion MCP.
Discussion TypingMind utilisant des outils MCP activés avec un modèle d’IA sélectionné
Pouvez-vous utiliser Weather MCP Server with GitHub OAuth & Location Management pour m’aider dans cette tâche ?
Weather MCP Server with GitHub OAuth & Location Management
Bien sûr. Je l’ai lu.
Voici ce que j’ai trouvé avec Weather MCP Server with GitHub OAuth & Location Management.

Foire aux questions

À quoi sert le serveur MCP Weather MCP Server with GitHub OAuth & Location Management ?

Weather MCP Server with GitHub OAuth & Location Management est un serveur MCP qui permet aux applications IA compatibles d’accéder à des outils et à des informations contextuelles externes. Dans TypingMind, il vous suffit d’ajouter ce serveur MCP une seule fois pour rendre ses outils disponibles dans votre espace de travail IA.

Puis-je utiliser le serveur MCP Weather MCP Server with GitHub OAuth & Location Management avec plusieurs modèles IA dans TypingMind ?

Oui. TypingMind connecte les outils MCP au niveau de l’espace de travail. Vous pouvez donc utiliser Weather MCP Server with GitHub OAuth & Location Management avec différents modèles IA comme Claude, ChatGPT, Gemini ou d’autres modèles configurés dans TypingMind, sans avoir à configurer le serveur MCP séparément pour chaque modèle.

Pourquoi utiliser le connecteur MCP Weather MCP Server with GitHub OAuth & Location Management avec TypingMind ?

TypingMind est l’une des meilleures interfaces de chat avec les LLM, car elle réunit plusieurs modèles IA, prompts, plugins, agents IA, clés API et outils MCP dans un seul espace de travail. Une fois Weather MCP Server with GitHub OAuth & Location Management connecté, vous pouvez utiliser ses outils MCP avec vos modèles préférés tout en gardant vos discussions bien organisées dans TypingMind.

Comment connecter le serveur MCP Weather MCP Server with GitHub OAuth & Location Management à TypingMind ?

Vous pouvez connecter Weather MCP Server with GitHub OAuth & Location Management à TypingMind à l’aide du connecteur MCP local ou en ajoutant l’URL d’un serveur MCP distant. Utilisez le connecteur local lorsque le serveur doit accéder à des fichiers, à des applications ou à des ressources privées sur votre appareil. Si le serveur MCP est hébergé à distance, utilisez son URL.

Quels outils le serveur MCP Weather MCP Server with GitHub OAuth & Location Management propose-t-il dans TypingMind ?

Weather MCP Server with GitHub OAuth & Location Management propose des fonctionnalités MCP que vous pouvez activer depuis la page Plugins de TypingMind et utiliser dans les discussions ou attribuer à des agents IA.

Dois-je partager mes clés API avec TypingMind pour utiliser le serveur MCP Weather MCP Server with GitHub OAuth & Location Management ?

Non. TypingMind privilégie le fonctionnement local et vous permet de garder le contrôle de vos fournisseurs de modèles, clés API, prompts et paramètres MCP. Si Weather MCP Server with GitHub OAuth & Location Management nécessite une authentification, ajoutez les en-têtes, les paramètres OAuth ou la configuration locale requis pour ce serveur MCP lors de la création de la connexion.

Serveurs MCP similaires

Tout voir

Créez votre propre espace de travail IA dès maintenant

Abonnez-vous à notre newsletter pour être informé des nouvelles fonctionnalités et des prochains cadeaux à gagner 👇