resource pattern

This commit is contained in:
John Lancaster
2026-06-18 19:38:57 -05:00
parent dbaaad8df8
commit d54f427112
11 changed files with 290 additions and 0 deletions
@@ -1,7 +1,14 @@
id: fastapi-uv-docker
name: FastAPI uv Docker
version: 1.0.0
description: Provide fast migration guidance to FastAPI plus uv plus Docker.
tags:
- fastapi
- uv
- docker
capabilities:
- resource://skills/fastapi_uv_docker/overview
- resource://skills/fastapi_uv_docker/rules
- resource://skills/fastapi_uv_docker/checklist
- resource://skills/fastapi_uv_docker/references
depends_on: []
@@ -1,7 +1,79 @@
from pathlib import Path
from fastmcp import FastMCP
fastapi_uv_docker_server = FastMCP("fastapi-uv-docker")
_REFERENCE_DIR = (
Path(__file__).resolve().parents[4]
/ "skills"
/ "fastapi-uv-docker"
/ "references"
)
_REFERENCE_FILES = {
"fastapi_best_practices": _REFERENCE_DIR / "fastapi-best-practices.md",
"uv_project_layout": _REFERENCE_DIR / "uv-project-layout.md",
"uvicorn_settings": _REFERENCE_DIR / "uvicorn-settings.md",
"docker_cloud_native": _REFERENCE_DIR / "docker-cloud-native.md",
}
def _load_reference_bundle() -> dict[str, str]:
bundle: dict[str, str] = {}
for key, path in _REFERENCE_FILES.items():
bundle[key] = path.read_text(encoding="utf-8")
return bundle
@fastapi_uv_docker_server.resource("resource://skills/fastapi_uv_docker/overview")
def fastapi_overview() -> dict:
"""Return high-level intent for FastAPI plus uv plus Docker migration."""
return {
"id": "fastapi-uv-docker",
"intent": "Migrate projects toward cloud-native FastAPI architecture managed by uv.",
"focus": [
"src package layout",
"uv-based dependency and lock management",
"container-ready runtime conventions",
],
}
@fastapi_uv_docker_server.resource("resource://skills/fastapi_uv_docker/rules")
def fastapi_rules() -> dict:
"""Return migration rules for stable FastAPI service architecture."""
return {
"rules": [
"Prefer src layout and installable package boundaries.",
"Use app factory and lifespan hooks for startup/shutdown ownership.",
"Keep runtime configuration in environment-backed settings.",
"Use uv lockfile and avoid drift between local and container environments.",
]
}
@fastapi_uv_docker_server.resource("resource://skills/fastapi_uv_docker/checklist")
def fastapi_checklist() -> dict:
"""Return a compact migration checklist for FastAPI plus uv plus Docker."""
return {
"checklist": [
"Audit current project manager, layout, and runtime settings.",
"Establish uv project metadata and lockfile ownership.",
"Implement app factory, lifespan, and health endpoints.",
"Create multi-stage Docker image with non-root runtime user.",
]
}
@fastapi_uv_docker_server.resource("resource://skills/fastapi_uv_docker/references")
def fastapi_references() -> dict:
"""Return bundled references for detailed implementation guidance."""
return {
"sources": {key: str(path) for key, path in _REFERENCE_FILES.items()},
"format": "markdown",
"content": _load_reference_bundle(),
}
@fastapi_uv_docker_server.tool()
def fastapi_uv_docker_mvp_checklist(current_state: str = "bare python project") -> list[str]:
@@ -1,7 +1,14 @@
id: pytest-scaffolding
name: Pytest Scaffolding
version: 1.0.0
description: Scaffold a maintainable pytest structure quickly.
tags:
- pytest
- testing
- python
capabilities:
- resource://skills/pytest_scaffolding/overview
- resource://skills/pytest_scaffolding/rules
- resource://skills/pytest_scaffolding/checklist
- resource://skills/pytest_scaffolding/references
depends_on: []
@@ -1,7 +1,82 @@
from pathlib import Path
from fastmcp import FastMCP
pytest_scaffolding_server = FastMCP("pytest-scaffolding")
_REFERENCE_PATH = (
Path(__file__).resolve().parents[4]
/ "skills"
/ "pytest-scaffolding"
/ "references"
/ "pytest-docs.md"
)
def _load_reference_text() -> str:
return _REFERENCE_PATH.read_text(encoding="utf-8")
@pytest_scaffolding_server.resource("resource://skills/pytest_scaffolding/overview")
def pytest_overview() -> dict:
"""Return the high-level intent and boundaries of this pattern module."""
return {
"id": "pytest-scaffolding",
"intent": "Design maintainable pytest structure before deep test implementation.",
"focus": [
"hierarchical test layout",
"dependency-aware fixture boundaries",
"fast local feedback loops",
],
}
@pytest_scaffolding_server.resource("resource://skills/pytest_scaffolding/rules")
def pytest_rules() -> dict:
"""Return method rules to keep test architecture consistent."""
return {
"rules": [
"Mirror major source package boundaries under tests/.",
"Use explicit markers for integration, smoke, and external tests.",
"Keep global fixtures lightweight; place expensive fixtures in subtree conftest files.",
"Prefer deterministic unit tests and isolate slow or external dependencies.",
]
}
@pytest_scaffolding_server.resource("resource://skills/pytest_scaffolding/checklist")
def pytest_checklist() -> dict:
"""Return an execution checklist for first-pass test scaffolding."""
return {
"checklist": [
"Map source modules to initial test modules.",
"Classify each module as unit, integration, or smoke.",
"Create baseline fixtures in tests/conftest.py.",
"Register markers in pyproject.toml.",
"Validate collection and run fast path first.",
]
}
@pytest_scaffolding_server.resource("resource://skills/pytest_scaffolding/references")
def pytest_references() -> dict:
"""Return canonical reference material for this pattern module."""
return {
"source": str(_REFERENCE_PATH),
"format": "markdown",
"content": _load_reference_text(),
}
@pytest_scaffolding_server.prompt()
def scaffold_pytest_prompt(target_scope: str = "src/") -> str:
"""Prompt template for planning pytest scaffolding for a target scope."""
return (
"Create a minimal pytest scaffold plan. "
f"Target scope: {target_scope}. "
"Return directory mapping, marker suggestions, and the first three tests to write."
)
@pytest_scaffolding_server.tool()
def propose_pytest_mvp_tree(target_scope: str = "src/") -> str:
@@ -1,7 +1,14 @@
id: python-logging-dictconfig
name: Python Logging DictConfig
version: 1.0.0
description: Provide minimal logging.config.dictConfig setup guidance.
tags:
- logging
- python
- observability
capabilities:
- resource://skills/python_logging_dictconfig/overview
- resource://skills/python_logging_dictconfig/rules
- resource://skills/python_logging_dictconfig/checklist
- resource://skills/python_logging_dictconfig/references
depends_on: []
@@ -1,7 +1,71 @@
from pathlib import Path
from fastmcp import FastMCP
python_logging_dictconfig_server = FastMCP("python-logging-dictconfig")
_REFERENCE_PATH = (
Path(__file__).resolve().parents[4]
/ "skills"
/ "python-logging-dictconfig"
/ "references"
/ "python-logging-docs.md"
)
def _load_reference_text() -> str:
return _REFERENCE_PATH.read_text(encoding="utf-8")
@python_logging_dictconfig_server.resource("resource://skills/python_logging_dictconfig/overview")
def logging_overview() -> dict:
"""Return high-level purpose and intended outcomes for logging configuration."""
return {
"id": "python-logging-dictconfig",
"intent": "Centralize Python logging setup with dictConfig during application startup.",
"focus": [
"single startup configuration",
"consistent formatting and level policy",
"named module loggers without local configuration",
],
}
@python_logging_dictconfig_server.resource("resource://skills/python_logging_dictconfig/rules")
def logging_rules() -> dict:
"""Return implementation rules for predictable logging behavior."""
return {
"rules": [
"Call dictConfig once at startup, not in leaf modules.",
"Use logging.getLogger(__name__) in all modules.",
"Avoid basicConfig in application packages.",
"Set disable_existing_loggers to False unless intentional suppression is required.",
]
}
@python_logging_dictconfig_server.resource("resource://skills/python_logging_dictconfig/checklist")
def logging_checklist() -> dict:
"""Return a startup checklist for logging configuration rollout."""
return {
"checklist": [
"Define formatter, handlers, and root logger in one LOGGING dict.",
"Wire configure_logging() in startup path only once.",
"Verify expected output at DEBUG/INFO/WARNING/ERROR levels.",
"Tune noisy third-party loggers intentionally.",
]
}
@python_logging_dictconfig_server.resource("resource://skills/python_logging_dictconfig/references")
def logging_references() -> dict:
"""Return canonical reference material for dictConfig-based logging."""
return {
"source": str(_REFERENCE_PATH),
"format": "markdown",
"content": _load_reference_text(),
}
@python_logging_dictconfig_server.tool()
def logging_dictconfig_template(level: str = "INFO") -> dict: