chore: Refactor code structure for improved readability and maintainability

This commit is contained in:
Sun-ZhenXing
2025-11-01 20:51:02 +08:00
parent 14ebafdc7a
commit 9c793622d7
7 changed files with 786 additions and 584 deletions

3
.gitignore vendored
View File

@@ -1,3 +1,6 @@
# Trace files
radar.duckdb*
# Environment files # Environment files
.env .env
.env.* .env.*

View File

@@ -70,4 +70,4 @@ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1 CMD curl -f http://localhost:${PORT}/health || exit 1
EXPOSE ${PORT} EXPOSE ${PORT}
CMD ["sh", "-c", "uv run --no-sync prod --host 0.0.0.0 --port ${PORT}"] CMD ["sh", "-c", "uv run --no-sync mcp-template-python --host 0.0.0.0 --port ${PORT}"]

View File

@@ -1,52 +1,54 @@
.PHONY: i dev prod build clean update lint docker-build docker-run helm-install helm-upgrade helm-uninstall helm-lint rename .PHONY: i dev prod build clean update lint docker-build docker-run helm-install helm-upgrade helm-uninstall helm-lint rename
args := $(wordlist 2, $(words $(MAKECMDGOALS)), $(MAKECMDGOALS))
i: i:
uv sync --all-extras --all-packages $(filter-out i,$(MAKECMDGOALS)) uv sync --all-extras --all-packages $(args)
dev: dev:
uv run --no-sync python -c "__import__('mcp_template_python.__main__').__main__.dev()" $(filter-out dev,$(MAKECMDGOALS)) || echo shutdown uv run --no-sync python -c "__import__('mcp_template_python.__main__').__main__.dev()" $(args) || echo shutdown
prod: prod:
uv run --no-sync python -c "__import__('mcp_template_python.__main__').__main__.main()" $(filter-out prod,$(MAKECMDGOALS)) uv run --no-sync python -c "__import__('mcp_template_python.__main__').__main__.main()" $(args)
build: build:
uv build $(filter-out build,$(MAKECMDGOALS)) uv build $(args)
clean: clean:
rm -rf .venv .ruff_cache dist/ build/ *.egg-info $(filter-out clean,$(MAKECMDGOALS)) rm -rf .venv .ruff_cache dist/ build/ *.egg-info $(args)
update: update:
uv sync --all-extras --all-packages -U $(filter-out update,$(MAKECMDGOALS)) uv sync --all-extras --all-packages -U $(args)
lint: lint:
uv run ruff check . $(filter-out lint,$(MAKECMDGOALS)) uv run ruff check . $(args)
docker-build: docker-build:
docker compose build $(filter-out docker-build,$(MAKECMDGOALS)) docker compose build $(args)
docker-run: docker-run:
docker compose up -d $(filter-out docker-run,$(MAKECMDGOALS)) docker compose up -d $(args)
helm-lint: helm-lint:
helm lint helm/mcp-template-python helm lint helm/mcp-template-python $(args)
helm-install: helm-install:
helm install mcp-template-python helm/mcp-template-python helm install mcp-template-python helm/mcp-template-python $(args)
helm-upgrade: helm-upgrade:
helm upgrade mcp-template-python helm/mcp-template-python helm upgrade mcp-template-python helm/mcp-template-python $(args)
helm-install-prod: helm-install-prod:
helm install mcp-template-python helm/mcp-template-python -f values-production.yaml helm install mcp-template-python helm/mcp-template-python -f values-production.yaml $(args)
helm-upgrade-prod: helm-upgrade-prod:
helm upgrade mcp-template-python helm/mcp-template-python -f values-production.yaml helm upgrade mcp-template-python helm/mcp-template-python -f values-production.yaml $(args)
helm-uninstall: helm-uninstall:
helm uninstall mcp-template-python helm uninstall mcp-template-python $(args)
rename: rename:
uv run python tools/rename.py $(filter-out rename,$(MAKECMDGOALS)) uv run python tools/rename.py $(args)
%: %:
@: @true

View File

@@ -15,7 +15,7 @@ class AppSettings(BaseSettings):
model_config = SettingsConfigDict( model_config = SettingsConfigDict(
env_prefix="APP_", env_prefix="APP_",
extra="allow", extra="ignore",
) )
mcp: MCPSettings = MCPSettings() mcp: MCPSettings = MCPSettings()

View File

@@ -8,7 +8,7 @@ class CORSSettings(BaseSettings):
model_config = SettingsConfigDict( model_config = SettingsConfigDict(
env_prefix="CORS_", env_prefix="CORS_",
extra="allow", extra="ignore",
) )
allow_origins: str = "*" allow_origins: str = "*"

View File

@@ -8,7 +8,7 @@ class MCPSettings(BaseSettings):
model_config = SettingsConfigDict( model_config = SettingsConfigDict(
env_prefix="MCP_", env_prefix="MCP_",
extra="allow", extra="ignore",
) )
default_mcp: str = "math" default_mcp: str = "math"

1323
uv.lock generated

File diff suppressed because it is too large Load Diff