Example MCP weather server with a terminal chat client

Example MCP weather server with a terminal chat client

mcp_exp•byalan-meigs

A weather MCP server, exposed over stdio, that provides US weather alerts and location forecasts via the National Weather Service API, paired with a terminal chat client using OpenAI.

License: Not specified•Runtime: Awaiting documentation review•Category: search web

WHAT IT DOES

  • •Exposes a get_alerts tool that fetches active weather alerts for a US state.
  • •Exposes a get_forecast tool that retrieves weather forecasts for a latitude and longitude.
  • •Runs as an MCP server over stdio transport.
  • •Includes a terminal chat client that connects to the MCP server and OpenAI's API, executing tools during queries.

BEST FOR

  • •Getting active weather alerts for a US state through an MCP-connected assistant.
  • •Retrieving location forecasts via MCP tools inside Cursor's Agent mode.
  • •Learning how to build an MCP server and connect it to a chat client.

ABOUT MCP_EXP

Example MCP weather server with a terminal chat client is cataloged as an MCP server attributed to alan-meigs. A weather MCP server, exposed over stdio, that provides US weather alerts and location forecasts via the National Weather Service API, paired with a terminal chat client using OpenAI. It is categorized under search web. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: Not specified. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Example MCP weather server with a terminal chat client are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Can the weather server be used with Cursor?

Yes; the README states the MCP server can be integrated with Cursor's Agent mode, with tools available there but not in Ask mode.

What data source does the weather service use?

It uses the National Weather Service API.

上游原版 README

在 GitHub 查看同一版本原文

README.md · ca1ded2dee8c · 采集于 2026-11-13 13:26:23 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

Terminal-based Chat Client with MCP Server Integration

This project demonstrates how to build a terminal-based chat client interface that connects to an MCP server and integrates with OpenAI's API. It includes a simple weather service as an example of MCP functionality.

Prerequisites

  • Python 3.8 or higher
  • UV package manager (a fast, reliable Python package installer and resolver)

Installation

1. Install UV

UV is a modern Python package manager that offers significant performance improvements over traditional tools like pip. It's written in Rust and provides:

  • Faster package installation
  • Reliable dependency resolution
  • Built-in virtual environment management
  • Compatible with existing Python tooling

To install UV, run:

curl -LsSf https://astral.sh/uv/install.sh | sh

2. Project Setup

  1. Initialize a new project:
uv init
  1. Create and activate a virtual environment:
uv venv
source .venv/bin/activate  # On Unix/macOS
# or
.venv\Scripts\activate  # On Windows
  1. Install required packages:
uv pip install httpx mcp[cli] openai python-dotenv

Project Structure and Implementation Guide

The project consists of two main components: a chat client (client.py) and a weather service (weather.py). Let's walk through how each component was built and what each part does.

Building the Chat Client (client.py)

The chat client is built as an asynchronous Python application that connects to both an MCP server and OpenAI's API. Here's how it was constructed:

  1. Imports and Setup

    import asyncio
    import os
    import sys
    from typing import Optional
    from contextlib import AsyncExitStack
    from dotenv import load_dotenv
    import openai
    from mcp import ClientSession, StdioServerParameters
    from mcp.client.stdio import stdio_client
    
    • asyncio: For asynchronous programming
    • AsyncExitStack: Manages cleanup of async resources
    • dotenv: Loads environment variables from .env file
    • mcp: Core MCP functionality for server communication
  2. MCPClient Class The main client class handles:

    • Connection to the MCP server
    • OpenAI API integration
    • Message processing
    • Tool execution

    Key methods:

    • connect_to_server(): Establishes connection to the MCP server
    • process_query(): Handles user queries and tool execution
    • chat_loop(): Manages the interactive chat session
    • cleanup(): Ensures proper resource cleanup
  3. Main Function

    async def main():
        client = MCPClient()
        try:
            await client.connect_to_server(sys.argv[1])
            await client.chat_loop()
        finally:
            await client.cleanup()
    
    • Entry point that initializes the client
    • Connects to the specified server
    • Runs the chat loop
    • Ensures proper cleanup

