Skip to content
Open
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
109 changes: 109 additions & 0 deletions .github/workflows/publish-mcp-registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: publish-mcp-registry

# Publishes server.json to the official MCP Registry under the
# app.structkit/mcp domain namespace.
# Gated to published GitHub Releases only — never runs on pull requests.
# GitHub OIDC cannot authenticate a domain namespace; this workflow uses
# DNS login with secrets.MCP_PRIVATE_KEY (Ed25519 hex). If the secret is
# unset, login and publish are skipped so the release is not failed.
# Never commit the private key.
on:
release:
types:
- published

jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v7

- name: Check server.json version matches package and release tag
run: |
set -euo pipefail

PACKAGE_VERSION=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
SERVER_VERSION=$(python3 -c "import json; print(json.load(open('server.json'))['version'])")
PACKAGE_ENTRY_VERSION=$(python3 -c "import json; print(json.load(open('server.json'))['packages'][0]['version'])")
RELEASE_VERSION="${GITHUB_REF_NAME#v}"

echo "Package version: $PACKAGE_VERSION"
echo "server.json version: $SERVER_VERSION"
echo "packages[0].version: $PACKAGE_ENTRY_VERSION"
echo "Release version: $RELEASE_VERSION"

if [ "$PACKAGE_VERSION" != "$RELEASE_VERSION" ] || \
[ "$SERVER_VERSION" != "$RELEASE_VERSION" ] || \
[ "$PACKAGE_ENTRY_VERSION" != "$RELEASE_VERSION" ]; then
echo "Error: pyproject.toml, server.json, and the release tag must share the same version"
exit 1
fi

- name: Install mcp-publisher
run: |
set -euo pipefail
curl -fsSL "https://github.com/modelcontextprotocol/registry/releases/latest/download/mcp-publisher_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" \
| tar xz mcp-publisher

- name: Validate server.json
run: ./mcp-publisher validate server.json

- name: Check whether MCP_PRIVATE_KEY is configured
id: mcp-auth
env:
MCP_PRIVATE_KEY: ${{ secrets.MCP_PRIVATE_KEY }}
run: |
if [ -z "${MCP_PRIVATE_KEY}" ]; then
echo "MCP_PRIVATE_KEY is not set; skipping MCP Registry login and publish"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi

- name: Wait for the PyPI release and mcp-name marker
if: steps.mcp-auth.outputs.skip != 'true'
run: |
set -euo pipefail

VERSION=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")

for i in $(seq 1 30); do
if curl -fsSL "https://pypi.org/pypi/structkit/${VERSION}/json" >/dev/null; then
echo "PyPI ${VERSION} is live"
break
fi
echo "waiting for PyPI ${VERSION} (${i}/30)"
sleep 10
if [ "$i" -eq 30 ]; then
echo "PyPI ${VERSION} did not appear within 5 minutes"
exit 1
fi
done

curl -fsSL "https://pypi.org/pypi/structkit/${VERSION}/json" \
| python3 -c "
import json
import sys

data = json.load(sys.stdin)
description = data['info'].get('description') or ''
marker = 'mcp-name: app.structkit/mcp'
present = marker in description
print('marker present:', present)
if not present:
sys.exit('PyPI long description is missing the mcp-name ownership marker')
"

- name: Authenticate to MCP Registry
if: steps.mcp-auth.outputs.skip != 'true'
env:
MCP_PRIVATE_KEY: ${{ secrets.MCP_PRIVATE_KEY }}
run: ./mcp-publisher login dns --domain structkit.app --private-key "${MCP_PRIVATE_KEY}"

- name: Publish server to MCP Registry
if: steps.mcp-auth.outputs.skip != 'true'
run: ./mcp-publisher publish
14 changes: 10 additions & 4 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ jobs:
run: |
set -euo pipefail

# Ensure the version in pyproject.toml matches the release tag being
# published. For manual runs, fall back to the latest published
# release tag.
# Read version from pyproject.toml
# Ensure the version in pyproject.toml and server.json matches the
# release tag being published. For manual runs, fall back to the
# latest published release tag.
PACKAGE_VERSION=$(python -c "import tomllib; f = open('pyproject.toml', 'rb'); data = tomllib.load(f); f.close(); print(data['project']['version'])")
SERVER_VERSION=$(python -c "import json; print(json.load(open('server.json'))['version'])")
echo "Package version: $PACKAGE_VERSION"
echo "server.json version: $SERVER_VERSION"

