SM

stepanogil/mcp-sse-demo

Developer tools

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요. 원문 보기

37 stars 6 forks 품질 43 트렌드 0

이 저장소는 Zapier MCP 서버와 상호 작용하기 위해 Server-Sent Events (SSE)를 사용하여 Model Context Protocol (MCP)을 사용하여 AI 에이전트를 통해 Gmail 기능에 액세스 할 수 있습니다.

개요

이 저장소는 Zapier MCP 서버와 상호 작용하기 위해 Server-Sent Events (SSE)를 사용하여 Model Context Protocol (MCP)을 사용하여 AI 에이전트를 통해 Gmail 기능에 액세스 할 수 있습니다. 선택의 LLM을 가진 원격 호스팅 MCP 서버를 통합하는 것을 보여줍니다 (클래드 데스크탑 앱 또는 커서를 통해 아닙니다) 업데이트: SSE는 stremable HTTP의 호의로 deprecated. 나는 FastMCP를 통해 이것을 사용하여 예를 추가했습니다. 여기에 노트북 프로젝트는 OpenAI 모델(gpt-4o-mini)을 사용하여 사용자 요청을 이해하고 Gmail 액션(tool)이 필요한 경우 결정하고 Zapier MCP 서버를 통해 실행합니다. * mcp clients/zapier mcp client.py: SSE에 Zapier MCP 서버에 연결하여 GmailMCP클래스 클래스를 포함하고, 사용 가능한 도구를 나열하고, 연결을 관리합니다. * chat.py: 채팅 애플리케이션 논리. 그것은 GmailMCPClient를 초기화, Zapier 서버에 연결, 검색 도구, 도구 호출을 실행하고 합성 LLM에 대한 도구 출력을 전달. (이.

개요(AI 번역)

이 저장소는 Zapier MCP 서버와 상호 작용하기 위해 Server-Sent Events (SSE)를 사용하여 Model Context Protocol (MCP)을 사용하여 AI 에이전트를 통해 Gmail 기능에 액세스 할 수 있습니다.

선택의 LLM을 가진 원격 호스팅 MCP 서버를 통합하는 것을 보여줍니다 (클래드 데스크탑 앱 또는 커서를 통해 아닙니다)

업데이트: SSE는 stremable HTTP의 호의로 deprecated. 나는 FastMCP를 통해 이것을 사용하여 예를 추가했습니다. 여기에 노트북

개요

이 프로젝트는 OpenAI 모델(gpt-4o-mini])을 사용하여 사용자 요청을 이해하고 Gmail 액션(tool)이 필요하다면 Zapier MCP 서버를 통해 실행합니다.

키 파일

  • mcp_clients/zapier_mcp_client.py: SSE에 Zapier MCP 서버 연결에 대한 GmailMCPClient 클래스를 포함하고, 사용 가능한 도구를 나열하고, 연결을 관리합니다.
  • chat.py: 채팅 애플리케이션 논리. 그것은 GmailMCPClient]를 초기화, Zapier 서버에 연결, 검색 도구, 도구 호출을 실행하고 합성 LLM에 대한 도구 출력을 전달. (즉, 익숙한 함수 호출 패턴)

필수품

  • 파이썬 3.8+
  • OpenAI API 키
  • MCP 액세스와 Zapier 계정

설치

  1. ** 저장소 : **

이 페이지는 AI로 자동 번역되었습니다. 기술적인 세부 사항은 원문을 확인하세요.

README

MCP SSE Demo

This repository demonstrates using the Model Context Protocol (MCP) with Server-Sent Events (SSE) to interact with a Zapier MCP server, enabling access to Gmail functionalities through an AI agent.

It illustrates integrating a remotely hosted MCP server with your LLM of choice (i.e. not via the Claude desktop app or Cursor)

Update: SSE is being deprecated in favor of Stremable HTTP. I’ve added an example using this via FastMCP. Notebook here

Overview

The project uses an OpenAI model (gpt-4o-mini) to understand user requests, determine if a Gmail action (tool) is needed, and execute it via the Zapier MCP server.

Key Files

  • mcp_clients/zapier_mcp_client.py: Contains the GmailMCPClient class responsible for connecting to the Zapier MCP server over SSE, listing available tools, and managing the connection.
  • chat.py: The chat application logic. It initializes the GmailMCPClient, connects to the Zapier server, retrieves tools, execute the tool call and pass the tool output to the LLM for synthesis. (i.e. the familiar function calling pattern)

Prerequisites

  • Python 3.8+
  • OpenAI API key
  • Zapier account with MCP access

Setup

  1. Clone the repository:

    git clone 
    cd 
    
  2. Create a virtual environment and install dependencies:

    python -m venv .venv
    source .venv/bin/activate
    pip install openai python-dotenv mcp nest_asyncio fastmcp
    
  3. Create a .env file:

    touch .env
    
  4. Add your credentials to the .env file:

    OPENAI_API_KEY="sk-proj-..."
    ZAPIER_URL="https://actions.zapier.com/mcp/YOUR_SECRET_KEY/sse"
    ZAPIER_URL_FASTMCP="https://mcp.zapier.com/api/mcp/s/your-secret-key/mcp"
    
    
  5. Enable the Zapier actions you want to call as tools

    via https://actions.zapier.com/settings/mcp/

    This demo uses Gmail: Find Email

Usage

The chat.py script provides an async chat(user_input) function. You can import and use this function in your own script or an interactive environment i.e. Jupyter notebook to interact with the chatbot.

Example in a Python script):

import asyncio
from chat import chat

async def main():
    user_query = "Check my latest email."
    response = await chat(user_query)
    print(response)

if __name__ == "__main__":
    asyncio.run(main())

Example in Jupyter notebook

Example using the FastMCP framework (tool discovery and invocation)

GitHub에서 전체 README 보기

설치

This server does not publish a one-line install command.

Open the repository installation guide MCP 초보자라면? mcpskill.org 가이드부터 시작하세요 →