This is an automated email from the ASF dual-hosted git repository.
yzheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris-tools.git
The following commit(s) were added to refs/heads/main by this push:
new d102fba Add Makefile for MCP project (#184)
d102fba is described below
commit d102fbac125e4860b96cab71ac4b340d287baf1f
Author: Yong Zheng <[email protected]>
AuthorDate: Tue Mar 10 13:53:07 2026 -0500
Add Makefile for MCP project (#184)
---
.github/workflows/mcp-server.yml | 2 +-
Makefile | 22 ++++++++++
mcp-server/Makefile | 93 ++++++++++++++++++++++++++++++++++++++++
mcp-server/README.md | 2 +-
mcp-server/pyproject.toml | 12 ++++--
mcp-server/tests/test_config.py | 3 ++
mcp-server/uv.lock | 13 +++---
7 files changed, 135 insertions(+), 12 deletions(-)
diff --git a/.github/workflows/mcp-server.yml b/.github/workflows/mcp-server.yml
index 72af36a..fdf80b9 100644
--- a/.github/workflows/mcp-server.yml
+++ b/.github/workflows/mcp-server.yml
@@ -83,7 +83,7 @@ jobs:
- name: Sync dependencies
working-directory: mcp-server
run: |
- uv sync --extra test --extra dev
+ uv sync --all-extras
- name: Lint
working-directory: mcp-server
diff --git a/Makefile b/Makefile
index e8511c0..8cebe94 100644
--- a/Makefile
+++ b/Makefile
@@ -100,3 +100,25 @@ console-lint-fix: ## Fix linting issues in the console
project
.PHONY: console-version
console-version: ## Display version for console project
@$(MAKE) -C console version
+
+##@ MCP
+
+.PHONY: mcp-build
+mcp-build: ## Build the distribution files (sdist and wheel) for MCP project
+ @$(MAKE) -C mcp-server build
+
+.PHONY: mcp-cleanup
+mcp-cleanup: ## Cleanup virtual environment and build artifacts for MCP project
+ @$(MAKE) -C mcp-server cleanup
+
+.PHONY: mcp-lint
+mcp-lint: ## Lint the MCP project
+ @$(MAKE) -C mcp-server lint
+
+.PHONY: mcp-run
+mcp-run: ## Start MCP server (stdin/stdout transport)
+ @$(MAKE) -C mcp-server run
+
+.PHONY: mcp-test
+mcp-test: ## Run unit tests for MCP project
+ @$(MAKE) -C mcp-server test
diff --git a/mcp-server/Makefile b/mcp-server/Makefile
new file mode 100644
index 0000000..1707e49
--- /dev/null
+++ b/mcp-server/Makefile
@@ -0,0 +1,93 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Configures the shell for recipes to use bash, enabling bash commands and
ensuring
+# that recipes exit on any command failure (including within pipes).
+SHELL = /usr/bin/env bash -o pipefail
+.SHELLFLAGS = -ec
+
+## Variables
+PYTHON ?= python3
+VENV_DIR := .venv
+ACTIVATE = source $(VENV_DIR)/bin/activate
+
+## Version information
+GIT_COMMIT := $(shell git rev-parse HEAD)
+UV_VERSION := $(shell cat pyproject.toml | grep -A1 tool.uv | grep -v tool.uv
| grep required-version | sed 's/required-version *= *"\([^"]*\)".*/\1/')
+
+##@ General
+
+.PHONY: help
+help: ## Display this help
+ @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make
\033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9\.-]+:.*?##/ { printf "
\033[36m%-40s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n",
substr($$0, 5) } ' $(MAKEFILE_LIST)
+
+.PHONY: version
+version: ## Display version information
+ @echo "Git commit: ${GIT_COMMIT}"
+ @echo "UV version: ${UV_VERSION}"
+
+##@ MCP Server
+
+# Target to create the virtual environment directory
+$(VENV_DIR):
+ @echo "Setting up Python virtual environment at $(VENV_DIR)..."
+ @$(PYTHON) -m venv $(VENV_DIR)
+ @echo "Virtual environment created."
+
+.PHONY: install-dependencies
+install-dependencies: $(VENV_DIR)
+ @echo "Installing UV and project dependencies into $(VENV_DIR) for MCP
project..."
+ @$(VENV_DIR)/bin/pip install --upgrade pip
+ @if [ ! -f "$(VENV_DIR)/bin/uv" ]; then \
+ $(VENV_DIR)/bin/pip install --upgrade "uv$(UV_VERSION)"; \
+ fi
+ @$(ACTIVATE) && uv lock && uv sync --active --all-extras
+ @echo "uv and dependencies installed for MCP project."
+
+.PHONY: setup-env
+setup-env: $(VENV_DIR) install-dependencies
+
+.PHONY: build
+build: setup-env ## Build the distribution files (sdist and wheel) for MCP
project
+ @echo "--- Building distribution for MCP project ---"
+ @$(ACTIVATE) && uv build
+ @echo "--- Distribution build complete for MCP project ---"
+
+.PHONY: cleanup
+cleanup: ## Cleanup virtual environment and build artifacts for MCP project
+ @echo "--- Cleaning up virtual environment and build artifacts for MCP
project ---"
+ @rm -rf "$(VENV_DIR)" build/ dist/ .pytest_cache/
apache_polaris_mcp.egg-info/
+ @find . -type d -name "__pycache__" -exec rm -rf {} +
+ @echo "--- Cleanup complete for MCP project ---"
+
+.PHONY: lint
+lint: setup-env ## Lint the MCP project
+ @echo "--- Running linting checks for MCP project ---"
+ @$(ACTIVATE) && uv run pre-commit run --all-files
+ @echo "--- Linting checks complete for MCP project ---"
+
+.PHONY: run
+run: setup-env ## Start MCP server (stdin/stdout transport)
+ @echo "--- Starting MCP server ---"
+ @$(ACTIVATE) && uv run polaris-mcp
+ @echo "--- MCP server finished ---"
+
+.PHONY: test
+test: setup-env ## Run unit tests for MCP project
+ @echo "--- Running unit tests for MCP project ---"
+ @$(ACTIVATE) && uv run pytest tests/
+ @echo "--- Unit tests complete for MCP project---"
diff --git a/mcp-server/README.md b/mcp-server/README.md
index 9b90ccf..a320af4 100644
--- a/mcp-server/README.md
+++ b/mcp-server/README.md
@@ -31,7 +31,7 @@ The implementation is built on top of
[FastMCP](https://gofastmcp.com) for strea
Run the following commands from the `mcp-server` directory:
- `uv sync` - install runtime dependencies
- `uv run polaris-mcp` - start the MCP server (stdin/stdout transport)
-- `uv sync --extra test --extra dev` - install runtime, test and dev
dependencies
+- `uv sync --all-extras` - install runtime and dev dependencies
- `uv run pytest` - run the test suite
- `uv run pre-commit run --all-files` - lint all files
- `uv build && uv publish --index testpypi --token [Pypi-API-token]` - Publish
a nightly to test.pypi.org
diff --git a/mcp-server/pyproject.toml b/mcp-server/pyproject.toml
index 449b60d..1bf19d9 100644
--- a/mcp-server/pyproject.toml
+++ b/mcp-server/pyproject.toml
@@ -35,11 +35,9 @@ dependencies = [
"python-dotenv>=1.2.1",
]
-[project.optional-dependencies]
-test = [
- "pytest>=8.2",
-]
+[dependency-groups]
dev = [
+ "pytest>=8.2",
"pre-commit>=3.7",
]
@@ -54,6 +52,12 @@ repository = "https://github.com/apache/polaris-tools/"
requires = ["hatchling"]
build-backend = "hatchling.build"
+[tool.uv]
+required-version = ">=0.9.0" # keep this as the first item for version parsing
+default-groups = [
+ "dev"
+]
+
[tool.hatch.build.targets.sdist]
include = ["polaris_mcp"]
diff --git a/mcp-server/tests/test_config.py b/mcp-server/tests/test_config.py
index acf24df..bbaf2a2 100644
--- a/mcp-server/tests/test_config.py
+++ b/mcp-server/tests/test_config.py
@@ -28,6 +28,7 @@ from pathlib import Path
def test_main_loads_default_config_file() -> None:
with (
+ mock.patch("sys.argv", [""]),
mock.patch("polaris_mcp.server.find_dotenv") as mock_find_dotenv,
mock.patch("polaris_mcp.server.load_dotenv") as mock_load_dotenv,
mock.patch("polaris_mcp.server.create_server") as mock_create_server,
@@ -48,6 +49,7 @@ def test_main_loads_default_config_file() -> None:
def test_main_loads_custom_config_file() -> None:
with (
+ mock.patch("sys.argv", [""]),
mock.patch("polaris_mcp.server.find_dotenv") as mock_find_dotenv,
mock.patch("polaris_mcp.server.load_dotenv") as mock_load_dotenv,
mock.patch("polaris_mcp.server.create_server") as mock_create_server,
@@ -75,6 +77,7 @@ def test_config_loading_precedence(tmp_path: Path) -> None:
)
with (
+ mock.patch("sys.argv", [""]),
mock.patch("polaris_mcp.server.create_server"),
mock.patch.dict(
os.environ,
diff --git a/mcp-server/uv.lock b/mcp-server/uv.lock
index b10dcde..790c42d 100644
--- a/mcp-server/uv.lock
+++ b/mcp-server/uv.lock
@@ -45,24 +45,25 @@ dependencies = [
{ name = "urllib3" },
]
-[package.optional-dependencies]
+[package.dev-dependencies]
dev = [
{ name = "pre-commit" },
-]
-test = [
{ name = "pytest" },
]
[package.metadata]
requires-dist = [
{ name = "fastmcp", specifier = ">=2.13.0" },
- { name = "pre-commit", marker = "extra == 'dev'", specifier = ">=3.7" },
- { name = "pytest", marker = "extra == 'test'", specifier = ">=8.2" },
{ name = "python-dotenv", specifier = ">=1.2.1" },
{ name = "python-json-logger", specifier = ">=4.0.0" },
{ name = "urllib3", specifier = ">=1.25.3,<3.0.0" },
]
-provides-extras = ["test", "dev"]
+
+[package.metadata.requires-dev]
+dev = [
+ { name = "pre-commit", specifier = ">=3.7" },
+ { name = "pytest", specifier = ">=8.2" },
+]
[[package]]
name = "async-timeout"