Sponsored by Deepsite.site

Table of Contents

Created By
aygp-dr8 months ago
A secure, isolated environment for exploring Python development with Model Context Protocol (MCP) and Language Server Protocol (LSP)
Content

Table of Contents

  1. Overview
  2. Architecture
  3. Security Model
  4. Core Components
  5. Integration Points
  6. Getting Started
  7. Command Reference
    1. Using MCP Run Python Directly
    2. Scripts
  8. Development Workflow
  9. Project Goals
  10. References
  11. License

A secure, isolated environment for exploring Python development with Model Context Protocol (MCP) and Language Server Protocol (LSP).

Overview

This project creates an isolated container environment that combines MCP and LSP capabilities for Python development. By leveraging the complementary strengths of both protocols, we enable LLMs to access powerful code intelligence features while maintaining strict security boundaries.

Architecture

graph TD
    A[Host System]
    B[API Keys]
    C[Alpine Container]
    D[Run-Python MCP]
    E[MultilspyLSP]
    F[Python LSP Server]
    G[Client Tools]
    H[Python Algorithms]

    A --> B
    A --> C
    B --> D
    B --> E
    C --> D
    C --> E
    C --> F
    C --> G
    C --> H

    D --> H
    E --> F
    F --> H

    G --> D
    G --> E

Security Model

The project implements a principle of least access architecture:

  • Container isolation from host system
  • Non-root user execution within container
  • Restricted port exposure (bound to localhost only)
  • Secure secrets management via GitHub Secrets
  • Resource limits on container (memory, CPU)
  • Input validation and sanitization
  • Clear security domain boundaries between components

See <./SECURITY.md> for comprehensive security guidelines and best practices.

Core Components

  • Pydantic Run-Python: Executes Python code via MCP
  • MultilspyLSP: Bridges LSP capabilities to MCP
  • Python LSP Server: Provides code intelligence (completion, analysis, diagnostics)
  • Client Interfaces: Multiple access methods with the same security model

Integration Points

ComponentProtocolFunction
Run-PythonMCPCode execution and output capture
MultilspyLSPMCP+LSPCode intelligence bridge
Python LSPLSPStatic analysis and completion
Claude Code-AI-assisted analysis and exploration

Getting Started

  1. Initial setup:

    Create required directories

    make dirs

    Generate configuration files from org sources

    make tangle

    Set up GitHub CLI authentication for secrets

    gh auth login

  2. Set up secrets management:

    Run the secrets setup script

    ./scripts/setup_secrets.sh

    Or manually update the GitHub secrets with your actual keys

    gh secret edit GH_PAT gh secret edit ANTHROPIC_API_KEY

  3. Build and run the container:

    Build the Docker/Podman image

    make build

    Run the container (automatically retrieves secrets)

    make run

  4. Test the environment:

    Verify MCP server connectivity

    make test

    Try analyzing an algorithm (after creating one)

    make analyze ALGO=fibonacci

Command Reference

Run make or gmake help for a full list of available commands.

Key commands for getting started:

  • make build - Build the Docker/Podman image
  • make run - Start container with mounted volumes
  • make test - Verify MCP server connectivity
  • make analyze ALGO=fibonacci - Analyze algorithm via MCP

Using MCP Run Python Directly

You can interact with the MCP Run Python server directly using Deno. The correct JSON-RPC format for calling Python code is:

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "run_python_code",
    "arguments": {
      "python_code": "print(\"Hello, MCP!\")"
    }
  },
  "id": 1
}

Example usage:

echo '{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "run_python_code", "arguments": {"python_code": "result = 40 + 2\nprint(f\"The answer is: {result}\")\nresult"}}, "id": 1}' | \
deno run -N -R=node_modules -W=node_modules --node-modules-dir=auto \
--allow-read=. jsr:@pydantic/mcp-run-python stdio | jq

To access the algorithms in this repository, use:

import sys
sys.path.append('.')
from algorithms.factorial import factorial_iterative

result = factorial_iterative(5)
print(f"Factorial of 5 is {result}")

Before committing changes, always run:

  1. gmake help - Verify all targets are documented
  2. gmake lint - Ensure code passes style checks
  3. gmake test - Verify functionality works

The project uses literate programming with org-mode. Configuration files are generated from env-setup.org using the tangle process. If you modify generated files directly, use detangle to propagate changes back to the org source.

Scripts

Utility scripts are available in the scripts/ directory. Scripts include setup tools, MCP management, and analysis utilities. Use `ls -la scripts/` to see all available scripts.

Development Workflow

This project follows a literate programming approach with org-mode. Key development files:

  • env-setup.org - Contains configuration for Emacs, VSCode, and Claude Code
  • SETUP.org - Contains general setup instructions and documentation
  • Makefile - Provides automation for common development tasks

When making changes:

  1. For configuration: Edit the org files and run make tangle
  2. For implementation: Follow standard Git workflow with conventional commits
  3. For testing: Add algorithms to algorithms/ directory and use make analyze

Project Goals

  1. Demonstrate secure integration between MCP and LSP
  2. Provide a reference architecture for isolated AI code analysis
  3. Enable exploration of Python algorithm implementations
  4. Support multiple client interfaces while maintaining security

References

License

MIT License

Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
CursorThe AI Code Editor
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Playwright McpPlaywright MCP server
Amap Maps高德地图官方 MCP Server
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Serper MCP ServerA Serper MCP Server
Tavily Mcp
WindsurfThe new purpose-built IDE to harness magic
DeepChatYour AI Partner on Desktop
ChatWiseThe second fastest AI chatbot™
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"