if [ "${GITHUB_EVENT_NAME}" = "release" ]; then
RELEASE_TAG="${GITHUB_REF_NAME}"
Expand All @@ -55,6 +56,11 @@ jobs:
exit 1
fi

if [ "$SERVER_VERSION" != "$RELEASE_VERSION" ]; then
echo "Error: server.json version ($SERVER_VERSION) does not match release version ($RELEASE_VERSION)"
exit 1
fi

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
Expand Down
37 changes: 24 additions & 13 deletions .github/workflows/release-drafter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update pyproject version from release draft
id: pyproject-version
- name: Update package versions from release draft
id: package-version
env:
RESOLVED_VERSION: ${{ steps.release-drafter.outputs.resolved_version }}
run: |
Expand All @@ -36,13 +36,15 @@ jobs:
fi

python - <<'PY'
import json
import os
import re
from pathlib import Path

version = os.environ["RESOLVED_VERSION"].removeprefix("v")
path = Path("pyproject.toml")
text = path.read_text()

pyproject = Path("pyproject.toml")
text = pyproject.read_text()
updated, count = re.subn(
r'(?m)^(version\s*=\s*")[^"]+(")$',
rf'\g<1>{version}\2',
Expand All @@ -51,27 +53,36 @@ jobs:
)
if count == 0:
raise SystemExit("pyproject.toml version field was not found")
path.write_text(updated)
pyproject.write_text(updated)

server_json = Path("server.json")
data = json.loads(server_json.read_text())
data["version"] = version
packages = data.get("packages") or []
if not packages:
raise SystemExit("server.json packages entry was not found")
packages[0]["version"] = version
server_json.write_text(json.dumps(data, indent=2) + "\n")
PY

if git diff --quiet -- pyproject.toml; then
echo "pyproject.toml already matches ${RESOLVED_VERSION}"
if git diff --quiet -- pyproject.toml server.json; then
echo "package versions already match ${RESOLVED_VERSION}"
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "pyproject.toml will be bumped to ${RESOLVED_VERSION}"
echo "package versions will be bumped to ${RESOLVED_VERSION}"
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Open pyproject version bump PR
if: steps.pyproject-version.outputs.changed == 'true'
- name: Open package version bump PR
if: steps.package-version.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v8.1.1
with:
branch: chore/bump-pyproject-version
delete-branch: true
commit-message: "chore: bump pyproject version to ${{ steps.release-drafter.outputs.resolved_version }}"
title: "Bump pyproject version to ${{ steps.release-drafter.outputs.resolved_version }}"
commit-message: "chore: bump package version to ${{ steps.release-drafter.outputs.resolved_version }}"
title: "Bump package version to ${{ steps.release-drafter.outputs.resolved_version }}"
body: |
Release Drafter resolved the next release as `${{ steps.release-drafter.outputs.resolved_version }}`.

