Skip to content

Commit 8c7eb16

Browse files
lesnik512claude
andauthored
docs: add Quickstart page and surface FastMCP in nav (#134)
End-to-end FastAPI walkthrough (install, bootstrap, run, what-you-get, enabling more instruments). Also adds the existing FastMCP integration page to the nav, where it was previously unreachable. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3bb26ad commit 8c7eb16

2 files changed

Lines changed: 120 additions & 0 deletions

File tree

docs/introduction/quickstart.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Quickstart
2+
3+
This walkthrough takes you from an empty project to a **FastAPI service with
4+
production instrumentation** — metrics, health checks, CORS, Swagger, and
5+
structured logging — wired up in a few lines. The same pattern applies to
6+
[Litestar](../integrations/litestar.md), [FastStream](../integrations/faststream.md),
7+
[FastMCP](../integrations/fastmcp.md), and
8+
[framework-free services](../integrations/free.md).
9+
10+
## 1. Install
11+
12+
Install `lite-bootstrap` with the FastAPI extras. `fastapi-all` pulls in every
13+
supported instrument:
14+
15+
=== "uv"
16+
17+
```bash
18+
uv add lite-bootstrap[fastapi-all]
19+
```
20+
21+
=== "pip"
22+
23+
```bash
24+
pip install lite-bootstrap[fastapi-all]
25+
```
26+
27+
=== "poetry"
28+
29+
```bash
30+
poetry add lite-bootstrap[fastapi-all]
31+
```
32+
33+
Want only some instruments? See the extras matrix in
34+
[Installation](installation.md).
35+
36+
## 2. Bootstrap your application
37+
38+
Create `main.py`:
39+
40+
```python
41+
from fastapi import FastAPI
42+
from lite_bootstrap import FastAPIConfig, FastAPIBootstrapper
43+
44+
config = FastAPIConfig(
45+
service_name="my-service",
46+
service_version="1.0.0",
47+
service_environment="local",
48+
prometheus_metrics_path="/metrics",
49+
health_checks_enabled=True,
50+
health_checks_path="/health",
51+
cors_allowed_origins=["*"],
52+
swagger_offline_docs=True,
53+
)
54+
55+
app: FastAPI = FastAPIBootstrapper(config).bootstrap()
56+
57+
58+
@app.get("/")
59+
async def root() -> dict[str, str]:
60+
return {"hello": "world"}
61+
```
62+
63+
`bootstrap()` returns a ready `FastAPI` app with every configured instrument
64+
attached.
65+
66+
## 3. Run it
67+
68+
```bash
69+
uvicorn main:app --reload
70+
```
71+
72+
## 4. What you get
73+
74+
With the config above, your service now exposes:
75+
76+
- **Metrics** at `/metrics` in Prometheus format — point your scraper at it.
77+
- **Health check** at `/health` — wire it to your orchestrator's readiness probe.
78+
- **Swagger UI** at `/docs` — with offline assets, so it renders without a CDN.
79+
- **CORS** headers for the configured origins.
80+
- **Structured logging** via `structlog` — enabled by default (opt out with
81+
`logging_enabled=False`).
82+
83+
## 5. Enable more
84+
85+
Each instrument is opt-in: add its config field to turn it on. Unset (or empty)
86+
fields are skipped automatically, so you only pay for what you enable.
87+
88+
```python
89+
config = FastAPIConfig(
90+
service_name="my-service",
91+
service_version="1.0.0",
92+
service_environment="local",
93+
# tracing — spans exported to your OTLP endpoint
94+
opentelemetry_endpoint="http://localhost:4317",
95+
# error reporting
96+
sentry_dsn="https://examplePublicKey@o0.ingest.sentry.io/0",
97+
# continuous profiling (needs the `pyroscope` extra)
98+
pyroscope_endpoint="http://localhost:4040",
99+
)
100+
```
101+
102+
To see exactly which instruments were enabled or skipped at startup, inspect the
103+
bootstrapper:
104+
105+
```python
106+
bootstrapper = FastAPIBootstrapper(config)
107+
app = bootstrapper.bootstrap()
108+
109+
print(bootstrapper.build_summary()) # human-readable summary
110+
for cls, reason in bootstrapper.skipped_instruments:
111+
print(f"skipped {cls.__name__}: {reason}")
112+
```
113+
114+
## Next steps
115+
116+
- [Configuration](configuration.md) — every config field and per-instrument option.
117+
- [Integrations](../integrations/litestar.md) — Litestar, FastStream, FastMCP,
118+
and framework-free services.

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ docs_dir: docs
55
edit_uri: edit/main/docs/
66
nav:
77
- Introduction:
8+
- Quickstart: introduction/quickstart.md
89
- Installation: introduction/installation.md
910
- Configuration: introduction/configuration.md
1011
- Integrations:
1112
- Litestar: integrations/litestar.md
1213
- FastStream: integrations/faststream.md
1314
- FastAPI: integrations/fastapi.md
15+
- FastMCP: integrations/fastmcp.md
1416
- Free bootstrapper: integrations/free.md
1517
theme:
1618
name: material

0 commit comments

Comments
 (0)