Skip to main content
Glama
pydantic

mcp-run-python

Official
by pydantic

MCP 파이썬 실행

샌드박스에서 Python 코드를 실행하기 위한 모델 컨텍스트 프로토콜 서버입니다.

이 코드는 Deno 의 Pyodide를 사용하여 실행되므로 운영 체제의 나머지 부분과 격리됩니다.

전체 문서는 https://ai.pydantic.dev/mcp/run-python/에서 확인하세요.

다음을 사용하여 deno 설치하여 서버를 실행할 수 있습니다.

지엑스피1

어디:

  • -N -R=node_modules -W=node_modules ( --allow-net --allow-read=node_modules --allow-write=node_modules 의 별칭)는 네트워크 접근 및 ./node_modules 에 대한 읽기+쓰기 접근을 허용합니다. 이는 pyodide가 Python 표준 라이브러리와 패키지를 다운로드하고 캐시하는 데 필요합니다.

  • --node-modules-dir=auto 는 deno에게 로컬 node_modules 디렉토리를 사용하도록 지시합니다.

  • stdioStdio MCP 전송을 사용하여 서버를 실행합니다. 이는 로컬에서 하위 프로세스로 프로세스를 실행하는 데 적합합니다.

  • sseSSE MCP 전송을 사용하여 서버를 실행합니다. 즉, 로컬 또는 원격으로 연결하기 위해 서버를 HTTP 서버로 실행합니다.

  • warmup Python 표준 라이브러리를 다운로드하고 캐시하는 최소한의 Python 스크립트를 실행합니다. 이는 서버가 정상적으로 작동하는지 확인하는 데에도 유용합니다.

다음은 PydanticAI와 함께 @pydantic/mcp-run-python 사용하는 예입니다.

from pydantic_ai import Agent
from pydantic_ai.mcp import MCPServerStdio

import logfire

logfire.configure()
logfire.instrument_mcp()
logfire.instrument_pydantic_ai()

server = MCPServerStdio('deno',
    args=[
        'run',
        '-N',
        '-R=node_modules',
        '-W=node_modules',
        '--node-modules-dir=auto',
        'jsr:@pydantic/mcp-run-python',
        'stdio',
    ])
agent = Agent('claude-3-5-haiku-latest', mcp_servers=[server])


async def main():
    async with agent.run_mcp_servers():
        result = await agent.run('How many days between 2000-01-01 and 2025-03-18?')
    print(result.output)
    #> There are 9,208 days between January 1, 2000, and March 18, 2025.w

if __name__ == '__main__':
    import asyncio
    asyncio.run(main())

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that allows management and execution of Blender Python scripts, enabling users to create, edit and run scripts in a headless Blender environment through natural language interfaces.
    11
    -
  • A
    license
    Not graded
    quality
    Not graded
    maintenance
    A streamlined foundation for building Model Context Protocol servers in Python, designed to make AI-assisted development of MCP tools easier and more efficient.
    12
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    A Python-based implementation of the Model Context Protocol that enables communication between a model context management server and client through a request-response architecture.
    -