This PR updates `pyproject.toml` before the draft release is published so the PyPI publish workflow can build a package whose version matches the release tag.
This PR updates `pyproject.toml` and `server.json` before the draft release is published so the PyPI and MCP Registry publish workflows can ship a package whose version matches the release tag.
labels: release
15 changes: 15 additions & 0 deletions .github/workflows/test-script.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ jobs:
/tmp/structkit-smoke/bin/pip install dist/*.whl
/tmp/structkit-smoke/bin/structkit --help
/tmp/structkit-smoke/bin/structkit generate --help
python - <<'PY'
from pathlib import Path
import zipfile

wheels = list(Path("dist").glob("*.whl"))
if len(wheels) != 1:
raise SystemExit(f"expected one wheel, found {wheels!r}")
with zipfile.ZipFile(wheels[0]) as wheel:
metadata_name = next(name for name in wheel.namelist() if name.endswith(".dist-info/METADATA"))
metadata = wheel.read(metadata_name).decode("utf-8")
marker = "mcp-name: app.structkit/mcp"
if marker not in metadata:
raise SystemExit("wheel METADATA is missing the MCP Registry ownership marker")
print(f"MCP ownership marker present in {metadata_name}")
PY

build:

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ example_project/
build/*
dist/

# MCP Registry domain-auth private key (never commit)
key.pem

# MkDocs generated documentation
site/docs/

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# StructKit

<!-- mcp-name: app.structkit/mcp -->

YAML scaffolding your AI assistant can actually run.

Define a repo once (files, CI, Terraform, app layout). Generate it from the CLI, from CI, or through an assistant over MCP. When the org template on GitHub changes, the next generate picks it up. No golden repo. No separate Cookiecutter tree.
Expand Down
55 changes: 55 additions & 0 deletions docs/mcp-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,61 @@ tags:

The structkit tool now supports MCP (Model Context Protocol) integration, providing a programmable interface to interact with structure definitions. This enables automation and integration with other tools, particularly AI-assisted development workflows.

## Official MCP Registry

The official MCP Registry name for StructKit is `app.structkit/mcp` (reverse-DNS of [structkit.app](https://structkit.app/)). The listing is defined in `server.json` at the repository root. Registry clients should launch the stdio server with:

```bash
uvx structkit mcp --server
```

Keep `server.json` `version` (and `packages[0].version`) in sync with the package version in `pyproject.toml`. The Release Drafter version-bump PR updates both files before a GitHub Release.

Domain namespaces authenticate with DNS or HTTP proof of `structkit.app`. GitHub OIDC (`mcp-publisher login github` / `github-oidc`) only covers `io.github.*` names and will not publish `app.structkit/mcp`.

### Manual publish (maintainer)

Do not publish from a pull request. Do not commit the Ed25519 private key (`key.pem` is gitignored). Ownership verification only succeeds after a PyPI release whose long description includes the hidden README marker `<!-- mcp-name: app.structkit/mcp -->`.

1. Install [`mcp-publisher`](https://github.com/modelcontextprotocol/registry/blob/main/docs/reference/cli/commands.md).
2. Generate an Ed25519 keypair and the DNS TXT proof (from [registry authentication](https://modelcontextprotocol.io/registry/authentication)):

```bash
MY_DOMAIN="structkit.app"
openssl genpkey -algorithm Ed25519 -out key.pem
PUBLIC_KEY="$(openssl pkey -in key.pem -pubout -outform DER | tail -c 32 | base64)"
echo "${MY_DOMAIN}. IN TXT \"v=MCPv1; k=ed25519; p=${PUBLIC_KEY}\""
```

3. Add that TXT record on **structkit.app** at the DNS host where the domain is registered (the website is hosted on Lovable; Lovable is not the DNS registrar). Host and value:

```text
Host/name: structkit.app (or `@`)
Type: TXT
Value: v=MCPv1; k=ed25519; p=<PUBLIC_KEY>
```

Wait until the record is visible, for example `dig TXT structkit.app +short`.

HTTP alternative (same keypair): write `v=MCPv1; k=ed25519; p=${PUBLIC_KEY}` to a file and serve it at `https://structkit.app/.well-known/mcp-registry-auth`, then login with `mcp-publisher login http --domain structkit.app --private-key ...` instead of `login dns`.

4. Extract the private key **hex** (this is what `mcp-publisher` and the GitHub secret expect, not the PEM file) and store it as the repository secret `MCP_PRIVATE_KEY`. Do not commit it.

```bash
PRIVATE_KEY="$(openssl pkey -in key.pem -noout -text | grep -A3 "priv:" | tail -n +2 | tr -d ' :\n')"
# Store "${PRIVATE_KEY}" as GitHub Actions secret MCP_PRIVATE_KEY
```

5. Cut a GitHub Release so `structkit` is uploaded to PyPI with the README marker. Confirm the marker in that version's PyPI JSON `info.description`.
6. From the repository root:

```bash
mcp-publisher login dns --domain structkit.app --private-key "${PRIVATE_KEY}"
mcp-publisher publish
```

Published GitHub Releases also run `.github/workflows/publish-mcp-registry.yml`. That workflow authenticates with `mcp-publisher login dns --domain structkit.app --private-key …` using `secrets.MCP_PRIVATE_KEY`. If the secret is unset, login and publish are skipped and the release still succeeds. It is gated to `release: published` and does not run on pull requests.

## Available MCP Tools

### 1. list_structures
Expand Down
35 changes: 35 additions & 0 deletions server.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
"name": "app.structkit/mcp",
"title": "StructKit",
"description": "YAML scaffolding your AI assistant can actually run.",
"version": "3.3.1",
"websiteUrl": "https://structkit.app/",
"repository": {
"url": "https://github.com/httpdss/structkit",
"source": "github",
"id": "827469347"
},
"packages": [
{
"registryType": "pypi",
"registryBaseUrl": "https://pypi.org",
"identifier": "structkit",
"version": "3.3.1",
"runtimeHint": "uvx",
"packageArguments": [
{
"type": "positional",
"value": "mcp"
},
{
"type": "positional",
"value": "--server"
}
],
"transport": {
"type": "stdio"
}
}
]
}
Loading
Loading