From 6e6667c8c97007421cc2f237daf9c83e99956977 Mon Sep 17 00:00:00 2001 From: Kevin Hong Date: Fri, 24 Oct 2025 09:11:25 -0400 Subject: [PATCH 1/4] hook --- .github/workflows/pre-commit.yml | 14 ++++++++++++++ .gitignore | 2 ++ .pre-commit-config.yaml | 17 +++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..2b11178 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,14 @@ +name: pre-commit + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + - uses: pre-commit/action@v3.0.1 diff --git a/.gitignore b/.gitignore index bdd17b6..d1188c0 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,5 @@ __pycache__/ *.egg-info/ .venv/ +# Ruff +.ruff_cache/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9abf213 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +repos: +- repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.14.2 + hooks: + # Run the linter. + - id: ruff-check + # Run the formatter. + - id: ruff-format +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v6.0.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: requirements-txt-fixer + - id: trailing-whitespace From 3bbbd72e8f0477685f56ce8efb4f978c6c2b187e Mon Sep 17 00:00:00 2001 From: Kevin Hong Date: Fri, 24 Oct 2025 09:13:12 -0400 Subject: [PATCH 2/4] add hooks --- README.md | 2 ++ dev-all.mts | 1 - pizzaz_server_python/main.py | 14 +++++++++----- pizzaz_server_python/requirements.txt | 2 +- solar-system_server_python/main.py | 19 ++++++++----------- solar-system_server_python/requirements.txt | 2 +- src/pizzaz-albums/albums.json | 2 -- tsconfig.app.json | 6 ------ tsconfig.node.json | 4 ---- 9 files changed, 21 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 8a68ee9..29fbdb9 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ The MCP servers in this demo highlight how each tool can light up widgets by com - Node.js 18+ - pnpm (recommended) or npm/yarn - Python 3.10+ (for the Python MCP server) +- pre-commit for formmating ## Install dependencies @@ -40,6 +41,7 @@ Clone the repository and install the workspace dependencies: ```bash pnpm install +pre-commit install ``` > Using npm or yarn? Install the root dependencies with your preferred client and adjust the commands below accordingly. diff --git a/dev-all.mts b/dev-all.mts index ef7fff8..c8a7ff2 100644 --- a/dev-all.mts +++ b/dev-all.mts @@ -115,4 +115,3 @@ main().catch((e) => { console.error(e); process.exit(1); }); - diff --git a/pizzaz_server_python/main.py b/pizzaz_server_python/main.py index cda0812..477ea0a 100644 --- a/pizzaz_server_python/main.py +++ b/pizzaz_server_python/main.py @@ -86,15 +86,19 @@ def _load_widget_html(component_name: str) -> str: invoked="Served a fresh list", html=_load_widget_html("pizzaz-list"), response_text="Rendered a pizza list!", - ) + ), ] MIME_TYPE = "text/html+skybridge" -WIDGETS_BY_ID: Dict[str, PizzazWidget] = {widget.identifier: widget for widget in widgets} -WIDGETS_BY_URI: Dict[str, PizzazWidget] = {widget.template_uri: widget for widget in widgets} +WIDGETS_BY_ID: Dict[str, PizzazWidget] = { + widget.identifier: widget for widget in widgets +} +WIDGETS_BY_URI: Dict[str, PizzazWidget] = { + widget.template_uri: widget for widget in widgets +} class PizzaInput(BaseModel): @@ -138,7 +142,7 @@ def _tool_meta(widget: PizzazWidget) -> Dict[str, Any]: "openai/toolInvocation/invoking": widget.invoking, "openai/toolInvocation/invoked": widget.invoked, "openai/widgetAccessible": True, - "openai/resultCanProduceWidget": True + "openai/resultCanProduceWidget": True, } @@ -277,7 +281,7 @@ async def _call_tool_request(req: types.CallToolRequest) -> types.ServerResult: ) ], structuredContent={"pizzaTopping": topping}, - _meta=meta + _meta=meta, ) ) diff --git a/pizzaz_server_python/requirements.txt b/pizzaz_server_python/requirements.txt index 6eb7e58..5deee2d 100644 --- a/pizzaz_server_python/requirements.txt +++ b/pizzaz_server_python/requirements.txt @@ -1,3 +1,3 @@ -mcp[fastapi]>=0.1.0 fastapi>=0.115.0 +mcp[fastapi]>=0.1.0 uvicorn>=0.30.0 diff --git a/solar-system_server_python/main.py b/solar-system_server_python/main.py index d7b3cad..37c2a11 100644 --- a/solar-system_server_python/main.py +++ b/solar-system_server_python/main.py @@ -125,10 +125,10 @@ def _tool_meta(widget: SolarWidget) -> Dict[str, Any]: "openai/widgetAccessible": True, "openai/resultCanProduceWidget": True, "annotations": { - "destructiveHint": False, - "openWorldHint": False, - "readOnlyHint": True, - } + "destructiveHint": False, + "openWorldHint": False, + "readOnlyHint": True, + }, } @@ -152,10 +152,10 @@ def _normalize_planet(name: str) -> str | None: if not key: return DEFAULT_PLANET - clean = ''.join(ch for ch in key if ch.isalnum()) + clean = "".join(ch for ch in key if ch.isalnum()) for planet in PLANETS: - planet_key = ''.join(ch for ch in planet.lower() if ch.isalnum()) + planet_key = "".join(ch for ch in planet.lower() if ch.isalnum()) if clean == planet_key or key == planet.lower(): return planet @@ -164,7 +164,7 @@ def _normalize_planet(name: str) -> str | None: return alias for planet in PLANETS: - planet_key = ''.join(ch for ch in planet.lower() if ch.isalnum()) + planet_key = "".join(ch for ch in planet.lower() if ch.isalnum()) if planet_key.startswith(clean): return planet @@ -259,10 +259,7 @@ async def _call_tool_request(req: types.CallToolRequest) -> types.ServerResult: content=[ types.TextContent( type="text", - text=( - "Unknown planet. Provide one of: " - + ", ".join(PLANETS) - ), + text=("Unknown planet. Provide one of: " + ", ".join(PLANETS)), ) ], isError=True, diff --git a/solar-system_server_python/requirements.txt b/solar-system_server_python/requirements.txt index 1f3183e..9741e5f 100644 --- a/solar-system_server_python/requirements.txt +++ b/solar-system_server_python/requirements.txt @@ -1,4 +1,4 @@ +fastapi>=0.115.0 # Dependencies for the solar-system MCP demo server mcp[fastapi]>=0.1.0 -fastapi>=0.115.0 uvicorn>=0.30.0 diff --git a/src/pizzaz-albums/albums.json b/src/pizzaz-albums/albums.json index a8119f8..9c934ca 100644 --- a/src/pizzaz-albums/albums.json +++ b/src/pizzaz-albums/albums.json @@ -110,5 +110,3 @@ } ] } - - diff --git a/tsconfig.app.json b/tsconfig.app.json index 9c9df02..383081a 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -6,8 +6,6 @@ "lib": ["ES2022", "DOM", "DOM.Iterable"], "module": "ESNext", "skipLibCheck": true, - - /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, "verbatimModuleSyntax": false, @@ -16,12 +14,8 @@ "jsx": "react-jsx", "jsxImportSource": "react", "types": ["vite/client", "@react-three/fiber"], - - // Helpful for TS resolving and editor tooling "baseUrl": ".", "paths": {}, - - /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, diff --git a/tsconfig.node.json b/tsconfig.node.json index 879d72c..531ead2 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -5,15 +5,11 @@ "lib": ["ES2023"], "module": "ESNext", "skipLibCheck": true, - - /* Bundler mode */ "moduleResolution": "bundler", "allowImportingTsExtensions": true, "verbatimModuleSyntax": true, "moduleDetection": "force", "noEmit": true, - - /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, From f6f86e81d4b9afd21d2bdbe0e4d2309711eda17e Mon Sep 17 00:00:00 2001 From: Kevin Hong Date: Fri, 24 Oct 2025 09:13:20 -0400 Subject: [PATCH 3/4] hook --- .pre-commit-config.yaml | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9abf213..6ed72bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,17 +1,14 @@ repos: -- repo: https://github.com/astral-sh/ruff-pre-commit - # Ruff version. - rev: v0.14.2 - hooks: - # Run the linter. - - id: ruff-check - # Run the formatter. - - id: ruff-format -repos: -- repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.14.2 + hooks: + - id: ruff-check + - id: ruff-format + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: requirements-txt-fixer - - id: trailing-whitespace + - id: check-yaml + - id: check-json + - id: end-of-file-fixer + - id: requirements-txt-fixer + - id: trailing-whitespace From 5c8fc751f984477495f617e6c4b314fb68f07f96 Mon Sep 17 00:00:00 2001 From: Kevin Hong Date: Fri, 24 Oct 2025 14:03:10 -0400 Subject: [PATCH 4/4] format --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 29fbdb9..cf1fb98 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ The MCP servers in this demo highlight how each tool can light up widgets by com - Node.js 18+ - pnpm (recommended) or npm/yarn - Python 3.10+ (for the Python MCP server) -- pre-commit for formmating +- pre-commit for formatting ## Install dependencies