FastAPI SSE MCP Random

by hk4crprasad

Integrations

  • Uses FastAPI to implement the Model Context Protocol server with Server-Sent Events for streaming communication

  • Connects to Azure OpenAI DALL-E 3 for image generation based on text prompts

  • Built with Python 3.10+ and includes various utility tools like random number generation, echo functionality, and AI podcast generation

FastAPI SSE MCP 随机

一个 FastAPI 服务器,它使用服务器发送事件 (SSE) 实现模型上下文协议 (MCP),用于流式通信。该项目提供各种实用工具,包括随机数生成、使用 Azure OpenAI DALL-E 生成图像以及 AI 播客生成。

特征

  • 用于实时流通信的服务器发送事件(SSE)
  • 用于结构化工具使用的**模型上下文协议 (MCP)**实现
  • 多种实用工具
    • Echo 工具和资源
    • 随机数生成器
    • 通过 Azure OpenAI DALL-E 3 生成图像
    • AI播客生成
    • 用于反思性回应的“思考工具”

先决条件

  • Python 3.10+
  • Azure OpenAI API 访问(用于图像生成)

安装

  1. 克隆存储库:
git clone <repository-url> cd fastapi_sse_mcp_random
  1. 安装依赖项:
pip install -r requirements.txt

或者使用uv

uv pip install -e .

用法

启动服务器

使用以下命令运行服务器:

python main.py

服务器将从http://0.0.0.0:8000启动

可用端点

  • GET / :健康检查端点
  • GET /sse/ :SSE 连接端点
  • POST /messages/ :客户端消息的端点

可用工具

回声工具
{ "name": "echo_tool", "parameters": { "message": "Hello, world!" } }
随机数生成器
{ "name": "random_number", "parameters": { "min_value": 1, "max_value": 100 } }
图像生成
{ "name": "generate_image", "parameters": { "prompt": "A beautiful landscape with mountains and a lake" } }
播客一代
{ "name": "generate_podcast", "parameters": { "prompt": "The future of artificial intelligence", "duration": 5, "name1": "Mark", "voice1": "Thomas", "name2": "Sophia", "voice2": "Emily" } }
思考工具
{ "name": "think_tool", "parameters": { "input": "What are the implications of quantum computing?" } }

项目结构

  • main.py :主要的 FastAPI 应用程序和 MCP 工具实现
  • sse.py :服务器发送事件(SSE)实现
  • pyproject.toml :项目元数据和依赖项
  • requirements.txt :基本依赖项列表

依赖项

  • FastAPI:用于构建 API 的 Web 框架
  • MCP:模型上下文协议实现
  • OpenAI:Azure OpenAI 服务的客户端
  • Uvicorn:用于运行 FastAPI 应用程序的 ASGI 服务器
  • 请求:用于 API 调用的 HTTP 库

执照

[在此指定您的许可证]

贡献

[项目贡献指南]

-
security - not tested
F
license - not found
-
quality - not tested

一个实现模型上下文协议 (MCP) 以供结构化工具使用的 FastAPI 服务器,提供实用工具,包括随机数生成、通过 Azure OpenAI DALL-E 生成图像以及 AI 播客生成。

  1. 特征
    1. 先决条件
      1. 安装
        1. 用法
          1. 启动服务器
          2. 可用端点
          3. 可用工具
        2. 项目结构
          1. 依赖项
            1. 执照
              1. 贡献

                Related MCP Servers

                • -
                  security
                  A
                  license
                  -
                  quality
                  A Model Context Protocol (MCP) server implementation for the OpenLedger API. This server provides structured context to AI models according to the MCP specification.
                  Last updated -
                  8
                  TypeScript
                  Apache 2.0
                • -
                  security
                  -
                  license
                  -
                  quality
                  A Model Context Protocol server enabling AI assistants to generate images through OpenAI's DALL-E API with full support for all available options and fine-grained control.
                  Last updated -
                  JavaScript
                  MIT License
                • -
                  security
                  A
                  license
                  -
                  quality
                  A zero-configuration tool that automatically converts FastAPI endpoints into Model Context Protocol (MCP) tools, enabling AI systems to interact with your API through natural language.
                  Last updated -
                  1
                  Python
                  MIT License
                • -
                  security
                  A
                  license
                  -
                  quality
                  A command-line tool that transforms any OpenAPI service into a Model Context Protocol (MCP) server, enabling seamless integration with AI agents and tools that support the MCP specification.
                  Last updated -
                  90
                  2
                  TypeScript
                  MIT License

                View all related MCP servers

                ID: cxgfonzuny