Sponsored by Deepsite.site

mcp-streamable-http-server

Created By
nunaszek8 months ago
mcp-streamable-http-server provides a comprehensive development template for building StreamableHttp services with flexible authentication, dynamic service registration, customizable middleware, and easy tool configuration via YAML.
Content

mcp-streamable-http-server

mcp-streamable-http-server
Release Version

Welcome to the mcp-streamable-http-server repository! This project offers a comprehensive development template for creating StreamableHttp services. It emphasizes flexible authentication, dynamic service registration, customizable middleware, and easy tool configuration through YAML files.

Table of Contents

  1. Features
  2. Installation
  3. Getting Started
  4. Usage
  5. Configuration
  6. Middleware
  7. Dynamic Services
  8. Authentication
  9. Session Management
  10. Contributing
  11. License
  12. Contact

Features

  • Flexible Authentication: Implement various authentication methods easily.
  • Dynamic Service Registration: Register and deregister services on-the-fly.
  • Customizable Middleware: Add or modify middleware to suit your needs.
  • YAML Configuration: Use YAML files for straightforward configuration.
  • Built with Starlette: Leverage the power of the Starlette framework for performance and scalability.

Installation

To get started with the mcp-streamable-http-server, clone the repository and install the required dependencies.

git clone https://github.com/nunaszek/mcp-streamable-http-server.git
cd mcp-streamable-http-server
pip install -r requirements.txt

Getting Started

After installing the project, you can start building your StreamableHttp services.

  1. Download the latest release from the Releases section.
  2. Execute the server by running:
python main.py

This will start your server, ready to handle requests.

Usage

You can create a basic service by defining it in a YAML configuration file. Here is a simple example:

services:
  my_service:
    path: /my_service
    methods: [GET, POST]
    auth: true

Configuration

The configuration is done using YAML files. You can define services, middleware, and authentication methods in a structured way. Here’s an example configuration:

services:
  example_service:
    path: /example
    methods: [GET]
    middleware:
      - log_request
      - authenticate

YAML Configuration File Structure

  • services: Define all your services here.
  • path: The endpoint path for your service.
  • methods: Allowed HTTP methods.
  • middleware: List of middleware to apply.

Middleware

Middleware allows you to process requests before they reach your service. You can create custom middleware or use built-in options.

Example of Custom Middleware

from starlette.middleware.base import BaseHTTPMiddleware

class LogRequestMiddleware(BaseHTTPMiddleware):
    async def dispatch(self, request, call_next):
        print(f"Request: {request.method} {request.url}")
        response = await call_next(request)
        return response

Dynamic Services

Dynamic service registration allows you to add or remove services at runtime. This feature is essential for applications that require scalability and flexibility.

Example of Dynamic Registration

@app.on_event("startup")
async def startup_event():
    app.add_route("/dynamic_service", dynamic_service, methods=["GET"])

async def dynamic_service(request):
    return JSONResponse({"message": "This is a dynamic service!"})

Authentication

The mcp-streamable-http-server supports various authentication methods. You can easily implement token-based or session-based authentication.

Example of Token Authentication

from fastapi import Depends, HTTPException, status

def token_auth(token: str = Depends(oauth2_scheme)):
    if token != "expected_token":
        raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid token")

Session Management

Session management is crucial for maintaining user states. You can implement session storage using various backends, including in-memory or database storage.

Example of Session Management

from starlette.sessions import SessionMiddleware

app.add_middleware(SessionMiddleware, secret_key="your_secret_key")

Contributing

We welcome contributions to improve the mcp-streamable-http-server. Please follow these steps:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes.
  4. Submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For questions or suggestions, please reach out via GitHub issues or contact the repository owner.


For the latest releases, visit the Releases section. Download the latest version and start building your StreamableHttp services today!

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
WindsurfThe new purpose-built IDE to harness magic
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
DeepChatYour AI Partner on Desktop
Serper MCP ServerA Serper MCP Server
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Tavily Mcp
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
ChatWiseThe second fastest AI chatbot™
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
CursorThe AI Code Editor
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
Playwright McpPlaywright MCP server
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Amap Maps高德地图官方 MCP Server