mcp-pyodide

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

Integrations

  • Used as the web framework for SSE (Server-Sent Events) support, providing endpoints for SSE connection and message handling

  • The server runs on Node.js, requiring version 18 or higher for development

  • Used for package management and running scripts for the MCP server

mcp-피오다이드

모델 컨텍스트 프로토콜(MCP)을 위한 Pyodide 서버 구현입니다. 이 서버는 대규모 언어 모델(LLM)이 MCP 인터페이스를 통해 Python 코드를 실행할 수 있도록 지원합니다.

특징

  • Pyodide를 사용한 LLM을 위한 Python 코드 실행 기능
  • MCP 호환 서버 구현
  • stdio 및 SSE 전송 모드 모두 지원
  • TypeScript로 작성된 강력한 구현
  • 명령줄 도구로 사용 가능

설치

지엑스피1

용법

서버로서

import { runServer } from "mcp-pyodide"; // Start the server runServer().catch((error: unknown) => { console.error("Error starting server:", error); process.exit(1); });

명령줄 도구로

stdio 모드로 시작(기본값):

mcp-pyodide

SSE 모드에서 시작:

mcp-pyodide --sse

SSE 모드

SSE 모드에서 실행할 때 서버는 다음과 같은 엔드포인트를 제공합니다.

  • SSE 연결: http://localhost:3020/sse
  • 메시지 핸들러: http://localhost:3020/messages

클라이언트 연결 예:

const eventSource = new EventSource("http://localhost:3020/sse"); eventSource.onmessage = (event) => { console.log("Received:", JSON.parse(event.data)); };

프로젝트 구조

mcp-pyodide/ ├── src/ │ ├── formatters/ # Data formatting handlers │ ├── handlers/ # Request handlers │ ├── lib/ # Library code │ ├── tools/ # Utility tools │ ├── utils/ # Utility functions │ └── index.ts # Main entry point ├── build/ # Build artifacts ├── pyodide-packages/ # Pyodide-related packages └── package.json

종속성

  • @modelcontextprotocol/sdk : MCP SDK (^1.4.0)
  • pyodide : Python 런타임 환경 (^0.27.1)
  • arktype : 유형 검증 라이브러리 (^2.0.1)
  • express : SSE 지원을 위한 웹 프레임워크
  • cors : SSE 지원을 위한 CORS 미들웨어

개발

요구 사항

  • Node.js 18 이상
  • npm 9 이상

설정

# Clone the repository git clone <repository-url> # Install dependencies npm install # Build npm run build

스크립트

  • npm run build : TypeScript를 컴파일하고 실행 권한을 설정합니다.
  • npm start : stdio 모드로 서버 실행
  • npm run start:sse : SSE 모드로 서버를 실행합니다.

환경 변수

  • PYODIDE_CACHE_DIR : Pyodide 캐시 디렉토리(기본값: "./cache")
  • PYODIDE_DATA_DIR : 마운트된 데이터의 디렉토리(기본값: "./data")
  • PORT : SSE 서버용 포트(기본값: 3020)

특허

MIT

기여하다

  1. 저장소를 포크하세요
  2. 기능 브랜치를 생성합니다( git checkout -b feature/amazing-feature )
  3. 변경 사항을 커밋합니다( git commit -am 'Add some amazing feature' )
  4. 브랜치에 푸시( git push origin feature/amazing-feature )
  5. 풀 리퀘스트 만들기

중요 참고 사항

  • 이 프로젝트는 개발 중이며 API가 변경될 수 있습니다.
  • 생산에 사용하기 전에 철저히 테스트하세요
  • 보안상의 이유로 신뢰할 수 없는 코드를 실행할 때는 주의하십시오.
  • SSE 모드를 사용할 때 필요한 경우 적절한 CORS 구성을 확인하세요.

지원하다

문제와 질문이 있으면 이슈 추적기를 이용하세요.

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

모델 컨텍스트 프로토콜(MCP)을 통해 대규모 언어 모델(LLM)로 Python 코드를 실행하기 위한 Pyodide 서버입니다.

  1. Features
    1. Installation
      1. Usage
        1. As a Server
        2. As a Command-line Tool
        3. SSE Mode
      2. Project Structure
        1. Dependencies
          1. Development
            1. Requirements
            2. Setup
            3. Scripts
          2. Environment Variables
            1. License
              1. Contributing
                1. Important Notes
                  1. Support
                    ID: pxls43joly