Get the FREE Ultimate OpenClaw Setup Guide →

mcp-streamable-http

Example implementation of MCP Streamable HTTP client/server in Python and TypeScript.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio invariantlabs-ai-mcp-streamable-http python weather.py \
  --env ANTHROPIC_API_KEY="your_api_key_here"

How to use

This repository provides example implementations of an MCP Streamable HTTP server and client in both Python and TypeScript. The servers expose a Streamable HTTP transport that allows a client to send structured context and receive responses backed by an Anthropic language model. You can run the Python server or the TypeScript server independently, and the clients can communicate with either server to demonstrate cross-language compatibility. Start the server of your chosen language, then run the corresponding client to begin an interactive chat loop that forwards requests over the MCP Streamable HTTP protocol to the local server.

How to install

Prerequisites:

  • Python 3.8+ with pip
  • Node.js 14+ with npm
  • Access to an Anthropic API key

Python setup:

  1. Navigate to the Python example:
    • cd python-example
    • cd server
  2. Install dependencies and run the server:
    • pip install .
    • python weather.py The server will start by default at http://localhost:8123. To use a different port, append --port, e.g.: python weather.py --port=9000
  3. Prepare the client:
    • cd ../client
    • pip install .
  4. Run the Python client:
    • python client.py

TypeScript setup:

  1. Navigate to the TypeScript example:
    • cd typescript-example
    • cd server
  2. Install and build:
    • npm install
    • npm run build
  3. Run the server:
    • node build/index.js The server will start by default at http://localhost:8123. To use a different port, append --port, e.g.: node build/index.js --port=9000
  4. Prepare the client:
    • cd ../client
    • npm install
    • npm run build
  5. Run the TypeScript client:
    • node build/index.js

Environment variable for both servers:

  • ANTHROPIC_API_KEY: your_api_key_here Place your actual API key in the environment or in the .env files as indicated by the respective example.

Additional notes

Tips and common considerations:

  • The Python and TypeScript servers are designed to be interchangeable in terms of the MCP Streamable HTTP protocol; ensure the client points to the correct server port when testing cross-language scenarios.
  • If you encounter port conflicts, start one server on a different port using the --port flag (e.g., --port=9000) and pass the same port to the client with --mcp-localhost-port.
  • The ANTHROPIC_API_KEY must be valid for the client/server to function; keep keys secure and avoid committing them to version control.
  • When building TypeScript, ensure you run npm run build before starting the server so build/index.js exists.
  • If you need to switch languages, you can mix Python and TS clients with either server as a backend, thanks to the protocol compatibility.

Related MCP Servers

Sponsor this space

Reach thousands of developers