docs(standards): vendor template into MCP bundle; add component tools + start_app prompt
This commit is contained in:
7
standards/mcp/templates/app/scripts/__init__.py
Normal file
7
standards/mcp/templates/app/scripts/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
||||
"""# Summary
|
||||
|
||||
Operator scripts — run from the project root as ``python -m scripts.<name>``.
|
||||
|
||||
They use the composition root (:func:`init.init` / :func:`init.shutdown`) so they
|
||||
share the exact wiring the API and worker use.
|
||||
"""
|
||||
32
standards/mcp/templates/app/scripts/drop.py
Normal file
32
standards/mcp/templates/app/scripts/drop.py
Normal file
@@ -0,0 +1,32 @@
|
||||
"""# Summary
|
||||
|
||||
Operator script — drop the collections owned by each service for a clean slate.
|
||||
|
||||
Run from the project root:
|
||||
|
||||
python -m scripts.drop
|
||||
"""
|
||||
import asyncio
|
||||
|
||||
from init import init, shutdown
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
"""Delete every service collection, best-effort, then shut down."""
|
||||
resources = await init()
|
||||
try:
|
||||
dropped = 0
|
||||
for name, svc in resources.items():
|
||||
if not name.endswith("_svc"):
|
||||
continue
|
||||
delete_many = getattr(svc.repo, "delete_many", None)
|
||||
if delete_many is not None:
|
||||
await delete_many({})
|
||||
dropped += 1
|
||||
print(f"Dropped {dropped} service collection(s).")
|
||||
finally:
|
||||
await shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
26
standards/mcp/templates/app/scripts/seed.py
Normal file
26
standards/mcp/templates/app/scripts/seed.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""# Summary
|
||||
|
||||
Operator script — seed demo data through the composition root.
|
||||
|
||||
Run from the project root:
|
||||
|
||||
python -m scripts.seed
|
||||
"""
|
||||
import asyncio
|
||||
|
||||
from init import init, shutdown
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
"""Seed one demo item and shut down cleanly."""
|
||||
resources = await init()
|
||||
try:
|
||||
item_svc = resources["item_svc"]
|
||||
await item_svc.create({"name": "seed", "quantity": 1})
|
||||
print("Seeded one item.")
|
||||
finally:
|
||||
await shutdown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user