- Explore MCP Servers
- mcp-server-example
Mcp Server Example
What is Mcp Server Example
mcp-server-example is a Model Context Protocol (MCP) server built with TypeScript that provides weather information and greeting functionality.
Use cases
Use cases include integrating with large language models for weather-related queries, providing weather information in web applications, and developing interactive applications that require real-time data.
How to use
To use mcp-server-example, install the dependencies with ‘npm install’, create a .env file with your weather API key, and run the server in either stdio mode or HTTP mode using the provided npm scripts.
Key features
Key features include two operational modes (stdio mode for direct LLM integration and HTTP mode for web API access), weather information retrieval, and greeting functionality.
Where to use
mcp-server-example can be used in applications requiring weather data, such as chatbots, virtual assistants, or any system that benefits from real-time weather updates.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcp Server Example
mcp-server-example is a Model Context Protocol (MCP) server built with TypeScript that provides weather information and greeting functionality.
Use cases
Use cases include integrating with large language models for weather-related queries, providing weather information in web applications, and developing interactive applications that require real-time data.
How to use
To use mcp-server-example, install the dependencies with ‘npm install’, create a .env file with your weather API key, and run the server in either stdio mode or HTTP mode using the provided npm scripts.
Key features
Key features include two operational modes (stdio mode for direct LLM integration and HTTP mode for web API access), weather information retrieval, and greeting functionality.
Where to use
mcp-server-example can be used in applications requiring weather data, such as chatbots, virtual assistants, or any system that benefits from real-time weather updates.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
Weather MCP Server
A Model Context Protocol (MCP) server built with TypeScript that provides weather information and greeting functionality. This server can run in two modes:
- stdio mode: For direct integration with LLMs through stdin/stdout
- HTTP mode: For exposing the MCP server as a web API
Setup
- Install dependencies:
npm install
- Create a
.envfile in the root directory with the following content:
WEATHER_API_KEY=your_api_key_here
Replace your_api_key_here with your weatherapi.com API key. You can get one by signing up at weatherapi.com.
Running the Server
Development Mode
For stdio mode (direct LLM integration):
npm run dev:stdio -- or -- npm run dev:stdio-mcp
For HTTP mode (web API):
npm run dev:http
Production Mode
For stdio mode:
npm run build node ./dist/index-stdio.js -- or -- node ./dist/index-stdio-mcp.js
For HTTP mode:
npm run build node ./dist/index-http.js
Using Docker (for the API)
docker-compose up --build -d
Usage Examples
stdio Mode
When running in stdio mode, the server communicates directly with LLMs through stdin/stdout. This is useful for local development and testing with LLMs.
HTTP Mode
When running in HTTP mode, the server exposes an HTTP API that can be accessed by any client. The server will be available at http://localhost:3000.
Cursor Configuration
Below is a .cursor/mcp.json configuration file to work with all 3 provided Examples
{ "mcpServers": { "local-mcp-sandbox-http": { "type": "sse", "url": "http://localhost:3000/sse" }, "local-mcp-sandbox-stdio": { "command": "node", "args": ["./dist/index-stdio.js"], "env": { "WEATHER_API_KEY": "API_KEY_HERE" } }, "local-mcp-sandbox-stdio-mcp": { "command": "node", "args": ["./dist/index-stdio-mcp.js"], "env": { "WEATHER_API_KEY": "API_KEY_HERE" } } } }
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










