MCP Server — FastAPI
A FastAPI-based MCP server providing automation and AI-powered tools for performance testing, security scanning, browser automation, code review, code generation, knowledge retrieval, and design collaboration via both REST API and MCP protocol.
README
Model Context Protocol (MCP) Server — FastAPI
A FastAPI-based MCP Server that exposes automation and AI tools via both REST API and MCP protocol. Tools cover performance testing (JMeter), security scanning (OWASP ZAP), browser automation (Playwright, Selenium), code review (GitLab), AI code generation (unit tests, scenario tests, API specs), knowledge retrieval (RAG/Knowledge Base), and design collaboration (Miro).
Table of Contents
- Prerequisites
- Project Structure
- Environment Variables
- Start the Server
- API & MCP Access
- Architecture
- Available Tools (MCP)
- Development
1. Prerequisites
- Docker
- Docker Compose (included with Docker Desktop)
2. Project Structure
├── functions/
│ └── main.py # FastAPI entry point; registers all routers; configures MCP
├── routers/ # One file per domain (REST endpoints)
├── services/ # Core business logic
├── batch_jobs/
│ ├── base/
│ │ └── subprocess_job_runner.py # Spawns worker processes; tracks state
│ └── jobs/ # One job file per async tool
├── schemas/ # Pydantic request/response models
├── models/ # DynamoDB models, job registry, OWASP ZAP state
├── constants/
│ └── config.py # All env-var constants (source of truth)
├── jobs/
│ └── scheduler.py # APScheduler: background sync jobs
├── prompts/ # Jinja2 prompt templates (organized by feature)
├── skills/ # Markdown skill definitions for agent workflows
├── subagents/ # Agent role documentation for multi-step pipelines
├── ui_s3_manager/ # Sub-app mounted at /ui-s3-manager and /ui-s3
├── data/
│ └── DDL/ # DynamoDB table creation scripts
├── public/ # Static files (served at /public)
├── docker/ # Dockerfiles for fastapi (ZAP uses zaproxy/zap-stable in compose)
├── docker-compose.yml
├── requirements.txt
├── .env.example
└── ruff-guide.md
3. Environment Variables
Copy .env.example to .env and fill in the required values:
cp .env.example .env
| Variable | Required | Description |
|---|---|---|
AWS_REGION |
Yes | AWS region for S3, DynamoDB, Bedrock, etc. |
AWS_ACCESS_KEY_ID |
Yes | AWS credentials |
AWS_SECRET_ACCESS_KEY |
Yes | AWS credentials |
S3_BUCKET_NAME |
Yes | S3 bucket for uploads and report storage |
| GitLab host allowlist | Code | Edit constants/gitlab_hosts.py (not .env) |
GITLAB_TOKEN |
Removed | Replaced by per-request gitlab_token field in tool inputs |
REDIS_HOST |
Yes* | Redis host for Miro OAuth state and per-user token storage |
REDIS_PORT |
Yes* | Redis port (default 6379 in Docker Compose) |
AUTH_JWT_SECRET |
Yes | JWT secret for AuthMiddleware |
AWS_BEDROCK_LLM_MODEL |
Yes | Bedrock model ID (e.g. anthropic.claude-3-haiku-20240307-v1:0) |
SLACK_HOOK |
No | Slack incoming webhook URL for job notifications |
SLACK_CHANNEL |
No | Slack channel for notifications |
BACKLOG_DOMAIN |
No | Backlog domain for backlog sync jobs |
BACKLOG_API_KEY |
No | Backlog API key |
BACKLOG_PROJECT_KEYS |
No | Comma-separated Backlog project keys |
LLM_LOCAL_BASE_URL |
No | Base URL for local LLM (e.g. Ollama: http://localhost:11434) |
LLM_LOCAL_MODEL |
No | Local LLM model name (e.g. qwen2.5:3b) |
BEDROCK_AGENT_ID |
No | AWS Bedrock Agent ID |
BEDROCK_AGENT_ALIAS_ID |
No | AWS Bedrock Agent Alias ID |
RAG_INIT_S3_FOLDER |
No | S3 folder to seed the RAG knowledge base on startup |
Yes*= required only when using that specific tool group.
See .env.example for all RAG, Selenium, and Redis tuning options.
4. Start the Server
Use the OS-specific wrapper script instead of calling docker compose directly. Each script auto-detects the host architecture and sets the correct platform before delegating to Docker.
macOS (Intel or Apple Silicon)
One-time prerequisite for Apple Silicon (M1/M2/M3):
Docker Desktop → Settings → General → enable "Use Rosetta for x86_64/amd64 emulation on Apple Silicon" → Apply & Restart
Step 1 — Build and start:
# All services
./run.sh up --build
# Minimal setup (fastapi + redis only)
./run.sh up --build fastapi redis
# Run in background
./run.sh up -d fastapi redis
On Apple Silicon you will see:
[run.sh] Apple Silicon (arm64) detected — running linux/amd64 containers via Rosetta 2 emulation
Windows
# All services
.\run.ps1 up --build
# Minimal setup (fastapi + redis only)
.\run.ps1 up --build fastapi redis
# Run in background
.\run.ps1 up -d fastapi redis
Common commands (both OSes)
# Stop all containers
./run.sh down # macOS
.\run.ps1 down # Windows
# View logs
./run.sh logs -f fastapi
# Open a shell inside the container
docker exec -it fastapi_app bash
Step 2 — (One-time) Create DynamoDB tables:
docker exec -it fastapi_app python ./data/DDL/create_dynamodb_tables.py
Check container logs:
docker logs fastapi_app
5. API & MCP Access
| Interface | URL |
|---|---|
| REST API docs (Swagger) | http://localhost:8000/docs |
| MCP endpoint | http://localhost:8000/mcp |
| S3 File Manager UI | http://localhost:8000/ui-s3-manager |
Integrate into an LLM client (MCP config):
{
"mcpServers": {
"local-mcp": {
"url": "http://localhost:8000/mcp"
}
}
}
6. Architecture
Request Flow
Client → Router → Service → (optional) Batch Job → DynamoDB / Redis
↑
Client polls GET /api/history/{operation_id} ───────────┘
- Router (
routers/) — validates the request schema and calls the service. - Service (
services/) — core business logic. Short operations (reading rules, file uploads, Miro API calls) return a result immediately. Long-running operations (test execution, security scans, LLM generation) spawn a batch job and return anoperation_id. - Batch Job (
batch_jobs/jobs/) — runs in a subprocess viaSubprocessJobRunner; writes status to DynamoDB/Redis. Only used for async operations. - Client — polls
GET /api/history/{operation_id}(exposed as theget_resultMCP tool) until the job resolves. Only needed after async operations.
Infrastructure
| Service | Description | Exposed Port |
|---|---|---|
fastapi |
Main app (fastapi_app) |
8000 |
owaspzap_1–5 |
5 parallel OWASP ZAP instances | 8080 (internal) |
redis |
Job state / caching | 6379 |
LLM Integration
| Service | Description |
|---|---|
LLMService (services/llm_service.py) |
Direct AWS Bedrock invocations |
LLMLocalService (services/llm_local_service.py) |
Local LLM via LLM_LOCAL_BASE_URL / LLM_LOCAL_MODEL |
Model IDs are configured via AWS_BEDROCK_LLM_MODEL in constants/config.py.
MCP Exposure
Only operations listed in include_operations inside functions/main.py are exposed as MCP tools. Endpoints tagged "allure" are additionally exposed via include_tags.
When adding a new router endpoint intended for MCP, add its
operation_idtoinclude_operationsinfunctions/main.py.
Authentication
AuthMiddleware (services/auth_service.py) is applied globally to all routes. JWT secret is configured via AUTH_JWT_SECRET.
7. Available Tools (MCP)
| Domain | Operation IDs |
|---|---|
| JMeter | run_jmeter |
| OWASP ZAP | scan_owasp_zap, scan_owasp_zap_scenario, scan_owasp_zap_website |
| Playwright | get_playwright_scenario_rules, run_playwright_e2e, run_playwright_converse |
| GitLab | gitlab_review_merge_request |
| Miro | create_miro_board, get_all_boards, get_miro_mermaid_rules, draw_miro_board |
| Spec Generator | get_template_design, publish_file, publish_file_ui, publish_file_via_s3, extract_archive, ai_generate_spec |
| Unit Test Generator | ai_generate_unit_test |
| Scenario Test Generator | generate_scenario_test |
| Knowledge Base | knowledge_ask |
| Allure | all endpoints tagged allure |
| History | get_result, stop_operation |
8. Development
All linting and formatting commands run inside the container:
# Open a shell in the container
docker exec -it fastapi_app bash
# Lint
ruff check .
ruff check . --fix # auto-fix
ruff check path/to/file.py
# Format
ruff format .
ruff format path/to/file.py
ruff format . --check # dry run (no changes)
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.