Building the Weather Service (weather.py)

The weather service is built as an MCP server that provides weather information through the National Weather Service API:

  1. Service Initialization

    from mcp.server.fastmcp import FastMCP
    mcp = FastMCP("weather")
    
    • Creates an MCP server instance named "weather"
    • Sets up the server infrastructure
  2. API Integration

    NWS_API_BASE = "https://api.weather.gov"
    USER_AGENT = "weather-app/1.0"
    
    • Defines constants for the National Weather Service API
    • Sets up proper user agent for API requests
  3. Helper Functions

    • make_nws_request(): Handles API requests with proper error handling
    • format_alert(): Formats weather alerts into readable text
  4. MCP Tools Two main tools are implemented:

    a. get_alerts(state):

    • Fetches active weather alerts for a US state
    • Returns formatted alert information

    b. get_forecast(latitude, longitude):

    • Retrieves weather forecast for a location
    • Returns detailed forecast information
  5. Server Execution

    if __name__ == "__main__":
        mcp.run(transport="stdio")
    
    • Runs the MCP server using stdio transport
    • Enables communication with the chat client

Usage

  1. Create a .env file with your OpenAI API key:
OPENAI_API_KEY=your_api_key_here
  1. Start the MCP server:
python weather.py
  1. In a separate terminal, run the chat client:
python client.py weather.py
  1. Interact with the chat interface:
    • Ask general questions to chat with the AI
    • Use weather-related queries to get weather information
    • Example: "What's the weather in California?" or "Are there any alerts in New York?"

Using with Cursor's Agent Mode

This MCP server can be integrated directly with Cursor's Agent mode (Note: This is different from Cursor's Ask feature and only works in Agent mode). Here's how to set it up:

Adding the MCP Server to Cursor

  1. Open Cursor Settings
  2. Navigate to Features > MCP
  3. Click + Add New MCP Server
  4. Fill out the form:
    • Type: Select stdio
    • Name: "Weather Service" (or any name you prefer)
    • Command: Enter the full path to run the weather server:
      python /full/path/to/your/weather.py
      

Alternative: Project-Specific Configuration

You can also configure the MCP server for your project by creating a .cursor/mcp.json file:

  1. Create the .cursor directory in your project root:
mkdir .cursor
  1. Create mcp.json with the following content:
{
  "mcpServers": {
    "weather": {
      "command": "python",
      "args": [
        "/full/path/to/your/weather.py"
      ]
    }
  }
}

Using the Weather Tools

  1. Open Cursor's Composer (Agent mode)
  2. The Agent will automatically detect when weather information is needed
  3. Example queries:
    • "What's the current weather in San Francisco?"
    • "Are there any weather alerts in California?"
    • "Get me the forecast for New York City"

Important Notes

  • Tools are only available in Cursor's Agent mode (Composer), not in Ask mode
  • By default, Cursor will ask for approval before using MCP tools
  • You may need to click the refresh button in the MCP settings to see newly added tools
  • The server must be running on your local machine (remote servers require SSE transport)

Features

  • Real-time chat interface with OpenAI integration
  • MCP server integration for extensible functionality
  • Weather service with alerts and forecasts
  • Asynchronous operation for better performance
  • Proper error handling and resource cleanup
  • Environment variable configuration for API keys

Contributing

Feel free to submit issues and enhancement requests!

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Example MCP weather server with a terminal chat client from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/mcp_exp)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related search web MCP Servers

Alternative and complementary servers in the same category

View all in search web →

An MCP server that merges Google Search Console history with a live first-party crawl of your site to produce a prioritised, evidence-backed technical SEO audit inside Claude, complete with paste-ready fixes.

Repository stats unavailable
Search & Web Research

An MCP server that offers intelligent web search using OpenAI reasoning models, with support for fast iterations and deep research.

94
Search & Web Research