This repository demonstrates how to use the Model Context Protocol (MCP) with HTTP communication between client and server components.
weather/: MCP server that provides weather toolsmcp-client-typescript/: MCP client that connects to the server and uses Claude API
First, build both the server and client:
# Build the weather server
cd weather
npm install
npm run build
# Build the client
cd ../mcp-client-typescript
npm install
npm run buildMake sure to set your API key in the client's .env file:
# mcp-client-typescript/.env
ANTHROPIC_API_KEY=your_anthropic_api_key_here
MCP_SERVER_URL=http://localhost:3001
Start the weather MCP server with HTTP transport:
cd weather
npm run start:httpThe server will start on http://localhost:3001 by default.
In a separate terminal, start the MCP client:
cd mcp-client-typescript
npm run start:httpThe client will connect to the server via HTTP and allow you to interact with the weather tools through Claude.
Once both the server and client are running, you can ask questions about weather in the client terminal:
- "What's the weather forecast for San Francisco?" (latitude 37.7749, longitude -122.4194)
- "Are there any weather alerts in CA?"
This HTTP-based setup can be easily adapted for AWS Lambda and API Gateway:
- Deploy the server as a Lambda function with API Gateway
- Update the client to point to the API Gateway URL
- Deploy the client as another Lambda function or use it from any environment