Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
refactor: inline critical references into mcp-builder SKILL.md (#67)
marcusjezwebbe682ef09743
diff --git a/plugins/integrations/skills/mcp-builder/SKILL.md b/plugins/integrations/skills/mcp-builder/SKILL.mdindex 0dd39b70..be68bb91 100644--- a/plugins/integrations/skills/mcp-builder/SKILL.md+++ b/plugins/integrations/skills/mcp-builder/SKILL.md@@ -19,9 +19,9 @@ Build a working MCP server from a description of the tools you need. Produces aAsk what the server needs to provide:-- **Tools** — Functions Claude can call (API wrappers, calculations, file operations)-- **Resources** — Data Claude can read (database records, config, documents)-- **Prompts** — Reusable prompt templates with parameters+- **Tools** -- Functions Claude can call (API wrappers, calculations, file operations)+- **Resources** -- Data Claude can read (database records, config, documents)+- **Prompts** -- Reusable prompt templates with parametersA brief like "MCP server for querying our customer database" is enough.@@ -31,7 +31,7 @@ A brief like "MCP server for querying our customer database" is enough.pip install fastmcp```-Copy and customise `assets/basic-server.py`:+Create the server file. The server instance MUST be at module level:```pythonfrom fastmcp import FastMCP@@ -73,37 +73,110 @@ See `assets/SCRIPTS-TEMPLATE.md` and `assets/script-template.ts` for TypeScript### Step 4: Test Locally+**Quick test -- run directly:**+```bash-# Run server directlypython server.py+```++**Dev mode with inspector UI (recommended):**-# With FastMCP dev mode (auto-reload)+```bashfastmcp dev server.py+# Opens inspector at http://localhost:5173+# Hot reload, detailed logging, tool/resource inspection+```++**HTTP mode for remote clients:**-# HTTP mode for remote clients+```bashpython server.py --transport http --port 8000+```++**Automated test script using FastMCP Client:**-# Test with MCP Inspector-fastmcp dev server.py --with-editable .+```python+import asyncio+from fastmcp import Client++async def test_server(server_path):+ async with Client(server_path) as client:+ # List everything+ tools = await client.list_tools()+ resources = await client.list_resources()+ prompts = await client.list_prompts()++ print(f"Tools: {[t.name for t in tools]}")+ print(f"Resources: {[r.uri for r in resources]}")+ print(f"Prompts: {[p.name for p in prompts]}")++ # Call first tool+ if tools:+ result = await client.call_tool(tools[0].name, {})+ print(f"Tool result: {result}")++ # Read first resource+ if resources:+ data = await client.read_resource(resources[0].uri)+ print(f"Resource data: {data}")++asyncio.run(test_server("server.py"))```-For comprehensive automated testing, generate a test script using the FastMCP Client.-See [references/testing-pattern.md](references/testing-pattern.md) for the async test pattern.+### Step 5: Pre-Deploy Checklist++Run these checks before deploying. All required checks must pass.++**Required (will cause deploy failure):**-### Step 5: Deploy+1. Server file exists+2. Python syntax valid: `python3 -m py_compile server.py`+3. Module-level server object (not inside a function):+ ```bash+ grep -q "^mcp = FastMCP\|^server = FastMCP\|^app = FastMCP" server.py+ ```+4. `requirements.txt` exists with PyPI packages only (no `git+`, `-e`, `.whl`, `.tar.gz`)+5. No hardcoded secrets (check for `api_key = "..."` patterns excluding `os.getenv`/`os.environ`)-**FastMCP Cloud** (simplest):+**Advisory (warnings):**-Before deploying, work through the pre-deploy checklist in [references/deploy-checklist.md](references/deploy-checklist.md) to catch common issues (missing module-level server, hardcoded secrets, etc.).+6. `fastmcp` listed in requirements.txt+7. `.gitignore` includes `.env`+8. No circular imports+9. Git repository initialised with remote+10. Server can load: `timeout 5 fastmcp inspect server.py`++### Step 6: Deploy++**FastMCP Cloud (simplest):**```bash-fastmcp deploy server.py --name my-server+git add . && git commit -m "Ready for deployment"+git push -u origin main+# Visit https://fastmcp.cloud, connect repo, add env vars, deploy+# URL: https://your-project.fastmcp.app/mcp```-**Docker** (self-hosted):-See `references/cloud-deployment.md` for Dockerfile patterns.+Cloud requirements:+- Module-level server object named `mcp`, `server`, or `app`+- PyPI dependencies only in `requirements.txt`+- Public GitHub repository+- Environment variables for secrets (no hardcoded values)+- Auto-deploys on push to main, PR preview deployments++**Docker (self-hosted):**++```dockerfile+FROM python:3.12-slim+WORKDIR /app+COPY requirements.txt .+RUN pip install -r requirements.txt+COPY . .+EXPOSE 8000+CMD ["python", "server.py", "--transport", "http", "--port", "8000"]+```-**Cloudflare Workers** (edge):+**Cloudflare Workers (edge):**See the cloudflare-worker-builder skill for Workers-based MCP servers.---@@ -121,10 +194,16 @@ mcp = FastMCP("My Server")@mcp.tool()def my_tool(): ...-# WRONG — Cloud can't find the server+# WRONG -- Cloud can't find the serverdef create_server():mcp = FastMCP("My Server")return mcp++# FIX for factory pattern -- export at module level+def create_server() -> FastMCP:+ mcp = FastMCP("server")+ return mcp+mcp = create_server()```### Type Annotations Required@@ -156,26 +235,212 @@ async def get_data(id: str) -> str:return f"Error: No data found for ID {id}"```+### Cloud-Ready Server Pattern++```python+import os+from fastmcp import FastMCP++mcp = FastMCP("production-server")+API_KEY = os.getenv("API_KEY")++async def production_tool(data: str) -> dict:+ if not API_KEY:+ return {"error": "API_KEY not configured"}+ return {"status": "success", "data": data}++if __name__ == "__main__":+ mcp.run()+```++---++## Common Errors and Fixes++These are the errors you will hit. Fix them before deploying.++| Error | Cause | Fix |+|-------|-------|-----|+| `RuntimeError: No server object found at module level` | Server inside a function | Export `mcp = FastMCP(...)` at module level |+| `RuntimeError: no running event loop` | Missing async/await | Use `async def` for async operations |+| `TypeError: missing required argument 'context'` | Context not type-hinted | Add `context: Context` with type hint |+| `ValueError: Invalid resource URI` | Missing URI scheme | Use `data://`, `file://`, `info://`, `api://` |+| Resource template parameter mismatch | Name mismatch | `user://{user_id}` needs `def get_user(user_id: str)` |+| Pydantic validation error | Wrong type hints | Ensure hints match actual data types |+| Transport mismatch | Client/server protocol differ | Match both to stdio or both to http |+| Import errors with editable package | Package not installed | `pip install -e .` or add to PYTHONPATH |+| `DeprecationWarning: mcp.settings` | Old API | Use `os.getenv()` instead |+| Port already in use | Stale process | `lsof -ti:8000 \| xargs kill -9` |+| Schema generation failure | Non-JSON types | Use JSON-compatible types (no NumPy arrays) |+| JSON serialization error | datetime/bytes in response | Convert to `.isoformat()` or string |+| Circular import | Factory in `__init__.py` | Use direct imports, avoid factory pattern |+| Python 3.12+ datetime warning | `datetime.utcnow()` deprecated | Use `datetime.now(timezone.utc)` |+| Import-time execution | Async resource at module level | Use lazy init pattern |++---++## Production Patterns++### Self-Contained Server++Keep all utilities in one file to avoid circular imports:++```python+from fastmcp import FastMCP+import os++mcp = FastMCP("my-server")++# Config+class Config:+ API_KEY = os.getenv("API_KEY", "")+ BASE_URL = os.getenv("BASE_URL", "https://api.example.com")++# Helpers+def format_success(data): return {"status": "success", "data": data}+def format_error(msg): return {"status": "error", "message": msg}++async def my_tool(query: str) -> dict:+ if not Config.API_KEY:+ return format_error("API_KEY not configured")+ return format_success({"query": query})+```++### Lazy Initialisation++Don't create async resources at module level. Initialise on first use:++```python+_db = None++async def get_db():+ global _db+ if _db is None:+ _db = await create_connection(Config.DB_URL)+ return _db+```++### Health Check Resource++```python[email protected]("health://status")+async def health_check() -> dict:+ return {+ "status": "healthy",+ "version": "1.0.0",+ "checks": {+ "api": "connected",+ "database": "connected"+ }+ }+```++### Connection Pooling++```python+import httpx++_client = None++def get_client() -> httpx.AsyncClient:+ global _client+ if _client is None:+ _client = httpx.AsyncClient(+ base_url=Config.BASE_URL,+ headers={"Authorization": f"Bearer {Config.API_KEY}"},+ limits=httpx.Limits(max_connections=20, max_keepalive_connections=5),+ timeout=30.0+ )+ return _client+```++### Retry with Backoff++```python+async def retry_with_backoff(func, max_retries=3, initial_delay=1.0):+ for attempt in range(max_retries):+ try:+ return await func()+ except Exception as e:+ if attempt == max_retries - 1:+ raise+ delay = initial_delay * (2 ** attempt)+ await asyncio.sleep(delay)+```++---++## Context Features (Advanced)++### Context Injection++```python+from fastmcp import Context++async def tool_with_context(param: str, context: Context) -> dict:+ # Context parameter MUST have type hint+ pass+```++### Progress Tracking++```python+async def long_task(items: list[str], context: Context) -> str:+ for i, item in enumerate(items):+ await context.report_progress(i + 1, len(items), f"Processing {item}")+ await process(item)+ return "Done"+```++### Sampling (LLM from within tools)++```python+async def summarise(text: str, context: Context) -> str:+ result = await context.request_sampling(+ messages=[{"role": "user", "content": f"Summarise: {text}"}],+ max_tokens=200+ )+ return result+```++---++## CLI Quick Reference++```bash+fastmcp dev server.py # Dev mode with inspector UI+fastmcp run server.py # Run (stdio)+fastmcp run server.py --transport http --port 8000 # Run (HTTP)+fastmcp inspect server.py # Inspect without running+fastmcp install server.py # Install to Claude Desktop+fastmcp deploy server.py --name my-server # Deploy to Cloud+```++Environment variables: `FASTMCP_LOG_LEVEL` (DEBUG/INFO/WARNING/ERROR), `FASTMCP_ENV` (development/staging/production).++---++## Integration Patterns (Optional)++For specific integration approaches, see `references/integration-patterns.md`:+- **Manual API** -- `httpx.AsyncClient` with reusable client+- **OpenAPI auto-generation** -- `FastMCP.from_openapi(spec, client, route_maps=[...])`+- **FastAPI conversion** -- `FastMCP.from_fastapi(app)`+---## Asset Files-- `assets/basic-server.py` — Minimal FastMCP server template-- `assets/self-contained-server.py` — Server with storage and middleware-- `assets/tools-examples.py` — Tool patterns and type annotations-- `assets/resources-examples.py` — Resource URI patterns-- `assets/prompts-examples.py` — Prompt template patterns-- `assets/client-example.py` — MCP client usage-- `assets/SCRIPTS-TEMPLATE.md` — CLI companion docs template-- `assets/script-template.ts` — TypeScript CLI script template--## Reference Files--- `references/common-errors.md` — 30+ documented errors with fixes-- `references/cli-commands.md` — FastMCP CLI reference-- `references/cloud-deployment.md` — Deployment patterns (Cloud, Docker, Workers)-- `references/production-patterns.md` — Auth, middleware, storage backends-- `references/integration-patterns.md` — FastAPI mount, OpenAPI import-- `references/context-features.md` — Lifespan, dependency injection-- `references/testing-pattern.md` — FastMCP Client async test pattern-- `references/deploy-checklist.md` — Pre-deploy validation checklist+- `assets/basic-server.py` -- Minimal FastMCP server template+- `assets/self-contained-server.py` -- Server with storage and middleware+- `assets/tools-examples.py` -- Tool patterns and type annotations+- `assets/resources-examples.py` -- Resource URI patterns+- `assets/prompts-examples.py` -- Prompt template patterns+- `assets/client-example.py` -- MCP client usage+- `assets/SCRIPTS-TEMPLATE.md` -- CLI companion docs template+- `assets/script-template.ts` -- TypeScript CLI script templatediff --git a/plugins/integrations/skills/mcp-builder/references/cli-commands.md b/plugins/integrations/skills/mcp-builder/references/cli-commands.mddeleted file mode 100644index addf1a01..00000000--- a/plugins/integrations/skills/mcp-builder/references/cli-commands.md+++ /dev/null@@ -1,417 +0,0 @@-# FastMCP CLI Commands Reference--Complete reference for FastMCP command-line interface.--## Installation--```bash-# Install FastMCP-pip install fastmcp--# or with uv-uv pip install fastmcp--# Check version-fastmcp --version-```--## Development Commands--### `fastmcp dev`--Run server with inspector interface (recommended for development).--```bash-# Basic usage-fastmcp dev server.py--# With options-fastmcp dev server.py --port 8000--# Enable debug logging-FASTMCP_LOG_LEVEL=DEBUG fastmcp dev server.py-```--**Features:**-- Interactive inspector UI-- Hot reload on file changes-- Detailed logging-- Tool/resource inspection--### `fastmcp run`--Run server normally (production-like).--```bash-# stdio transport (default)-fastmcp run server.py--# HTTP transport-fastmcp run server.py --transport http --port 8000--# SSE transport-fastmcp run server.py --transport sse-```--**Options:**-- `--transport`: `stdio`, `http`, or `sse`-- `--port`: Port number (for HTTP/SSE)-- `--host`: Host address (default: 127.0.0.1)--### `fastmcp inspect`--Inspect server without running it.--```bash-# Inspect tools and resources-fastmcp inspect server.py--# Output as JSON-fastmcp inspect server.py --json--# Show detailed information-fastmcp inspect server.py --verbose-```--**Output includes:**-- List of tools-- List of resources-- List of prompts-- Configuration details--## Installation Commands--### `fastmcp install`--Install server to Claude Desktop.--```bash-# Basic installation-fastmcp install server.py--# With custom name-fastmcp install server.py --name "My Server"--# Specify config location-fastmcp install server.py --config-path ~/.config/Claude/claude_desktop_config.json-```--**What it does:**-- Adds server to Claude Desktop configuration-- Sets up proper command and arguments-- Validates server before installing--### Claude Desktop Configuration--Manual configuration (if not using `fastmcp install`):--```json-{- "mcpServers": {- "my-server": {- "command": "python",- "args": ["/absolute/path/to/server.py"],- "env": {- "API_KEY": "your-key"- }- }- }-}-```--**Config locations:**-- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`-- **Linux**: `~/.config/Claude/claude_desktop_config.json`-- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`--## Python Direct Execution--### Run with Python--```bash-# stdio (default)-python server.py--# HTTP transport-python server.py --transport http --port 8000--# With arguments-python server.py --transport http --port 8000 --host 0.0.0.0-```--### Custom Argument Parsing--```python-# server.py-if __name__ == "__main__":- import sys-- # Parse custom arguments- if "--test" in sys.argv:- run_tests()- elif "--migrate" in sys.argv:- run_migrations()- else:- mcp.run()-```--## Environment Variables--### FastMCP-Specific Variables--```bash-# Logging-export FASTMCP_LOG_LEVEL=DEBUG # DEBUG, INFO, WARNING, ERROR-export FASTMCP_LOG_FILE=/path/to/log.txt--# Environment-export FASTMCP_ENV=production # development, staging, production--# Custom variables (your server)-export API_KEY=your-key-export DATABASE_URL=postgres://...-```--### Using with Commands--```bash-# Inline environment variables-API_KEY=test fastmcp dev server.py--# From .env file-set -a && source .env && set +a && fastmcp dev server.py-```--## Testing Commands--### Run Tests with Client--```python-# test.py-import asyncio-from fastmcp import Client--async def test():- async with Client("server.py") as client:- tools = await client.list_tools()- print(f"Tools: {[t.name for t in tools]}")--asyncio.run(test())-```--```bash-# Run tests-python test.py-```--### Integration Testing--```bash-# Start server in background-fastmcp run server.py --transport http --port 8000 &-SERVER_PID=$!--# Run tests-pytest tests/--# Kill server-kill $SERVER_PID-```--## Debugging Commands--### Enable Debug Logging--```bash-# Full debug output-FASTMCP_LOG_LEVEL=DEBUG fastmcp dev server.py--# Python logging-PYTHONVERBOSE=1 fastmcp dev server.py--# Trace imports-PYTHONPATH=. python -v server.py-```--### Check Python Environment--```bash-# Check Python version-python --version--# Check installed packages-pip list | grep fastmcp--# Check import paths-python -c "import sys; print('\n'.join(sys.path))"-```--### Validate Server--```bash-# Check syntax-python -m py_compile server.py--# Check imports-python -c "import server; print('OK')"--# Inspect structure-fastmcp inspect server.py --verbose-```--## Deployment Commands--### Prepare for Deployment--```bash-# Freeze dependencies-pip freeze > requirements.txt--# Clean specific to FastMCP-echo "fastmcp>=2.12.0" > requirements.txt-echo "httpx>=0.27.0" >> requirements.txt--# Test with clean environment-python -m venv test_env-source test_env/bin/activate-pip install -r requirements.txt-python server.py-```--### Git Commands for Deployment--```bash-# Prepare for cloud deployment-git add server.py requirements.txt-git commit -m "Prepare for deployment"--# Create GitHub repo-gh repo create my-mcp-server --public--# Push-git push -u origin main-```--## Performance Commands--### Profiling--```bash-# Profile with cProfile-python -m cProfile -o profile.stats server.py--# Analyze profile-python -m pstats profile.stats-```--### Memory Profiling--```bash-# Install memory_profiler-pip install memory_profiler--# Run with memory profiling-python -m memory_profiler server.py-```--## Batch Operations--### Multiple Servers--```bash-# Start multiple servers-fastmcp run server1.py --port 8000 &-fastmcp run server2.py --port 8001 &-fastmcp run server3.py --port 8002 &--# Kill all-killall -9 python-```--### Process Management--```bash-# Use screen/tmux for persistent sessions-screen -S fastmcp-fastmcp dev server.py-# Detach: Ctrl+A, D--# Reattach-screen -r fastmcp-```--## Common Command Patterns--### Local Development--```bash-# Quick iteration cycle-fastmcp dev server.py # Edit, save, auto-reload-```--### Testing with HTTP Client--```bash-# Start HTTP server-fastmcp run server.py --transport http --port 8000--# Test with curl-curl -X POST http://localhost:8000/mcp \- -H "Content-Type: application/json" \- -d '{"method": "tools/list"}'-```--### Production-like Testing--```bash-# Set production environment-export ENVIRONMENT=production-export FASTMCP_LOG_LEVEL=WARNING--# Run-fastmcp run server.py-```--## Troubleshooting Commands--### Server Won't Start--```bash-# Check for syntax errors-python -m py_compile server.py--# Check for missing dependencies-pip check--# Verify FastMCP installation-python -c "import fastmcp; print(fastmcp.__version__)"-```--### Port Already in Use--```bash-# Find process using port-lsof -i :8000--# Kill process-lsof -ti:8000 | xargs kill -9--# Use different port-fastmcp run server.py --port 8001-```--### Permission Issues--```bash-# Make server executable-chmod +x server.py--# Fix Python path-export PYTHONPATH="${PYTHONPATH}:$(pwd)"-```--## Resources--- **FastMCP CLI Docs**: https://github.com/jlowin/fastmcp#cli-- **MCP Protocol**: https://modelcontextprotocol.io-- **Context7**: `/jlowin/fastmcp`diff --git a/plugins/integrations/skills/mcp-builder/references/cloud-deployment.md b/plugins/integrations/skills/mcp-builder/references/cloud-deployment.mddeleted file mode 100644index d40128cc..00000000--- a/plugins/integrations/skills/mcp-builder/references/cloud-deployment.md+++ /dev/null@@ -1,309 +0,0 @@-# FastMCP Cloud Deployment Guide--Complete guide for deploying FastMCP servers to FastMCP Cloud.--## Critical Requirements--**❗️ MUST HAVE** for FastMCP Cloud:--1. **Module-level server object** named `mcp`, `server`, or `app`-2. **PyPI dependencies only** in `requirements.txt`-3. **Public GitHub repository** (or accessible to FastMCP Cloud)-4. **Environment variables** for configuration (no hardcoded secrets)--## Cloud-Ready Server Pattern--```python-# server.py-from fastmcp import FastMCP-import os--# ✅ CORRECT: Module-level export-mcp = FastMCP("production-server")--# ✅ Use environment variables-API_KEY = os.getenv("API_KEY")-DATABASE_URL = os.getenv("DATABASE_URL")--async def production_tool(data: str) -> dict:- if not API_KEY:- return {"error": "API_KEY not configured"}- return {"status": "success", "data": data}--if __name__ == "__main__":- mcp.run()-```--## Common Anti-Patterns--### ❌ WRONG: Function-Wrapped Server--```python-def create_server():- mcp = FastMCP("server")- return mcp--if __name__ == "__main__":- server = create_server() # Too late for cloud!- server.run()-```--### ✅ CORRECT: Factory with Module Export--```python-def create_server() -> FastMCP:- mcp = FastMCP("server")- # Complex setup logic here- return mcp--# Export at module level-mcp = create_server()--if __name__ == "__main__":- mcp.run()-```--## Deployment Steps--### 1. Prepare Repository--```bash-# Initialize git-git init--# Add files-git add .--# Commit-git commit -m "Initial MCP server"--# Create GitHub repo-gh repo create my-mcp-server --public--# Push-git push -u origin main-```--### 2. Deploy to FastMCP Cloud--1. Visit https://fastmcp.cloud-2. Sign in with GitHub-3. Click "Create Project"-4. Select your repository-5. Configure:- - **Server Name**: Your project name- - **Entrypoint**: `server.py`- - **Environment Variables**: Add all needed variables--### 3. Configure Environment Variables--In FastMCP Cloud dashboard, add:-- `API_KEY`-- `DATABASE_URL`-- `CACHE_TTL`-- Any custom variables--### 4. Access Your Server--- **URL**: `https://your-project.fastmcp.app/mcp`-- **Auto-deploy**: Pushes to main branch auto-deploy-- **PR Previews**: Pull requests get preview deployments--## Project Structure Requirements--### Minimal Structure--```-my-mcp-server/-├── server.py # Main entry point (required)-├── requirements.txt # PyPI dependencies (required)-├── .env # Local dev only (git-ignored)-├── .gitignore # Must ignore .env-└── README.md # Documentation (recommended)-```--### Production Structure--```-my-mcp-server/-├── src/-│ ├── server.py # Main entry point-│ ├── utils.py # Self-contained utilities-│ └── tools/ # Tool modules-│ ├── __init__.py-│ └── api_tools.py-├── requirements.txt-├── .env.example # Template for .env-├── .gitignore-└── README.md-```--## Requirements.txt Rules--### ✅ ALLOWED: PyPI Packages--```txt-fastmcp>=2.12.0-httpx>=0.27.0-python-dotenv>=1.0.0-pydantic>=2.0.0-```--### ❌ NOT ALLOWED: Non-PyPI Dependencies--```txt-# Don't use these in cloud:-git+https://github.com/user/repo.git--e ./local-package-./wheels/package.whl-```--## Environment Variables Best Practices--### ✅ GOOD: Environment-based Configuration--```python-import os--class Config:- API_KEY = os.getenv("API_KEY", "")- BASE_URL = os.getenv("BASE_URL", "https://api.example.com")- DEBUG = os.getenv("DEBUG", "false").lower() == "true"-- @classmethod- def validate(cls):- if not cls.API_KEY:- raise ValueError("API_KEY is required")-```--### ❌ BAD: Hardcoded Values--```python-# Never do this in cloud:-API_KEY = "sk-1234567890" # Exposed in repository!-DATABASE_URL = "postgresql://user:pass@host/db" # Insecure!-```--## Avoiding Circular Imports--**Critical for cloud deployment!**--### ❌ WRONG: Factory Function in `__init__.py`--```python-# shared/__init__.py-def get_api_client():- from .api_client import APIClient # Circular import risk- return APIClient()--# shared/monitoring.py-from . import get_api_client # Creates circle!-```--### ✅ CORRECT: Direct Imports--```python-# shared/__init__.py-from .api_client import APIClient-from .cache import CacheManager--# shared/monitoring.py-from .api_client import APIClient-client = APIClient() # Create directly-```--## Testing Before Deployment--### Local Testing--```bash-# Test with stdio (default)-fastmcp dev server.py--# Test with HTTP-python server.py --transport http --port 8000-```--### Pre-Deployment Checklist--- [ ] Server object exported at module level-- [ ] Only PyPI dependencies in requirements.txt-- [ ] No hardcoded secrets (all in environment variables)-- [ ] `.env` file in `.gitignore`-- [ ] No circular imports-- [ ] No import-time async execution-- [ ] Works with `fastmcp dev server.py`-- [ ] Git repository committed and pushed-- [ ] All required environment variables documented--## Monitoring Deployment--### Check Deployment Logs--FastMCP Cloud provides:-- Build logs-- Runtime logs-- Error logs--### Health Check Endpoint--Add a health check resource:--```python[email protected]("health://status")-async def health_check() -> dict:- return {- "status": "healthy",- "timestamp": datetime.now().isoformat(),- "version": "1.0.0"- }-```--### Common Deployment Errors--1. **"No server object found"**- - Fix: Export server at module level--2. **"Module not found"**- - Fix: Use only PyPI packages--3. **"Import error: circular dependency"**- - Fix: Avoid factory functions in `__init__.py`--4. **"Environment variable not set"**- - Fix: Add variables in FastMCP Cloud dashboard--## Continuous Deployment--FastMCP Cloud automatically deploys when you push to main:--```bash-# Make changes-git add .-git commit -m "Add new feature"-git push--# Deployment happens automatically!-# Check status at fastmcp.cloud-```--## Rollback Strategy--If deployment fails:--```bash-# Revert to previous commit-git revert HEAD-git push--# Or reset to specific commit-git reset --hard <commit-hash>-git push --force # Use with caution!-```--## Resources--- **FastMCP Cloud**: https://fastmcp.cloud-- **FastMCP GitHub**: https://github.com/jlowin/fastmcp-- **Deployment Docs**: Check FastMCP Cloud documentationdiff --git a/plugins/integrations/skills/mcp-builder/references/common-errors.md b/plugins/integrations/skills/mcp-builder/references/common-errors.mddeleted file mode 100644index 83feb9bb..00000000--- a/plugins/integrations/skills/mcp-builder/references/common-errors.md+++ /dev/null@@ -1,118 +0,0 @@-# FastMCP Common Errors Reference--Quick reference for the 15 most common FastMCP errors and their solutions.--## Error 1: Missing Server Object-**Error:** `RuntimeError: No server object found at module level`-**Fix:** Export server at module level: `mcp = FastMCP("name")`-**Why:** FastMCP Cloud requires module-level server object-**Source:** FastMCP Cloud documentation--## Error 2: Async/Await Confusion-**Error:** `RuntimeError: no running event loop`-**Fix:** Use `async def` for async operations, don't mix sync/async-**Example:** Use `await client.get()` not `client.get()`-**Source:** GitHub issues #156, #203--## Error 3: Context Not Injected-**Error:** `TypeError: missing required argument 'context'`-**Fix:** Add type hint: `async def tool(context: Context):`-**Why:** Type hint is required for context injection-**Source:** FastMCP v2 migration guide--## Error 4: Resource URI Syntax-**Error:** `ValueError: Invalid resource URI`-**Fix:** Include scheme: `@mcp.resource("data://config")`-**Valid schemes:** `data://`, `file://`, `info://`, `api://`-**Source:** MCP Protocol specification--## Error 5: Resource Template Parameter Mismatch-**Error:** `TypeError: missing positional argument`-**Fix:** Match parameter names: `user://{user_id}` → `def get_user(user_id: str)`-**Why:** Parameter names must exactly match URI template-**Source:** FastMCP patterns documentation--## Error 6: Pydantic Validation Error-**Error:** `ValidationError: value is not valid`-**Fix:** Ensure type hints match data types-**Best practice:** Use Pydantic models for complex validation-**Source:** Pydantic documentation--## Error 7: Transport/Protocol Mismatch-**Error:** `ConnectionError: different transport`-**Fix:** Match client/server transport (stdio or http)-**Server:** `mcp.run(transport="http")`-**Client:** `{"transport": "http", "url": "..."}`-**Source:** MCP transport specification--## Error 8: Import Errors (Editable Package)-**Error:** `ModuleNotFoundError: No module named 'my_package'`-**Fix:** Install in editable mode: `pip install -e .`-**Alternative:** Use absolute imports or add to PYTHONPATH-**Source:** Python packaging documentation--## Error 9: Deprecation Warnings-**Error:** `DeprecationWarning: 'mcp.settings' deprecated`-**Fix:** Use `os.getenv()` instead of `mcp.settings.get()`-**Why:** FastMCP v2 removed settings API-**Source:** FastMCP v2 migration guide--## Error 10: Port Already in Use-**Error:** `OSError: [Errno 48] Address already in use`-**Fix:** Use different port: `--port 8001`-**Alternative:** Kill process: `lsof -ti:8000 | xargs kill -9`-**Source:** Common networking issue--## Error 11: Schema Generation Failures-**Error:** `TypeError: not JSON serializable`-**Fix:** Use JSON-compatible types (no NumPy arrays, custom classes)-**Example:** Convert: `data.tolist()` or `data.to_dict()`-**Source:** JSON serialization requirements--## Error 12: JSON Serialization-**Error:** `TypeError: Object of type 'datetime' not JSON serializable`-**Fix:** Convert to string: `datetime.now().isoformat()`-**Apply to:** datetime, bytes, custom objects-**Source:** JSON specification--## Error 13: Circular Import Errors-**Error:** `ImportError: cannot import name 'X' from partially initialized module`-**Fix:** Avoid factory functions in `__init__.py`, use direct imports-**Example:** Import `APIClient` directly, don't use `get_api_client()` factory-**Why:** Cloud deployment initializes modules differently-**Source:** Production cloud deployment errors--## Error 14: Python Version Compatibility-**Error:** `DeprecationWarning: datetime.utcnow() deprecated`-**Fix:** Use `datetime.now(timezone.utc)` (Python 3.12+)-**Why:** Python 3.12+ deprecated some datetime methods-**Source:** Python 3.12 release notes--## Error 15: Import-Time Execution-**Error:** `RuntimeError: Event loop is closed`-**Fix:** Don't create async resources at module level-**Example:** Use lazy initialization: create resources when needed, not at import-**Why:** Event loop not available during module import-**Source:** Async event loop management-------## Quick Debugging Checklist--When encountering errors:--1. ✅ Check server is exported at module level-2. ✅ Verify async/await usage is correct-3. ✅ Ensure Context type hints are present-4. ✅ Validate resource URIs have scheme prefixes-5. ✅ Match resource template parameters exactly-6. ✅ Use JSON-serializable types only-7. ✅ Avoid circular imports (especially in `__init__.py`)-8. ✅ Don't execute async code at module level-9. ✅ Test locally with `fastmcp dev server.py` before deploying--## Getting Help--- **FastMCP GitHub**: https://github.com/jlowin/fastmcp/issues-- **Context7 Docs**: `/jlowin/fastmcp`-- **This Skill**: See SKILL.md for detailed solutionsdiff --git a/plugins/integrations/skills/mcp-builder/references/context-features.md b/plugins/integrations/skills/mcp-builder/references/context-features.mddeleted file mode 100644index 5c1e31ea..00000000--- a/plugins/integrations/skills/mcp-builder/references/context-features.md+++ /dev/null@@ -1,475 +0,0 @@-# FastMCP Context Features Reference--Complete reference for FastMCP's advanced context features: elicitation, progress tracking, and sampling.--## Context Injection--To use context features, inject Context into your tool:--```python-from fastmcp import Context--async def tool_with_context(param: str, context: Context) -> dict:- """Tool that uses context features."""- # Access context features here- pass-```--**Important:** Context parameter MUST have type hint `Context` for injection to work.--## Feature 1: Elicitation (User Input)--Request user input during tool execution.--### Basic Usage--```python-from fastmcp import Context--async def confirm_action(action: str, context: Context) -> dict:- """Request user confirmation."""- # Request user input- user_response = await context.request_elicitation(- prompt=f"Confirm {action}? (yes/no)",- response_type=str- )-- if user_response.lower() == "yes":- result = await perform_action(action)- return {"status": "completed", "action": action}- else:- return {"status": "cancelled", "action": action}-```--### Type-Based Elicitation--```python-async def collect_user_info(context: Context) -> dict:- """Collect information from user."""- # String input- name = await context.request_elicitation(- prompt="What is your name?",- response_type=str- )-- # Boolean input- confirmed = await context.request_elicitation(- prompt="Do you want to continue?",- response_type=bool- )-- # Numeric input- count = await context.request_elicitation(- prompt="How many items?",- response_type=int- )-- return {- "name": name,- "confirmed": confirmed,- "count": count- }-```--### Custom Type Elicitation--```python-from dataclasses import dataclass--@dataclass-class UserChoice:- option: str- reason: str--async def get_user_choice(options: list[str], context: Context) -> dict:- """Get user choice with reasoning."""- choice = await context.request_elicitation(- prompt=f"Choose from: {', '.join(options)}",- response_type=UserChoice- )-- return {- "selected": choice.option,- "reason": choice.reason- }-```--### Client Handler for Elicitation--Client must provide handler:--```python-from fastmcp import Client--async def elicitation_handler(message: str, response_type: type, context: dict):- """Handle elicitation requests."""- if response_type == str:- return input(f"{message}: ")- elif response_type == bool:- response = input(f"{message} (y/n): ")- return response.lower() == 'y'- elif response_type == int:- return int(input(f"{message}: "))- else:- return input(f"{message}: ")--async with Client(- "server.py",- elicitation_handler=elicitation_handler-) as client:- result = await client.call_tool("collect_user_info", {})-```--## Feature 2: Progress Tracking--Report progress for long-running operations.--### Basic Progress--```python-async def long_operation(count: int, context: Context) -> dict:- """Operation with progress tracking."""- for i in range(count):- # Report progress- await context.report_progress(- progress=i + 1,- total=count,- message=f"Processing item {i + 1}/{count}"- )-- # Do work- await asyncio.sleep(0.1)-- return {"status": "completed", "processed": count}-```--### Multi-Phase Progress--```python-async def multi_phase_operation(data: list, context: Context) -> dict:- """Operation with multiple phases."""- # Phase 1: Loading- await context.report_progress(0, 3, "Phase 1: Loading data")- loaded = await load_data(data)-- # Phase 2: Processing- await context.report_progress(1, 3, "Phase 2: Processing")- for i, item in enumerate(loaded):- await context.report_progress(- progress=i,- total=len(loaded),- message=f"Processing {i + 1}/{len(loaded)}"- )- await process_item(item)-- # Phase 3: Saving- await context.report_progress(2, 3, "Phase 3: Saving results")- await save_results()-- await context.report_progress(3, 3, "Complete!")-- return {"status": "completed", "items": len(loaded)}-```--### Indeterminate Progress--For operations where total is unknown:--```python-async def indeterminate_operation(context: Context) -> dict:- """Operation with unknown duration."""- stages = [- "Initializing",- "Loading data",- "Processing",- "Finalizing"- ]-- for stage in stages:- # No total - shows as spinner/indeterminate- await context.report_progress(- progress=stages.index(stage),- total=None,- message=stage- )- await perform_stage(stage)-- return {"status": "completed"}-```--### Client Handler for Progress--```python-async def progress_handler(progress: float, total: float | None, message: str | None):- """Handle progress updates."""- if total:- pct = (progress / total) * 100- # Use \r for same-line update- print(f"\r[{pct:.1f}%] {message}", end="", flush=True)- else:- # Indeterminate progress- print(f"\n[PROGRESS] {message}")--async with Client(- "server.py",- progress_handler=progress_handler-) as client:- result = await client.call_tool("long_operation", {"count": 100})-```--## Feature 3: Sampling (LLM Integration)--Request LLM completions from within tools.--### Basic Sampling--```python-async def enhance_text(text: str, context: Context) -> str:- """Enhance text using LLM."""- response = await context.request_sampling(- messages=[{- "role": "system",- "content": "You are a professional copywriter."- }, {- "role": "user",- "content": f"Enhance this text: {text}"- }],- temperature=0.7,- max_tokens=500- )-- return response["content"]-```--### Structured Output with Sampling--```python-async def classify_text(text: str, context: Context) -> dict:- """Classify text using LLM."""- prompt = f"""- Classify this text: {text}-- Return JSON with:- - category: one of [news, blog, academic, social]- - sentiment: one of [positive, negative, neutral]- - topics: list of main topics-- Return as JSON object.- """-- response = await context.request_sampling(- messages=[{"role": "user", "content": prompt}],- temperature=0.3, # Lower for consistency- response_format="json"- )-- import json- return json.loads(response["content"])-```--### Multi-Turn Sampling--```python-async def interactive_analysis(topic: str, context: Context) -> dict:- """Multi-turn analysis with LLM."""- # First turn: Generate questions- questions_response = await context.request_sampling(- messages=[{- "role": "user",- "content": f"Generate 3 key questions about: {topic}"- }],- max_tokens=200- )-- # Second turn: Answer questions- analysis_response = await context.request_sampling(- messages=[{- "role": "user",- "content": f"Answer these questions about {topic}:\n{questions_response['content']}"- }],- max_tokens=500- )-- return {- "topic": topic,- "questions": questions_response["content"],- "analysis": analysis_response["content"]- }-```--### Client Handler for Sampling--Client provides LLM access:--```python-async def sampling_handler(messages, params, context):- """Handle LLM sampling requests."""- # Call your LLM API- from openai import AsyncOpenAI-- client = AsyncOpenAI()- response = await client.chat.completions.create(- model=params.get("model", "gpt-4"),- messages=messages,- temperature=params.get("temperature", 0.7),- max_tokens=params.get("max_tokens", 1000)- )-- return {- "content": response.choices[0].message.content,- "model": response.model,- "usage": {- "prompt_tokens": response.usage.prompt_tokens,- "completion_tokens": response.usage.completion_tokens,- "total_tokens": response.usage.total_tokens- }- }--async with Client(- "server.py",- sampling_handler=sampling_handler-) as client:- result = await client.call_tool("enhance_text", {"text": "Hello world"})-```--## Combined Example--All context features together:--```python-async def comprehensive_task(data: list, context: Context) -> dict:- """Task using all context features."""- # 1. Elicitation: Confirm operation- confirmed = await context.request_elicitation(- prompt="Start processing?",- response_type=bool- )-- if not confirmed:- return {"status": "cancelled"}-- # 2. Progress: Track processing- results = []- for i, item in enumerate(data):- await context.report_progress(- progress=i + 1,- total=len(data),- message=f"Processing {i + 1}/{len(data)}"- )-- # 3. Sampling: Use LLM for processing- enhanced = await context.request_sampling(- messages=[{- "role": "user",- "content": f"Analyze this item: {item}"- }],- temperature=0.5- )-- results.append({- "item": item,- "analysis": enhanced["content"]- })-- return {- "status": "completed",- "total": len(data),- "results": results- }-```--## Best Practices--### Elicitation--- **Clear prompts**: Be specific about what you're asking-- **Type validation**: Use appropriate response_type-- **Handle cancellation**: Allow users to cancel operations-- **Provide context**: Explain why input is needed--### Progress Tracking--- **Regular updates**: Report every 5-10% or every item-- **Meaningful messages**: Describe what's happening-- **Phase indicators**: Show which phase of operation-- **Final confirmation**: Report 100% completion--### Sampling--- **System prompts**: Set clear instructions-- **Temperature control**: Lower for factual, higher for creative-- **Token limits**: Set reasonable max_tokens-- **Error handling**: Handle API failures gracefully-- **Cost awareness**: Sampling uses LLM API (costs money)--## Error Handling--### Context Not Available--```python-async def safe_context_usage(context: Context) -> dict:- """Safely use context features."""- # Check if feature is available- if hasattr(context, 'report_progress'):- await context.report_progress(0, 100, "Starting")-- if hasattr(context, 'request_elicitation'):- response = await context.request_elicitation(- prompt="Continue?",- response_type=bool- )- else:- # Fallback behavior- response = True-- return {"status": "completed"}-```--### Timeout Handling--```python-import asyncio--async def elicitation_with_timeout(context: Context) -> dict:- """Elicitation with timeout."""- try:- response = await asyncio.wait_for(- context.request_elicitation(- prompt="Your input (30 seconds):",- response_type=str- ),- timeout=30.0- )- return {"status": "completed", "input": response}- except asyncio.TimeoutError:- return {"status": "timeout", "message": "No input received"}-```--## Context Feature Availability--| Feature | Claude Desktop | Claude Code CLI | FastMCP Cloud | Custom Client |-|---------|---------------|----------------|---------------|---------------|-| Elicitation | ✅ | ✅ | ⚠️ Depends | ✅ With handler |-| Progress | ✅ | ✅ | ✅ | ✅ With handler |-| Sampling | ✅ | ✅ | ⚠️ Depends | ✅ With handler |--⚠️ = Feature availability depends on client implementation--## Resources--- **Context API**: See SKILL.md for full Context API reference-- **Client Handlers**: See `client-example.py` template-- **MCP Protocol**: https://modelcontextprotocol.iodiff --git a/plugins/integrations/skills/mcp-builder/references/deploy-checklist.md b/plugins/integrations/skills/mcp-builder/references/deploy-checklist.mddeleted file mode 100644index 67299cd2..00000000--- a/plugins/integrations/skills/mcp-builder/references/deploy-checklist.md+++ /dev/null@@ -1,73 +0,0 @@-# FastMCP Cloud Pre-Deploy Checklist--Work through these checks before deploying to FastMCP Cloud. Fix errors before deploying;-warnings are advisory.--## Required Checks (errors)--### 1. Server file exists-Verify the main server file exists at the expected path.--### 2. Python syntax valid-```bash-python3 -m py_compile server.py-```--### 3. Module-level server object-The server instance must be at module level (not inside a function):--```python-# CORRECT — Cloud can find this-mcp = FastMCP("My Server")--# WRONG — Cloud can't discover the server-def create_server():- mcp = FastMCP("My Server")- return mcp-```--Check: `grep -q "^mcp = FastMCP\|^server = FastMCP\|^app = FastMCP" server.py`--### 4. requirements.txt exists-Must exist and contain only PyPI packages (no `git+`, `-e`, `.whl`, `.tar.gz`).--### 5. No hardcoded secrets-Check for `api_key = "..."` or `password = "..."` patterns (excluding `os.getenv`/`os.environ`):--```bash-grep -i 'api_key\s*=\s*["\x27]' server.py | grep -v 'os.getenv\|os.environ'-grep -i 'password\s*=\s*["\x27]\|secret\s*=\s*["\x27]' server.py | grep -v 'os.getenv\|os.environ'-```--Use `os.getenv()` for all secrets.--## Advisory Checks (warnings)--### 6. fastmcp in requirements.txt-Should be listed as a dependency.--### 7. .gitignore includes .env-Prevent accidental secret commits.--### 8. No circular imports-Check for `from __init__ import` or `from . import.*get_` patterns.--### 9. Git repository initialised-Should have a remote configured for Cloud deployment.--### 10. Server can load-```bash-timeout 5 python3 server.py --help-# or-timeout 5 fastmcp inspect server.py-```--## Deploy--Once all checks pass:--```bash-git add . && git commit -m "Ready for deployment"-git push -u origin main-# Then: visit https://fastmcp.cloud, connect repo, add env vars, deploy-```diff --git a/plugins/integrations/skills/mcp-builder/references/production-patterns.md b/plugins/integrations/skills/mcp-builder/references/production-patterns.mddeleted file mode 100644index e4b5da82..00000000--- a/plugins/integrations/skills/mcp-builder/references/production-patterns.md+++ /dev/null@@ -1,488 +0,0 @@-# FastMCP Production Patterns Reference--Battle-tested patterns for production-ready FastMCP servers.--## Self-Contained Server Pattern--**Problem:** Circular imports break cloud deployment-**Solution:** Keep all utilities in one file--```python-# src/utils.py - All utilities in one place-import os-from typing import Dict, Any-from datetime import datetime--class Config:- """Configuration from environment."""- SERVER_NAME = os.getenv("SERVER_NAME", "FastMCP Server")- API_KEY = os.getenv("API_KEY", "")- CACHE_TTL = int(os.getenv("CACHE_TTL", "300"))--def format_success(data: Any) -> Dict[str, Any]:- """Format successful response."""- return {- "success": True,- "data": data,- "timestamp": datetime.now().isoformat()- }--def format_error(error: str, code: str = "ERROR") -> Dict[str, Any]:- """Format error response."""- return {- "success": False,- "error": error,- "code": code,- "timestamp": datetime.now().isoformat()- }--# Usage in tools-from .utils import format_success, format_error, Config--async def process_data(data: dict) -> dict:- try:- result = await process(data)- return format_success(result)- except Exception as e:- return format_error(str(e))-```--**Why it works:**-- No circular dependencies-- Cloud deployment safe-- Easy to maintain-- Single source of truth--## Lazy Initialization Pattern--**Problem:** Creating expensive resources at import time fails in cloud-**Solution:** Initialize resources only when needed--```python-class ResourceManager:- """Manages expensive resources with lazy initialization."""- _db_pool = None- _cache = None-- @classmethod- async def get_db(cls):- """Get database pool (create on first use)."""- if cls._db_pool is None:- cls._db_pool = await create_db_pool()- return cls._db_pool-- @classmethod- async def get_cache(cls):- """Get cache (create on first use)."""- if cls._cache is None:- cls._cache = await create_cache()- return cls._cache--# Usage - no initialization at module level-manager = ResourceManager() # Lightweight--async def database_operation():- db = await manager.get_db() # Initialization happens here- return await db.query("SELECT * FROM users")-```--## Connection Pooling Pattern--**Problem:** Creating new connections for each request is slow-**Solution:** Reuse HTTP clients with connection pooling--```python-import httpx--class APIClient:- _instance: Optional[httpx.AsyncClient] = None-- @classmethod- async def get_client(cls) -> httpx.AsyncClient:- """Get or create shared HTTP client."""- if cls._instance is None:- cls._instance = httpx.AsyncClient(- base_url=API_BASE_URL,- timeout=httpx.Timeout(30.0),- limits=httpx.Limits(- max_keepalive_connections=5,- max_connections=10- )- )- return cls._instance-- @classmethod- async def cleanup(cls):- """Cleanup on shutdown."""- if cls._instance:- await cls._instance.aclose()- cls._instance = None--async def api_request(endpoint: str) -> dict:- client = await APIClient.get_client()- response = await client.get(endpoint)- return response.json()-```--## Retry with Exponential Backoff--**Problem:** Transient failures cause tool failures-**Solution:** Automatic retry with exponential backoff--```python-import asyncio--async def retry_with_backoff(- func,- max_retries: int = 3,- initial_delay: float = 1.0,- exponential_base: float = 2.0-):- """Retry function with exponential backoff."""- delay = initial_delay- last_exception = None-- for attempt in range(max_retries):- try:- return await func()- except (httpx.TimeoutException, httpx.NetworkError) as e:- last_exception = e- if attempt < max_retries - 1:- await asyncio.sleep(delay)- delay *= exponential_base-- raise last_exception--async def resilient_api_call(endpoint: str) -> dict:- """API call with automatic retry."""- async def make_call():- client = await APIClient.get_client()- response = await client.get(endpoint)- response.raise_for_status()- return response.json()-- try:- data = await retry_with_backoff(make_call)- return {"success": True, "data": data}- except Exception as e:- return {"success": False, "error": str(e)}-```--## Time-Based Caching Pattern--**Problem:** Repeated API calls for same data waste time/money-**Solution:** Cache with TTL (time-to-live)--```python-import time--class TimeBasedCache:- def __init__(self, ttl: int = 300):- self.ttl = ttl- self.cache = {}- self.timestamps = {}-- def get(self, key: str):- if key in self.cache:- if time.time() - self.timestamps[key] < self.ttl:- return self.cache[key]- else:- del self.cache[key]- del self.timestamps[key]- return None-- def set(self, key: str, value):- self.cache[key] = value- self.timestamps[key] = time.time()--cache = TimeBasedCache(ttl=300)--async def cached_fetch(resource_id: str) -> dict:- """Fetch with caching."""- cache_key = f"resource:{resource_id}"-- cached = cache.get(cache_key)- if cached:- return {"data": cached, "from_cache": True}-- data = await fetch_from_api(resource_id)- cache.set(cache_key, data)-- return {"data": data, "from_cache": False}-```--## Structured Error Responses--**Problem:** Inconsistent error formats make debugging hard-**Solution:** Standardized error response format--```python-from enum import Enum--class ErrorCode(Enum):- VALIDATION_ERROR = "VALIDATION_ERROR"- NOT_FOUND = "NOT_FOUND"- API_ERROR = "API_ERROR"- TIMEOUT = "TIMEOUT"- UNKNOWN = "UNKNOWN"--def create_error(code: ErrorCode, message: str, details: dict = None):- """Create structured error response."""- return {- "success": False,- "error": {- "code": code.value,- "message": message,- "details": details or {},- "timestamp": datetime.now().isoformat()- }- }--async def validated_operation(data: str) -> dict:- if not data:- return create_error(- ErrorCode.VALIDATION_ERROR,- "Data is required",- {"field": "data"}- )-- try:- result = await process(data)- return {"success": True, "data": result}- except Exception as e:- return create_error(ErrorCode.UNKNOWN, str(e))-```--## Environment-Based Configuration--**Problem:** Different settings for dev/staging/production-**Solution:** Environment-based configuration class--```python-import os-from enum import Enum--class Environment(Enum):- DEVELOPMENT = "development"- STAGING = "staging"- PRODUCTION = "production"--class Config:- ENV = Environment(os.getenv("ENVIRONMENT", "development"))-- SETTINGS = {- Environment.DEVELOPMENT: {- "debug": True,- "cache_ttl": 60,- "log_level": "DEBUG"- },- Environment.STAGING: {- "debug": True,- "cache_ttl": 300,- "log_level": "INFO"- },- Environment.PRODUCTION: {- "debug": False,- "cache_ttl": 3600,- "log_level": "WARNING"- }- }-- @classmethod- def get(cls, key: str):- return cls.SETTINGS[cls.ENV].get(key)--# Use configuration-cache_ttl = Config.get("cache_ttl")-debug_mode = Config.get("debug")-```--## Health Check Pattern--**Problem:** Need to monitor server health in production-**Solution:** Comprehensive health check resource--```python[email protected]("health://status")-async def health_check() -> dict:- """Comprehensive health check."""- checks = {}-- # Check API connectivity- try:- client = await APIClient.get_client()- response = await client.get("/health", timeout=5)- checks["api"] = response.status_code == 200- except:- checks["api"] = False-- # Check database (if applicable)- try:- db = await ResourceManager.get_db()- await db.execute("SELECT 1")- checks["database"] = True- except:- checks["database"] = False-- # System resources- import psutil- checks["memory_percent"] = psutil.virtual_memory().percent- checks["cpu_percent"] = psutil.cpu_percent()-- # Overall status- all_healthy = (- checks.get("api", True) and- checks.get("database", True) and- checks["memory_percent"] < 90 and- checks["cpu_percent"] < 90- )-- return {- "status": "healthy" if all_healthy else "degraded",- "timestamp": datetime.now().isoformat(),- "checks": checks- }-```--## Parallel Processing Pattern--**Problem:** Sequential processing is slow for batch operations-**Solution:** Process items in parallel--```python-import asyncio--async def batch_process(items: list[str]) -> dict:- """Process multiple items in parallel."""- async def process_single(item: str):- try:- result = await process_item(item)- return {"item": item, "success": True, "result": result}- except Exception as e:- return {"item": item, "success": False, "error": str(e)}-- # Process all items in parallel- tasks = [process_single(item) for item in items]- results = await asyncio.gather(*tasks)-- successful = [r for r in results if r["success"]]- failed = [r for r in results if not r["success"]]-- return {- "total": len(items),- "successful": len(successful),- "failed": len(failed),- "results": results- }-```--## State Management Pattern--**Problem:** Shared state causes race conditions-**Solution:** Thread-safe state management with locks--```python-import asyncio--class StateManager:- def __init__(self):- self._state = {}- self._locks = {}-- async def get(self, key: str, default=None):- return self._state.get(key, default)-- async def set(self, key: str, value):- if key not in self._locks:- self._locks[key] = asyncio.Lock()-- async with self._locks[key]:- self._state[key] = value-- async def update(self, key: str, updater):- """Update with function."""- if key not in self._locks:- self._locks[key] = asyncio.Lock()-- async with self._locks[key]:- current = self._state.get(key)- self._state[key] = await updater(current)- return self._state[key]--state = StateManager()--async def increment_counter(name: str) -> dict:- new_value = await state.update(- f"counter_{name}",- lambda x: (x or 0) + 1- )- return {"counter": name, "value": new_value}-```--## Anti-Patterns to Avoid--### ❌ Factory Functions in __init__.py--```python-# DON'T DO THIS-# shared/__init__.py-def get_api_client():- from .api_client import APIClient # Circular import risk- return APIClient()-```--### ❌ Blocking Operations in Async--```python-# DON'T DO THIS-async def bad_async():- time.sleep(5) # Blocks entire event loop!- return "done"--# DO THIS INSTEAD-async def good_async():- await asyncio.sleep(5)- return "done"-```--### ❌ Global Mutable State--```python-# DON'T DO THIS-results = [] # Race conditions!--async def add_result(data: str):- results.append(data)-```--## Production Deployment Checklist--- [ ] Module-level server object-- [ ] Environment variables for all config-- [ ] Connection pooling for HTTP clients-- [ ] Retry logic for transient failures-- [ ] Caching for expensive operations-- [ ] Structured error responses-- [ ] Health check endpoint-- [ ] Logging configured-- [ ] No circular imports-- [ ] No import-time async execution-- [ ] Rate limiting if needed-- [ ] Graceful shutdown handling--## Resources--- **Production Examples**: See `self-contained-server.py` template-- **Error Handling**: See `error-handling.py` template-- **API Patterns**: See `api-client-pattern.py` templatediff --git a/plugins/integrations/skills/mcp-builder/references/testing-pattern.md b/plugins/integrations/skills/mcp-builder/references/testing-pattern.mddeleted file mode 100644index 6d36d626..00000000--- a/plugins/integrations/skills/mcp-builder/references/testing-pattern.md+++ /dev/null@@ -1,89 +0,0 @@-# FastMCP Server Testing Pattern--Reference pattern for testing a FastMCP server. Claude should generate a tailored-test script based on the server being tested.--## Async Test Client (Stdio)--```python-import asyncio-from fastmcp import Client--async def test_server(server_path):- async with Client(server_path) as client:- # List capabilities- tools = await client.list_tools()- print(f"Found {len(tools)} tools")- for tool in tools:- print(f" - {tool.name}: {tool.description[:60]}...")-- resources = await client.list_resources()- print(f"Found {len(resources)} resources")- for resource in resources:- desc = resource.description[:60] if resource.description else "No description"- print(f" - {resource.uri}: {desc}...")-- prompts = await client.list_prompts()- print(f"Found {len(prompts)} prompts")-- # Call first tool with empty args (may fail if required params)- if tools:- try:- result = await client.call_tool(tools[0].name, {})- print(f"Tool '{tools[0].name}' returned: {str(result.data)[:100]}...")- except Exception as e:- print(f"Tool call failed (may need params): {e}")-- # Read first resource- if resources:- try:- data = await client.read_resource(resources[0].uri)- print(f"Resource read: {str(data)[:100]}...")- except Exception as e:- print(f"Resource read failed: {e}")--asyncio.run(test_server("server.py"))-```--## HTTP Transport Testing--For HTTP servers, start the server in the background first:--```python-async def test_http_server(port=8000):- url = f"http://localhost:{port}/mcp"- async with Client(url) as client:- # Same test logic as stdio- tools = await client.list_tools()- ...-```--Start the server separately:-```bash-python server.py --transport http --port 8000 &-SERVER_PID=$!-sleep 2 # Wait for server startup--# Run tests-python test_script.py--# Cleanup-kill $SERVER_PID-```--## FastMCP Dev Mode--For development with auto-reload:--```bash-fastmcp dev server.py-fastmcp dev server.py --with-editable .-```--## MCP Inspector--Interactive testing via browser:--```bash-fastmcp dev server.py # Opens inspector at http://localhost:5173-```