Khởi chạy Nhanh (10 phút)
Làm theo 4 bước ngắn dưới đây để khởi chạy siêu đồ thị mẫu Walking Skeleton — ghép nối cửa hàng REST OpenAPI (shop) với máy chủ MCP (notes) trong đúng một truy vấn GraphQL.
Bạn sẽ nắm được gì
- Kiểm tra cấu hình an toàn bằng
gap config checkvàgap doctor. - Khởi chạy hai upstream mẫu REST + MCP và tiến trình
gap serve. - Thực thi câu truy vấn gộp dữ liệu từ cả hai nguồn trong một request duy nhất.
Trong trang này
Chuẩn bị Trước khi Chạy
- Binary
gapđã biên dịch (từ bản phát hành hoặc chạy./dist/build-reproducible.sh --offlinetạo ra./target/dist/gap). - Python 3.10+ để chạy hai dịch vụ giả lập mẫu trong
examples/walking-skeleton/fixtures/.
Hướng dẫn Từng bước
-
Kiểm tra hợp lệ tệp cấu hình
Chạy kiểm tra tĩnh với
examples/walking-skeleton/gap.toml. GAP từ chối khởi động ngay nếu thấy trường lạ, bí mật ghi trần không qua biến môi trường hoặc thiếu tệp spec:./target/dist/gap config check examples/walking-skeleton/gap.toml ./target/dist/gap doctor --config examples/walking-skeleton/gap.tomlok: `examples/walking-skeleton/gap.toml` valid (2 branches) [ok] config.parse: parsed examples/walking-skeleton/gap.toml (profile=dev) [ok] security.sandbox: OS sandbox operational [ok] security.egress_guard: egress SSRF self-test matrix passed [warn] models.s1: model cache incomplete offline; degrades safely to baseline (RTE-044) summary: 11 ok, 1 warn, 0 fail, 0 skip- Lưu ý: Cả hai lệnh trả về mã thoát
0(OPS-044). Khóa APIdev-agentđược lưu bằng mã băm BLAKE3 trong TOML.
- Lưu ý: Cả hai lệnh trả về mã thoát
-
Khởi chạy hai máy chủ upstream mẫu
Bật giả lập REST API trên cổng
9101và máy chủ MCP trên cổng9102:python3 examples/walking-skeleton/fixtures/rest_fixture.py --port 9101 & python3 examples/walking-skeleton/fixtures/mcp_fixture.py --port 9102 & -
Khởi chạy Cổng GAP Gateway
Chạy lệnh
gap servetrỏ tới cấu hình Walking Skeleton:./target/dist/gap serve --config examples/walking-skeleton/gap.toml- Kiểm tra sẵn sàng:
GET http://127.0.0.1:8080/readyztrả HTTP200({"status":"ready","generation":1}) ngay khi thế hệ snapshot1được nạp xong.
- Kiểm tra sẵn sàng:
-
Gửi truy vấn gộp liên nhánh đầu tiên
Lấy hồ sơ khách hàng + đơn hàng từ nhánh OpenAPI
shopkèm JSON ghi chú từ nhánh MCPnotestrong 1 lần gọi HTTP (chú ýcustomer_notestrả về kiểu vô hướngJSONnên gọi trực tiếp không mở ngoặc con):curl -sS -X POST http://127.0.0.1:8080/graphql \ -H "Content-Type: application/json" \ -H "Accept: application/graphql-response+json" \ -H "Authorization: Bearer gap_dev_skeleton_key_01" \ -d '{"query": "{ customer(id: 1) { id name tier } orders(customer_id: 1) { id total_cents status } customer_notes(customer_id: 1) }"}' | python3 -m json.tool{ "data": { "customer": { "id": 1, "name": "Ada Lovelace", "tier": "vip" }, "orders": [ { "id": 101, "total_cents": 4200, "status": "paid" }, { "id": 103, "total_cents": 8500, "status": "pending" } ], "customer_notes": { "customer_id": 1, "notes": [{ "note_id": "n-1", "customer_id": 1, "summary": "Prefers consolidated monthly invoice" }] } }, "extensions": { "gap": { "cost": { "actual": 7, "planned": 306 }, "generation": 1, "partial": false } } }
Bước 5: Gắn vào MCP Host hoặc Phát Luồng AG-UI
Thay vì cấu hình từng công cụ REST rời rạc, hãy trỏ AI host vào MCP server 5 tool cố định của GAP qua stdio, hoặc nhận luồng sự kiện AG-UI v1.0 qua SSE. Xem chi tiết tích hợp tại Tích hợp MCP, A2A & AG-UI.
{
"mcpServers": {
"gap-gateway": {
"command": "/path/to/GraphProtocol/target/dist/gap",
"args": ["serve", "--config", "examples/walking-skeleton/gap.toml", "--stdio"]
}
}
}
curl -sS -N -X POST http://127.0.0.1:8080/ag-ui \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-H "Authorization: Bearer gap_dev_skeleton_key_01" \
-d '{"threadId":"t1","runId":"r1","messages":[],"forwardedProps":{"graphql":{"query":"{ customer(id: 1) { id name } customer_notes(customer_id: 1) }"}}}'