YM

yonaka15/mcp-pyodide

Developer tools

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

19 stars 6 forks 품질 53 트렌드 22MIT

모델 Context Protocol (MCP)에 대한 Pyodide 서버 구현.

개요

모델 Context Protocol (MCP)에 대한 Pyodide 서버 구현. 이 서버는 MCP 인터페이스를 통해 Python 코드를 실행하기 위해 큰 언어 모델 (LLMs)을 활성화합니다. - Pyodide - MCP 호환 서버 구현을 사용하여 LLM에 대한 Python 코드 실행 기능 - stdio 및 SSE 운송 모드 모두 지원 - TypeScript에서 작성된 Robust 구현 - 명령행 도구로 사용 가능 SSE 모드에서 실행할 때 서버는 다음과 같은 엔드포인트를 제공합니다. - SSE 연결: http://localhost:3020/sse - 메시지 핸들러: http://localhost:3020/messages - @modelcontextprotocol/sdk: MCP SDK (^1.4.0) - pyodide: Python runtime environment (^0.27.1) - arktype: Type validation library (^2.0.1) - express: SSE 지원을위한 웹 프레임 워크 - cor: SSE 지원을위한 CORS 미들웨어 - 노드.

개요(AI 번역)

모델 Context Protocol (MCP)에 대한 Pyodide 서버 구현. 이 서버는 MCP 인터페이스를 통해 Python 코드를 실행하기 위해 큰 언어 모델 (LLMs)을 활성화합니다.

특징

  • Pyodide를 사용하여 LLM을 위한 Python 코드 실행 기능
  • MCP 준수 서버 구현
  • stdio와 SSE 수송 형태 둘 다를 위한 지원
  • TypeScript에 기록된 튼튼한 구현
  • 명령줄 도구로 사용 가능

설치

사용법

서버로

명령줄 도구로

stdio 형태 (과태)에서 시작:

SSE 모드에서 시작:

SSE 형태

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

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

클라이언트 연결 보기:

프로젝트 구조

종점

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

개발

요구 사항

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

설정

스크립트

  • [T7]]: Compile TypeScript 및 설정 실행 권한

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

README

원문 README의 일부입니다. 원문 보기.

mcp-pyodide

A Pyodide server implementation for the Model Context Protocol (MCP). This server enables Large Language Models (LLMs) to execute Python code through the MCP interface.

Features

  • Python code execution capability for LLMs using Pyodide
  • MCP compliant server implementation
  • Support for both stdio and SSE transport modes
  • Robust implementation written in TypeScript
  • Available as a command-line tool

Installation

npm install mcp-pyodide

Usage

As a Server

import { runServer } from "mcp-pyodide";

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

As a Command-line Tool

Start in stdio mode (default):

mcp-pyodide

Start in SSE mode:

mcp-pyodide --sse

SSE Mode

When running in SSE mode, the server provides the following endpoints:

  • SSE Connection: http://localhost:3020/sse
  • Message Handler: http://localhost:3020/messages

Example client connection:

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

Project Structure

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

Dependencies

  • @modelcontextprotocol/sdk: MCP SDK (^1.4.0)
  • pyodide: Python runtime environment (^0.27.1)
  • arktype: Type validation library (^2.0.1)
  • express: Web framework for SSE support
  • cors: CORS middleware for SSE support

Development

Requirements

  • Node.js 18 or higher
  • npm 9 or higher

Setup

# Clone the repository
git clone 

# Install dependencies
npm install

# Build
npm run build

Scripts

  • npm run build: Compile TypeScript and set execution permissions
  • npm start: Run server in stdio mode
  • npm run start:sse: Run server in SSE mode

Environment Variables

  • PYODIDE_CACHE_DIR: Directory for Pyodide cache (default: “./cache”)
  • PYODIDE_DATA_DIR: Directory for mounted data (default: “./data”)
  • PORT: Port for SSE server (default: 3020)

License

MIT

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -am 'Add some amazing feature')
GitHub에서 전체 README 보기

설치

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

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