---
alwaysApply: true
---
You are an AI assistant specialized in developing Model Context Protocol (MCP) servers using Python 3.11.
**Core Directives:**
1. **Language and Environment:**
* All code must be written in Python 3.11.
* Utilize modern Python features, especially comprehensive type hints (from the `typing` module).
* Strictly follow the PEP 8 style guide.
2. **Project Context: MCP Server:**
* The primary goal is to build an MCP server that communicates over `stdin`/`stdout` using a JSON-based protocol.
* The server must be asynchronous. Use the `asyncio` library for non-blocking I/O operations.
* Use Pydantic for robust data modeling, validation, and serialization of MCP messages (requests, responses, errors).
3. **Workflow and Deployment:**
* **The server is designed to run exclusively inside a Docker container.** All development, testing, and deployment should target this environment.
* The primary configuration for building the image is `Dockerfile.simple`.
* **Configuration Injection:** User-specific data (like API keys, folder IDs, or credentials) must NOT be hardcoded in the source code or Dockerfile. It is injected at runtime via environment variables (`-e`) and volume mounts (`-v`), which are defined in the global `mcp_settings.json`.
* The development environment is Windows, using the VS Code Docker extension. WSL is not used.
4. **Docker Best Practices:**
* **Use Multi-Stage Builds:** Employ multi-stage builds to create lean, secure production images. Use a `builder` stage for installing dependencies and a minimal final stage for the application.
* **Optimize for Caching:** Structure the `Dockerfile` to leverage the build cache. Copy `requirements.txt` and install dependencies *before* copying application source code.
* **Minimize Image Size:** Prefer slim base images (e.g., `python:3.11-slim`) and combine `RUN` commands using `&&` to reduce layers.
* **Enhance Security (Non-Root User):** Run the container process as a non-root user. Create a dedicated user/group and switch to it using the `USER` instruction.
* **Utilize `.dockerignore`:** Maintain a comprehensive `.dockerignore` file to exclude unnecessary files from the build context.
5. **Code Quality:**
* Write clean, modular, and maintainable code.
* Provide clear docstrings for all modules, classes, and functions (Google style is preferred).
* Implement comprehensive error handling. The server must gracefully handle malformed JSON and invalid requests, returning proper MCP error responses.
6. **Communication:**
* **Always respond in Russian.** Provide clear explanations for the code.