Skip to content

Commit 9325311

Browse files
authored
Merge pull request #74 from IBM/docs-clean
Add performance testing and documentation authoring guide to docs
2 parents 5be5264 + edad007 commit 9325311

File tree

7 files changed

+268
-4
lines changed

7 files changed

+268
-4
lines changed

docs/docs/development/.pages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ nav:
22
- index.md
33
- github.md
44
- building.md
5+
- documentation.md
56
- packaging.md
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Writing & Publishing Documentation
2+
3+
Follow this guide when you need to add or update markdown pages under `docs/` and preview the documentation locally.
4+
5+
---
6+
7+
## 🧩 Prerequisites
8+
9+
* **Python ≥ 3.10** (only for the initial virtual env – *not* required if you already have one)
10+
* `make` (GNU Make 4+)
11+
* (First-time only) **[`mkdocs-material`](https://squidfunk.github.io/mkdocs-material/)** and plugins are installed automatically by the *docs* `Makefile`.
12+
* One-time GitHub setup, e.g. [gitconfig setup](./github.md#16-personal-git-configuration-recommended)
13+
14+
---
15+
16+
## ⚡ One-liner for a live preview
17+
18+
```bash
19+
cd docs
20+
make venv # First-time only, installs dependencies into a venv under `~/.venv/mcpgateway-docs`
21+
make serve # http://localhost:8000 (auto-reload on save)
22+
```
23+
24+
*The `serve` target automatically creates a project-local virtual environment (under `~/.venv/mcpgateway-docs`) the first time you run it and installs all doc dependencies before starting **MkDocs** in live-reload mode.*
25+
26+
---
27+
28+
## 📂 Folder layout
29+
30+
```text
31+
repo-root/
32+
├─ docs/ # MkDocs project (DO NOT put .md files here!)
33+
│ ├─ docs/ # <-- ────────────▶ place Markdown pages here
34+
│ │ └─ ...
35+
│ ├─ mkdocs.yml # MkDocs config & navigation
36+
│ └─ Makefile # build / serve / clean targets
37+
└─ Makefile # repo-wide helper targets (lint, spellcheck, …)
38+
```
39+
40+
* **Add new pages** inside `docs/docs/` – organise them in folders that make sense for navigation.
41+
* **Update navigation**: edit `.pages` for your section so your page shows up in the left-hand nav.
42+
43+
> **Tip:** MkDocs Material auto-generates "Edit this page" links – keep file names lowercase-hyphen-case.
44+
45+
---
46+
47+
## ✏️ Editing tips
48+
49+
1. Write in **standard Markdown**; we also support admonitions, call-outs, and Mermaid diagrams.
50+
2. Use relative links between pages: `[Gateway API](../api/index.md)`.
51+
3. For local images place them under `docs/docs/images/` and reference with `![](../images/example.png)`.
52+
4. Never edit `mkdocs.yml` - all nav structure is defined in `.pages` files (one per directory).
53+
54+
---
55+
56+
## ✏️ Writing docs
57+
58+
Start each new Markdown file with a clear **`# Heading 1`** title – this becomes the visible page title and is required for proper rendering in MkDocs.
59+
60+
Follow the conventions and layout guidelines from the official **[MkDocs Material reference](https://squidfunk.github.io/mkdocs-material/reference/)** for callouts, tables, code blocks, and more. This ensures consistent formatting across the docs.
61+
62+
Keep file names in `lowercase-hyphen-case.md` and use relative links when referencing other docs or images.
63+
64+
---
65+
66+
## 🗂️ Ordering pages with `.pages`
67+
68+
For directories that contain multiple Markdown files, we rely on the [awesome-pages](https://henrywhitaker3.github.io/mkdocs-material-dark-theme/plugins/awesome-pages/) MkDocs plugin.
69+
70+
Creating a `.pages` file inside a folder lets you:
71+
72+
* **Set the section title** (different from the folder name).
73+
* **Control the left‑nav order** without touching the root `mkdocs.yml`.
74+
* **Hide** specific files from the navigation.
75+
76+
We do **not** auto-generate the `nav:` structure – you must create `.pages` manually.
77+
78+
Example – *docs for the **development** section:*
79+
80+
```yaml
81+
# docs/docs/development/.pages
82+
# This file affects ONLY this folder and its sub‑folders
83+
84+
# Optional: override the title shown in the nav
85+
# title: Development Guide
86+
87+
nav:
88+
- index.md # ➟ /development/ (landing page)
89+
- github.md # contribution workflow
90+
- building.md # local build guide
91+
- packaging.md # release packaging steps
92+
```
93+
94+
Guidelines:
95+
96+
1. Always include `index.md` first so the folder has a clean landing URL.
97+
2. List files **in the exact order** you want them to appear; anything omitted is still built but won't show in the nav.
98+
3. You can nest `.pages` files in deeper folders – rules apply hierarchically.
99+
4. Avoid circular references: do **not** include files from *other* directories.
100+
101+
After saving a `.pages` file, simply refresh the browser running `make serve`; MkDocs will hot‑reload and the navigation tree will update instantly.
102+
103+
---
104+
105+
106+
107+
## ✅ Pre-commit checklist
108+
109+
From the **repository root** run **all** lint & QA checks before pushing:
110+
111+
```bash
112+
make spellcheck # Spell-check the codebase
113+
make spellcheck-sort # Sort local spellcheck dictionary
114+
make markdownlint # Lint Markdown files with markdownlint (requires markdownlint-cli)
115+
make pre-commit # Run all configured pre-commit hooks
116+
```
117+
118+
> These targets are defined in the top-level `Makefile`. Make sure you're in the repository root when running these targets.
119+
120+
---
121+
122+
## 🧹 Cleaning up
123+
124+
```bash
125+
cd docs
126+
make clean # remove generated site/
127+
make git-clean # remove ignored files per .gitignore
128+
make git-scrub # blow away *all* untracked files – use with care!
129+
```
130+
131+
---
132+
133+
## 🔄 Rebuilding the static site
134+
135+
> This is not necessary, as this will be done automatically when publishing.
136+
137+
```bash
138+
cd docs
139+
make build # outputs HTML into docs/site/
140+
```
141+
142+
The `build` target produces a fully-static site (used by CI for docs previews and by GitHub Pages).
143+
144+
---
145+
146+
## 📤 Publishing (CI)
147+
148+
Docs are tested, but not deployed automatically by GitHub Actions on every push to `main`. The workflow runs `cd docs && make build`.
149+
150+
Publishing is done manually by repo maintainers with `make deploy` which publishes the generated site to **GitHub Pages**.
151+
152+
---
153+
154+
## 🔗 Related reading
155+
156+
* [Building Locally](building.md) – how to run the gateway itself

docs/docs/manage/tuning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
> 1. Tune the **runtime environment** via `.env` and configure mcpgateway to use PostgreSQL and Redis.
88
> 2. Adjust **Gunicorn** workers & time‑outs in `gunicorn.conf.py`.
99
> 3. Right‑size **CPU/RAM** for the container or spin up more instances (with shared Redis state) and change the database settings (ex: connection limits).
10-
> 4. Benchmark with **hey** (or your favourite load‑generator) before & after.
10+
> 4. Benchmark with **hey** (or your favourite load‑generator) before & after. See also: [performance testing guide](../testing/performance.md)
1111
1212
---
1313

docs/docs/testing/.pages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
nav:
22
- index.md
33
- basic.md
4+
- performance.md

docs/docs/testing/performance.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Performance Testing
2+
3+
Use this guide to benchmark **MCP Gateway** under load, validate performance improvements, and identify bottlenecks before production deployment.
4+
5+
---
6+
7+
## ⚙️ Tooling: `hey`
8+
9+
[`hey`](https://github.com/rakyll/hey) is a CLI-based HTTP load generator. Install it with:
10+
11+
```bash
12+
brew install hey # macOS
13+
sudo apt install hey # Debian/Ubuntu
14+
go install github.com/rakyll/hey@latest # From source
15+
```
16+
17+
---
18+
19+
## 🎯 Establishing a Baseline
20+
21+
Before benchmarking the full MCP Gateway stack, run tests against the **MCP server directly** (if applicable) to establish baseline latency and throughput. This helps isolate issues related to gateway overhead, authentication, or network I/O.
22+
23+
If your backend service exposes a direct HTTP interface or gRPC gateway, target it with `hey` using the same payload and concurrency settings.
24+
25+
```bash
26+
hey -n 5000 -c 100 \
27+
-m POST \
28+
-T application/json \
29+
-D tests/hey/payload.json \
30+
http://localhost:5000/your-backend-endpoint
31+
```
32+
33+
Compare the 95/99th percentile latencies and error rates with and without the gateway in front. Any significant increase can guide you toward:
34+
35+
* Bottlenecks in auth middleware
36+
* Overhead from JSON-RPC wrapping/unwrapping
37+
* Improper worker/thread config in Gunicorn
38+
39+
## 🚀 Scripted Load Tests: `tests/hey/hey.sh`
40+
41+
A wrapper script exists at:
42+
43+
```bash
44+
tests/hey/hey.sh
45+
```
46+
47+
This script provides:
48+
49+
* Strict error handling (`set -euo pipefail`)
50+
* Helpful CLI interface (`-n`, `-c`, `-d`, etc.)
51+
* Required dependency checks
52+
* Optional dry-run mode
53+
* Timestamped logging
54+
55+
Example usage:
56+
57+
```bash
58+
./hey.sh -n 10000 -c 200 \
59+
-X POST \
60+
-T application/json \
61+
-H "Authorization: Bearer $JWT" \
62+
-d payload.json \
63+
-u http://localhost:4444/rpc
64+
```
65+
66+
> The `payload.json` file is expected to be a valid JSON-RPC request payload.
67+
68+
Sample payload (`tests/hey/payload.json`):
69+
70+
```json
71+
{
72+
"jsonrpc": "2.0",
73+
"id": 1,
74+
"method": "convert_time",
75+
"params": {
76+
"source_timezone": "Europe/Berlin",
77+
"target_timezone": "Europe/Dublin",
78+
"time": "09:00"
79+
}
80+
}
81+
```
82+
83+
Logs are saved automatically (e.g. `hey-20250610_120000.log`).
84+
85+
---
86+
87+
## 📊 Interpreting Results
88+
89+
When the test completes, look at:
90+
91+
| Metric | Interpretation |
92+
| ------------------ | ------------------------------------------------------- |
93+
| Requests/sec (RPS) | Raw throughput capability |
94+
| 95/99th percentile | Tail latency — tune `timeout`, workers, or DB pooling |
95+
| Non-2xx responses | Failures under load — common with CPU/memory starvation |
96+
97+
---
98+
99+
## 🧪 Tips & Best Practices
100+
101+
* Always test against a **realistic endpoint** (e.g. `POST /rpc` with auth and payload).
102+
* Use the same JWT and payload structure your clients would.
103+
* Run from a dedicated machine to avoid local CPU skewing results.
104+
* Use `make run` or `make serve` to launch the app for local testing.
105+
106+
For runtime tuning details, see [Gateway Tuning Guide](../manage/tuning.md).
107+
108+
---

docs/docs/using/clients/copilot.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,3 @@ Expected: Copilot invokes the Gateway's `echo` tool and displays the response.
144144
* [Copilot Docs](https://github.com/features/copilot)
145145

146146
---
147-
148-
Would you like this exported as a Markdown file or added to your MkDocs site?

tests/hey/payload2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
"time": "09:00"
1111
}
1212
}
13-
}
13+
}

0 commit comments

Comments
 (0)