Skip to content
Merged
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
14 changes: 14 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ __pycache__/
*.egg-info/
.venv/

# Ruff
.ruff_cache/
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
repos:
- 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: check-json
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ 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 formatting

## Install dependencies

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.
Expand Down
1 change: 0 additions & 1 deletion dev-all.mts
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,3 @@ main().catch((e) => {
console.error(e);
process.exit(1);
});

14 changes: 9 additions & 5 deletions pizzaz_server_python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
}


Expand Down Expand Up @@ -277,7 +281,7 @@ async def _call_tool_request(req: types.CallToolRequest) -> types.ServerResult:
)
],
structuredContent={"pizzaTopping": topping},
_meta=meta
_meta=meta,
)
)

Expand Down
2 changes: 1 addition & 1 deletion pizzaz_server_python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mcp[fastapi]>=0.1.0
fastapi>=0.115.0
mcp[fastapi]>=0.1.0
uvicorn>=0.30.0
19 changes: 8 additions & 11 deletions solar-system_server_python/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}


Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion solar-system_server_python/requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions src/pizzaz-albums/albums.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,3 @@
}
]
}


6 changes: 0 additions & 6 deletions tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": false,
Expand All @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down