Skip to content

Add hatchling build hook to build UI during package installation#565

Open
b-per wants to merge 1 commit intomainfrom
fix/ui-build-hook-560
Open

Add hatchling build hook to build UI during package installation#565
b-per wants to merge 1 commit intomainfrom
fix/ui-build-hook-560

Conversation

@b-per
Copy link
Collaborator

@b-per b-per commented Jan 28, 2026

Summary

Fixes #560

This PR adds a hatchling build hook that automatically builds the UI assets during package installation, enabling users to install dbt-mcp directly from GitHub:

uvx git+https://github.com/dbt-labs/dbt-mcp@main

Changes

  • Add hatch_build.py with UIBuildHook that runs pnpm install and pnpm build
  • Configure the hook in pyproject.toml for both wheel and sdist targets
  • Include ui/ source files in sdist (excluding node_modules)
  • Remove manual UI build from Taskfile build task (hook handles it now)
  • Fix pnpm-workspace.yaml to include packages field required by pnpm v10

Notes

  • Users installing from GitHub will need pnpm installed (as discussed in the issue, this is an acceptable tradeoff)
  • GitHub Actions already has pnpm setup via pnpm/action-setup
  • The hook provides clear error messages if pnpm is not available

Test plan

  • Verified uv build works and triggers the hook
  • Verified sdist includes UI source files but excludes node_modules

@b-per b-per requested review from a team, jairus-m and jasnonaz as code owners January 28, 2026 09:44
@b-per b-per force-pushed the fix/ui-build-hook-560 branch from 0bc3175 to a8bda04 Compare January 28, 2026 09:46
@b-per b-per requested a review from a team as a code owner January 28, 2026 09:46
This allows installing dbt-mcp directly from GitHub via
`uvx git+https://github.com/dbt-labs/dbt-mcp@main` by automatically
building the UI assets during package build.

Changes:
- Add hatch_build.py with UIBuildHook that runs pnpm install/build
- Configure the hook in pyproject.toml for both wheel and sdist targets
- Include ui/ source files in sdist (excluding node_modules)
- Remove manual UI build from Taskfile build task (hook handles it)
- Fix pnpm-workspace.yaml to include packages field for pnpm v10

Closes #560
@b-per b-per force-pushed the fix/ui-build-hook-560 branch from a8bda04 to b0f4b16 Compare January 28, 2026 09:54
return

root = Path(self.root)
ui_dir = root / "ui"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to keep this path the same as before, src/dbt_mcp/ui? The app expects that specific path, here.

Comment on lines +77 to +81
[tool.hatch.build.targets.wheel.hooks.custom]
path = "hatch_build.py"

[tool.hatch.build.targets.sdist.hooks.custom]
path = "hatch_build.py"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never worked w/ build hooks before so was generally curious about the behavior as well as the diff between sdist and wheel distributions.

I ran uv build -v locally and saw that the "pnpm install + pnpm build" step ran twice. Is this intended?

From my new understanding, the wheel dist is the built package that gets directly installed and used. The source dist is one step before that (has raw src files and no build assets) and is the basis for then building a wheel. So given this, is the hook on sdist necessary? Or would it make sense to just keep it on the wheel target?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Can't call uvx --env-file .env git+https://github.com/dbt-labs/dbt-mcp@main with OAuth due to ui files built at release time

3 participants