@@ -6,7 +6,9 @@ Never mention Claude or Claude Code in your PRs, diffs, etc.
66
77## Project Overview  
88
9- MCP Gateway (ContextForge) is a production-grade gateway, proxy, and registry for Model Context Protocol (MCP) servers and A2A Agents. It federates MCP and REST services, providing unified discovery, auth, rate-limiting, observability, virtual servers, multi-transport protocols, and an optional Admin UI.
9+ MCP Gateway (ContextForge) is a production-grade gateway, proxy, and registry for Model Context Protocol (MCP) servers
10+ and A2A Agents. It federates MCP and REST services, providing unified discovery, auth, rate-limiting, observability,
11+ virtual servers, multi-transport protocols, and an optional Admin UI.
1012
1113## Essential Commands  
1214
@@ -45,121 +47,15 @@ make doctest test htmlcov smoketest lint-web flake8 bandit interrogate pylint ve
4547make doctest test  htmlcov         #  Doctests + unit tests + coverage (→ docs/docs/coverage/index.html)
4648make smoketest                    #  End-to-end container testing
4749
48- #  Testing individual files (activate env first )
49- .  /home/cmihai/.venv/mcpgateway/bin/activate  &&  pytest --cov-report=annotate tests/unit/mcpgateway/test_translate.py
50+ #  Testing individual files (using uv environment manager )
51+ uv run  pytest --cov-report=annotate tests/unit/mcpgateway/test_translate.py
5052``` 
5153
52- ## Performance Configuration  
53- 
54- ### Response Compression  
55- 
56- The gateway includes automatic response compression middleware (Brotli, Zstd, GZip) that reduces bandwidth usage by 30-70% for text-based responses (JSON, HTML, CSS, JS).
57- 
58- ** Configuration**  (` .env.example ` ):
59- ``` bash 
60- #  Enable/disable compression
61- COMPRESSION_ENABLED=true                 #  Default: true
62- 
63- #  Minimum response size to compress (bytes)
64- COMPRESSION_MINIMUM_SIZE=500             #  Default: 500 bytes
65- 
66- #  Compression quality levels
67- COMPRESSION_GZIP_LEVEL=6                 #  GZip: 1-9 (default: 6 balanced)
68- COMPRESSION_BROTLI_QUALITY=4             #  Brotli: 0-11 (default: 4 balanced)
69- COMPRESSION_ZSTD_LEVEL=3                 #  Zstd: 1-22 (default: 3 fast)
70- ``` 
71- 
72- ** Algorithm Priority** : Brotli (best) > Zstd (fast) > GZip (universal)
73- 
74- ** Testing Compression**  (requires running server):
75- ``` bash 
76- #  Start server
77- make dev
78- 
79- #  Test Brotli compression (best compression ratio)
80- curl -H " Accept-Encoding: br" 2>&1  |  grep -i " content-encoding" 
81- #  Should show: content-encoding: br
82- 
83- #  Test GZip compression (universal fallback)
84- curl -H " Accept-Encoding: gzip" 2>&1  |  grep -i " content-encoding" 
85- #  Should show: content-encoding: gzip
86- 
87- #  Test Zstd compression (fastest)
88- curl -H " Accept-Encoding: zstd" 2>&1  |  grep -i " content-encoding" 
89- #  Should show: content-encoding: zstd
90- 
91- #  Verify Vary header (for cache compatibility)
92- curl -H " Accept-Encoding: br" 2>&1  |  grep -i " vary" 
93- #  Should show: vary: Accept-Encoding
94- 
95- #  Test minimum size threshold (small responses not compressed)
96- curl -H " Accept-Encoding: br" 2>&1  |  grep -i " content-encoding" 
97- #  Should NOT show content-encoding (response too small)
98- 
99- #  Measure compression ratio
100- curl -w " %{size_download}\n" #  Uncompressed
101- curl -H " Accept-Encoding: br" " %{size_download}\n" #  Brotli
102- ``` 
103- 
104- ** Implementation Details** :
105- -  Middleware location: ` mcpgateway/main.py:888-907 ` 
106- -  Config settings: ` mcpgateway/config.py:379-384 ` 
107- -  Only compresses responses > ` COMPRESSION_MINIMUM_SIZE `  bytes
108- -  Automatically negotiates algorithm based on client ` Accept-Encoding `  header
109- -  Adds ` Vary: Accept-Encoding `  header for proper cache behavior
110- -  No client changes required (browsers handle decompression automatically)
111- 
112- ### JSON Serialization (orjson)  
113- 
114- The gateway uses ** orjson**  for high-performance JSON serialization, providing ** 5-6x faster serialization**  and ** 1.5-2x faster deserialization**  compared to Python's standard library.
115- 
116- ** Performance Benefits** :
117- -  ** Serialization** : 5-6x faster (550-623% speedup)
118- -  ** Deserialization** : 1.5-2x faster (55-115% speedup)
119- -  ** Output size** : 7% smaller (more compact JSON)
120- -  ** Zero configuration** : Drop-in replacement, works automatically
121- 
122- ** Why orjson?** 
123- -  Rust-based implementation for maximum performance
124- -  RFC 8259 compliant (strict JSON specification)
125- -  Native support for datetime, UUID, numpy arrays
126- -  Used by major companies (Reddit, Stripe, etc.)
127- 
128- ** Testing JSON Serialization**  (requires running server):
129- ``` bash 
130- #  Start server
131- make dev
132- 
133- #  Benchmark JSON serialization performance
134- python scripts/benchmark_json_serialization.py
135- 
136- #  Test endpoint response times
137- time  curl -s http://localhost:8000/tools >  /dev/null
138- 
139- #  Verify orjson unit tests
140- pytest tests/unit/mcpgateway/utils/test_orjson_response.py -v --cov=mcpgateway.utils.orjson_response --cov-report=term-missing
141- ``` 
142- 
143- ** Implementation Details** :
144- -  Response class: ` mcpgateway/utils/orjson_response.py ` 
145- -  FastAPI config: ` mcpgateway/main.py:408 `  (default_response_class=ORJSONResponse)
146- -  Benchmark script: ` scripts/benchmark_json_serialization.py ` 
147- -  Options: OPT_NON_STR_KEYS (allows int keys), OPT_SERIALIZE_NUMPY (numpy support)
148- -  Datetime format: RFC 3339 (ISO 8601 with timezone)
149- -  No client changes required (standard JSON, fully compatible)
150- 
151- ** Performance Impact** :
152- -  Large endpoints (GET /tools, GET /servers): 20-40% faster response time
153- -  Bulk exports: 50-60% faster serialization
154- -  API throughput: 15-30% higher requests/second
155- -  CPU usage: 10-20% lower per request
156- 
157- ** Documentation** : See ` docs/docs/testing/performance.md `  for detailed benchmarks
158- 
15954## Architecture Overview  
16055
16156### Technology Stack  
16257-  ** FastAPI**  with ** Pydantic**  validation and ** SQLAlchemy**  ORM
58+   -  FastAPI is build on Starlette ASGI framework
16359-  ** HTMX + Alpine.js**  for admin UI
16460-  ** SQLite**  default, ** PostgreSQL**  support, ** Redis**  for caching/federation
16561-  ** Alembic**  for database migrations
@@ -315,52 +211,14 @@ make security-scan                   # Trivy + Grype vulnerability scans
3152114. Implement hooks: pre/post request/response
3162125. Test: ` pytest tests/unit/mcpgateway/plugins/` 
317213
318- # # A2A (Agent-to-Agent) Integration
319- 
320- A2A agents are external AI agents (OpenAI, Anthropic, custom) integrated as tools within virtual servers.
321- 
322- # ## Integration Workflow
323- 1. ** Register Agent** : Add via ` /a2a` 
324- 2. ** Associate with Server** : Include agent ID in  virtual server' s `associated_a2a_agents`
325- 3. **Auto-Tool Creation**: Gateway creates tools for associated agents 
326- 4. **Tool Invocation**: Standard tool invocation routes to A2A agents 
327- 5. **Metrics Collection**: Comprehensive interaction tracking 
328- 
329- ### Configuration Effects 
330- - `MCPGATEWAY_A2A_ENABLED=false`: Disables all A2A features (API 404, UI hidden) 
331- - `MCPGATEWAY_A2A_METRICS_ENABLED=false`: Disables metrics collection only 
332- 
333- ## API Endpoints Overview 
334- 
335- ### Core MCP Protocol 
336- - `POST /` - JSON-RPC endpoint for MCP protocol 
337- - `GET /servers/{id}/sse` - Server-Sent Events transport 
338- - `WS /servers/{id}/ws` - WebSocket transport 
339- - `GET /.well-known/mcp` - Well-known URI handler 
340- 
341- ### Admin APIs (when `MCPGATEWAY_ADMIN_API_ENABLED=true`) 
342- - `GET/POST /tools` - Tool management and invocation 
343- - `GET/POST /resources` - Resource management 
344- - `GET/POST /prompts` - Prompt templates 
345- - `GET/POST /servers` - Virtual server management 
346- - `GET/POST /gateways` - Peer gateway federation 
347- - `GET/POST /a2a` - A2A agent management 
348- - `GET/POST /tags` - Tag management system 
349- - `POST /bulk-import` - Bulk import operations 
350- - `GET /admin` - Admin UI dashboard 
351- 
352- ### Observability 
353- - `GET /health` - Health check endpoint 
354- - `GET /metrics` - Prometheus metrics (when enabled) 
355- - `GET /openapi.json` - OpenAPI specification 
356- 
357214# # Development Guidelines
358215
359216# ## Git & Commit Standards
360217- ** Always sign commits** : Use ` git commit -s` 
361218- ** Conventional Commits** : ` feat:` ` fix:` ` docs:` ` refactor:` ` chore:` 
362219- ** Link Issues** : Include ` Closes # 123` in  commit messages
363220- ** No Claude mentions** : Never mention Claude or Claude Code in  PRs/diffs
221+ - DO NOT include test  plans in  pull requests
364222- ** No estimates** : Don' t include effort estimates or "phases"
365223
366224### Code Style & Standards 
@@ -379,6 +237,7 @@ A2A agents are external AI agents (OpenAI, Anthropic, custom) integrated as tool
379237### CLI Tools Available 
380238- `gh` for GitHub operations: `gh issue view 586`, `gh pr create` 
381239- `make` for all build/test operations 
240+ - uv for managing virtual environments 
382241- Standard development tools: pytest, black, isort, etc. 
383242
384243## Quick Reference 
@@ -400,3 +259,49 @@ make autoflake isort black pre-commit
400259# Complete quality pipeline 
401260make doctest test htmlcov smoketest lint-web flake8 bandit interrogate pylint verify 
402261``` 
262+ 
263+ ## Documentation Quick Links 
264+ 
265+ ### Getting Started 
266+ - [Developer Onboarding](docs/docs/development/developer-onboarding.md) - Complete setup guide for new contributors 
267+ - [Building & Testing](docs/docs/development/building.md) - Build system, testing workflows, coverage 
268+ - [Configuration Reference](docs/docs/manage/configuration.md) - Environment variables and settings 
269+ 
270+ ### API & Protocol Reference 
271+ - [REST API Usage](docs/docs/manage/api-usage.md) - Comprehensive REST API guide with curl examples 
272+ - [MCP JSON-RPC Guide](docs/docs/development/mcp-developer-guide-json-rpc.md) - Low-level MCP protocol implementation 
273+ - [OpenAPI Interactive Docs](http://localhost:4444/docs) - Swagger UI (requires running server) 
274+ - [OpenAPI Schema](http://localhost:4444/openapi.json) - Machine-readable API specification 
275+ 
276+ ### Core Features 
277+ - [A2A Agent Integration](docs/docs/using/agents/a2a.md) - Agent-to-Agent setup, authentication, monitoring 
278+ - [Plugin Development](docs/docs/architecture/plugins.md) - Plugin framework, hooks, creating custom plugins 
279+ - [Virtual Servers](docs/docs/manage/virtual-servers.md) - Creating and managing composite MCP servers 
280+ - [Export/Import Reference](docs/docs/manage/export-import-reference.md) - Bulk operations and configuration migration 
281+ 
282+ ### Architecture & Design 
283+ - [Architecture Overview](docs/docs/architecture/README.md) - System design, components, data flow 
284+ - [ADR Index](docs/docs/architecture/adr/README.md) - Architecture Decision Records 
285+ - [Security Architecture](docs/docs/architecture/security.md) - Authentication, authorization, security features 
286+ - [Multi-Transport Design](docs/docs/architecture/adr/003-expose-multi-transport-endpoints.md) - HTTP, WebSocket, SSE, STDIO 
287+ 
288+ ### Operations & Management 
289+ - [Logging & Monitoring](docs/docs/manage/logging.md) - Log configuration, rotation, analysis 
290+ - [Performance Tuning](docs/docs/testing/performance.md) - Benchmarks, optimization, profiling 
291+ - [Scaling & High Availability](docs/docs/manage/scaling.md) - Horizontal scaling, load balancing, federation 
292+ - [Well-Known URIs](docs/docs/manage/well-known-uris.md) - Standard endpoints (robots.txt, security.txt) 
293+ 
294+ ### Deployment 
295+ - [Docker/Podman Deployment](docs/docs/deployment/docker.md) - Container setup and configuration 
296+ - [Kubernetes Deployment](docs/docs/deployment/kubernetes.md) - K8s manifests and Helm charts 
297+ - [Cloud Deployments](docs/docs/deployment/) - AWS, Azure, GCP, Fly.io guides 
298+ 
299+ ### Testing & Quality 
300+ - [Testing Guide](docs/docs/testing/basic.md) - Unit, integration, E2E, security testing 
301+ - [Security Testing](docs/docs/testing/security.md) - Vulnerability scanning, penetration testing 
302+ - [Documentation Standards](docs/docs/development/documentation.md) - Writing and maintaining docs 
303+ 
304+ ### Integration Guides 
305+ - [Agent Frameworks](docs/docs/using/agents/) - LangChain, CrewAI, LangGraph, AutoGen 
306+ - [MCP Clients](docs/docs/using/clients/) - Claude Desktop, Continue, Zed, OpenWebUI 
307+ - [MCP Servers](docs/docs/using/servers/) - Example server integrations 
0 commit comments