Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ jobs:
exit 1
fi

- name: Check template metadata
run: python scripts/check_template_ready.py

- name: Build
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ permissions:
contents: read
jobs:
checks:
uses: starter-series/.github/.github/workflows/reusable-python-ci.yml@main
uses: starter-series/.github/.github/workflows/reusable-python-ci.yml@fdacdbce9d1dd18a573e7c57c482bb07ab1f2954
ci:
if: ${{ always() }}
needs:
- checks
runs-on: ubuntu-latest
steps:
- uses: starter-series/.github/.github/actions/require-checks@main
- uses: starter-series/.github/.github/actions/require-checks@fdacdbce9d1dd18a573e7c57c482bb07ab1f2954
with:
results: ${{ toJSON(needs) }}
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ permissions:
security-events: write
jobs:
analyze:
uses: starter-series/.github/.github/workflows/reusable-codeql.yml@main
uses: starter-series/.github/.github/workflows/reusable-codeql.yml@fdacdbce9d1dd18a573e7c57c482bb07ab1f2954
with:
language: python
2 changes: 2 additions & 0 deletions README.ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,5 @@ pip-audit . --strict # 의존성 audit
## 라이선스

MIT

게시 전에 패키지 이름·저자·프로젝트 URL·콘솔 명령을 수정하고 실행하세요: `python scripts/check_template_ready.py`.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,5 @@ pip-audit . --strict # Dependency audit
## License

MIT

Before publishing, customize the package name, author, project URLs, and console command, then run `python scripts/check_template_ready.py`.
50 changes: 50 additions & 0 deletions scripts/check_template_ready.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""Reject uncustomized package metadata before publishing to PyPI."""

import re
import sys
import tomllib
from pathlib import Path
from typing import Any


def find_issues(project: dict[str, Any]) -> list[str]:
issues = []
name = project.get("name", "")
if not name or re.sub(r"[-_.]+", "-", name).lower() == "my-mcp-server":
issues.append("project.name: replace my-mcp-server with your package name")
authors = project.get("authors", [])
if not authors or any(not a.get("name") or a["name"] == "Your Name" for a in authors):
issues.append("project.authors: set the package author")
urls = project.get("urls", {})
for field in ("Homepage", "Repository", "Issues"):
value = urls.get(field, "")
if (
not value
or "starter-series/python-mcp-server-starter" in value.lower()
or "YOUR_" in value
):
issues.append(f"project.urls.{field}: set your project's URL")
if "my-mcp-server" in project.get("scripts", {}):
issues.append("project.scripts: rename the my-mcp-server console command")
return issues


def main() -> int:
path = (
Path(sys.argv[1])
if len(sys.argv) > 1
else Path(__file__).resolve().parents[1] / "pyproject.toml"
)
with path.open("rb") as stream:
issues = find_issues(tomllib.load(stream).get("project", {}))
if issues:
print("Template metadata is not ready to publish:", file=sys.stderr)
for issue in issues:
print(f"- {issue}", file=sys.stderr)
return 1
print("Template metadata is ready to publish.")
return 0


if __name__ == "__main__":
raise SystemExit(main())
36 changes: 36 additions & 0 deletions tests/test_template_ready.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import runpy
from pathlib import Path

find_issues = runpy.run_path(
str(Path(__file__).resolve().parents[1] / "scripts/check_template_ready.py")
)["find_issues"]


def test_rejects_template_metadata():
issues = find_issues(
{
"name": "my_mcp_server",
"authors": [{"name": "Your Name"}],
"urls": {"Repository": "https://github.com/starter-series/python-mcp-server-starter"},
"scripts": {"my-mcp-server": "sample.__main__:run"},
}
)
assert len(issues) == 6


def test_accepts_customized_metadata():
assert (
find_issues(
{
"name": "sample-mcp",
"authors": [{"name": "Heznpc"}],
"urls": {
"Homepage": "https://github.com/sample/sample-mcp",
"Repository": "https://github.com/sample/sample-mcp",
"Issues": "https://github.com/sample/sample-mcp/issues",
},
"scripts": {"sample-mcp": "sample.__main__:run"},
}
)
== []
)
Loading