derekneely/mcp-server-example
If you are the rightful owner of mcp-server-example and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Model Context Protocol (MCP) server built with TypeScript that provides weather information and greeting functionality.
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
.env
file 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"
}
}
}
}