Skip to content

Commit 44afd45

Browse files
committed
Indent Python script in GitHub Actions for better readability
- Reformatted inlined Python script for error handling and schema validation - Improved identation for consistent alignment and maintainability - No behavioral changes, purely a formatting update for clarity.
1 parent 367e123 commit 44afd45

File tree

1 file changed

+63
-55
lines changed

1 file changed

+63
-55
lines changed

.github/workflows/main.yml

Lines changed: 63 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -137,61 +137,69 @@ jobs:
137137
if: steps.version-check.outputs.version_changed == 'true' && github.ref == 'refs/heads/main'
138138
run: |
139139
python - <<'PY'
140-
import json
141-
import sys
142-
import urllib.request
143-
from jsonschema import ValidationError, validate
144-
145-
schema_url = "https://static.modelcontextprotocol.io/schemas/2025-09-16/server.schema.json"
146-
147-
try:
148-
with urllib.request.urlopen(schema_url, timeout=30) as response:
149-
schema = json.load(response)
150-
except Exception as exc:
151-
print(f"✗ Unable to download server.json schema: {exc}")
152-
sys.exit(1)
153-
154-
try:
155-
with open('server.json', 'r') as f:
156-
data = json.load(f)
157-
except Exception as exc:
158-
print(f"✗ Failed to load server.json: {exc}")
159-
sys.exit(1)
160-
161-
try:
162-
validate(instance=data, schema=schema)
163-
print('✓ server.json schema validation passed')
164-
except ValidationError as exc:
165-
print(f"✗ server.json schema validation failed: {exc.message}")
166-
sys.exit(1)
167-
168-
has_packages = 'packages' in data and len(data['packages']) > 0
169-
has_remotes = 'remotes' in data and len(data['remotes']) > 0
170-
171-
if not (has_packages or has_remotes):
172-
print('✗ Must have either packages or remotes configured')
173-
sys.exit(1)
174-
175-
if has_packages:
176-
for idx, pkg in enumerate(data['packages']):
177-
registry_type = pkg.get('registryType')
178-
identifier = pkg.get('identifier')
179-
if registry_type not in ['npm', 'pypi', 'nuget', 'oci', 'mcpb']:
180-
print(f"✗ Package {idx}: Invalid registry type '{registry_type}'")
181-
sys.exit(1)
182-
print(f"✓ Package {idx}: {registry_type.upper()} -> {identifier}")
183-
184-
if has_remotes:
185-
for idx, remote in enumerate(data['remotes']):
186-
remote_type = remote.get('type')
187-
url = remote.get('url')
188-
if remote_type not in ['sse', 'streamable-http']:
189-
print(f"✗ Remote {idx}: Invalid transport type '{remote_type}'")
190-
sys.exit(1)
191-
print(f"✓ Remote {idx}: {remote_type} -> {url}")
192-
193-
print('✓ server.json validation passed (hybrid deployment)')
194-
PY
140+
from textwrap import dedent
141+
142+
exec(
143+
dedent(
144+
"""
145+
import json
146+
import sys
147+
import urllib.request
148+
from jsonschema import ValidationError, validate
149+
150+
schema_url = "https://static.modelcontextprotocol.io/schemas/2025-09-16/server.schema.json"
151+
152+
try:
153+
with urllib.request.urlopen(schema_url, timeout=30) as response:
154+
schema = json.load(response)
155+
except Exception as exc:
156+
print(f"✗ Unable to download server.json schema: {exc}")
157+
sys.exit(1)
158+
159+
try:
160+
with open('server.json', 'r') as f:
161+
data = json.load(f)
162+
except Exception as exc:
163+
print(f"✗ Failed to load server.json: {exc}")
164+
sys.exit(1)
165+
166+
try:
167+
validate(instance=data, schema=schema)
168+
print('✓ server.json schema validation passed')
169+
except ValidationError as exc:
170+
print(f"✗ server.json schema validation failed: {exc.message}")
171+
sys.exit(1)
172+
173+
has_packages = 'packages' in data and len(data['packages']) > 0
174+
has_remotes = 'remotes' in data and len(data['remotes']) > 0
175+
176+
if not (has_packages or has_remotes):
177+
print('✗ Must have either packages or remotes configured')
178+
sys.exit(1)
179+
180+
if has_packages:
181+
for idx, pkg in enumerate(data['packages']):
182+
registry_type = pkg.get('registryType')
183+
identifier = pkg.get('identifier')
184+
if registry_type not in ['npm', 'pypi', 'nuget', 'oci', 'mcpb']:
185+
print(f"✗ Package {idx}: Invalid registry type '{registry_type}'")
186+
sys.exit(1)
187+
print(f"✓ Package {idx}: {registry_type.upper()} -> {identifier}")
188+
189+
if has_remotes:
190+
for idx, remote in enumerate(data['remotes']):
191+
remote_type = remote.get('type')
192+
url = remote.get('url')
193+
if remote_type not in ['sse', 'streamable-http']:
194+
print(f"✗ Remote {idx}: Invalid transport type '{remote_type}'")
195+
sys.exit(1)
196+
print(f"✓ Remote {idx}: {remote_type} -> {url}")
197+
198+
print('✓ server.json validation passed (hybrid deployment)')
199+
"""
200+
)
201+
)
202+
PY
195203
196204
- name: Install MCP Publisher CLI
197205
if: steps.version-check.outputs.version_changed == 'true' && github.ref == 'refs/heads/main'

0 commit comments

Comments
 (0)