|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from mcp.server.fastmcp import FastMCP |
| 4 | + |
| 5 | + |
| 6 | +def register_system_prompts(mcp: FastMCP) -> None: |
| 7 | + @mcp.prompt( |
| 8 | + name="system_design_overview", |
| 9 | + description="Produce a complete architectural overview of the whole system: service inventory," |
| 10 | + " communication topology, shared data stores, and cross-cutting concerns.", |
| 11 | + ) |
| 12 | + def system_design_overview() -> str: |
| 13 | + """Complete system design overview across all indexed services.""" |
| 14 | + return ( |
| 15 | + "Produce a complete system design overview using the semcode MCP tools. " |
| 16 | + "Work through these steps:\n" |
| 17 | + "\n" |
| 18 | + "1. **Discover the service inventory.** Call `list_indexed_services` to get " |
| 19 | + "the full list. If nothing is indexed, stop and tell the user.\n" |
| 20 | + "\n" |
| 21 | + "2. **Profile each service.** For every service, invoke the `service_overview` " |
| 22 | + "prompt — it will identify entry points, domain types, and framework " |
| 23 | + "conventions for that service. Collect those summaries before proceeding.\n" |
| 24 | + "\n" |
| 25 | + "3. **Map inter-service communication.** Search across all services for " |
| 26 | + "outbound call patterns using queries like: " |
| 27 | + '`"http client"`, `"feign client"`, `"rest template"`, ' |
| 28 | + '`"grpc stub"`, `"kafka producer"`, `"message publisher"`, ' |
| 29 | + '`"event emitter"`, `"amqp"`. ' |
| 30 | + "Build a dependency list noting which services are callers and which are " |
| 31 | + "called, and whether communication is synchronous or asynchronous.\n" |
| 32 | + "\n" |
| 33 | + "4. **Identify shared infrastructure.** Search for terms like " |
| 34 | + '`"datasource"`, `"redis"`, `"kafka"`, `"rabbitmq"`, `"s3"`, ' |
| 35 | + '`"mongo"`, `"postgres"`, `"elasticsearch"` to surface data stores, ' |
| 36 | + "caches, and message brokers. Note which services own vs. share each resource.\n" |
| 37 | + "\n" |
| 38 | + "5. **Find cross-cutting concerns.** Search for `\"authentication\"`, `\"jwt\"`, " |
| 39 | + '`"oauth"`, `"tracing"`, `"opentelemetry"`, `"metrics"`, ' |
| 40 | + '`"circuit breaker"`, `"retry"`, `"rate limit"` to understand ' |
| 41 | + "system-wide conventions.\n" |
| 42 | + "\n" |
| 43 | + "Then write the overview with these sections:\n" |
| 44 | + "\n" |
| 45 | + "- **System Purpose** — 2-3 sentences on what problem this collection of " |
| 46 | + "services solves as a whole.\n" |
| 47 | + "- **Service Inventory** — a table: Service | Purpose | Tech Stack | Entry Style.\n" |
| 48 | + "- **Communication Topology** — synchronous (REST/gRPC) vs asynchronous " |
| 49 | + "(events/queues) interactions. Include a dependency list: " |
| 50 | + "`ServiceA → ServiceB (REST)`, `ServiceC → broker → ServiceD (async)`, etc.\n" |
| 51 | + "- **Data Architecture** — data stores, caches, and message brokers with " |
| 52 | + "ownership notes (owned by one service vs. shared).\n" |
| 53 | + "- **Cross-cutting Concerns** — how authentication, observability (tracing, " |
| 54 | + "metrics, logging), and resilience (retries, circuit breakers) are handled " |
| 55 | + "across the system.\n" |
| 56 | + "- **Key Architectural Patterns** — flag patterns you have evidence for: " |
| 57 | + "event-driven, CQRS, saga, API gateway, BFF, strangler fig, etc.\n" |
| 58 | + "\n" |
| 59 | + "Skip any section you have no evidence for. Do not invent details." |
| 60 | + ) |
0 commit comments