-
Notifications
You must be signed in to change notification settings - Fork 189
Configure: add --enable-mcp-server option #1446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tuhaihe
wants to merge
1
commit into
apache:main
Choose a base branch
from
tuhaihe:mcp-make
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+311
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -942,6 +942,30 @@ PGAC_ARG_BOOL(enable, preload-ic-module, yes, | |
| AC_MSG_RESULT([checking whether to build with preload ic module ... $enable_preload_ic_module]) | ||
| AC_SUBST(enable_preload_ic_module) | ||
|
|
||
| # | ||
| # mcp-server | ||
| # | ||
| PGAC_ARG_BOOL(enable, mcp-server, no, | ||
| [enable MCP server support], | ||
| [AC_DEFINE(ENABLE_MCP_SERVER, 1, | ||
| [Define to 1 to build with MCP server support (--enable-mcp-server)])]) | ||
| AC_MSG_RESULT([checking whether to build with MCP server... $enable_mcp_server]) | ||
| AC_SUBST(enable_mcp_server) | ||
|
|
||
| # Check for required dependencies when mcp-server is enabled | ||
| if test "$enable_mcp_server" = yes; then | ||
| AC_PATH_PROG([PYTHON3], [python3]) | ||
| if test -z "$PYTHON3"; then | ||
| AC_MSG_ERROR([python3 is required for --enable-mcp-server but was not found]) | ||
| fi | ||
|
Comment on lines
+957
to
+960
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we check the python version that is required by mcp-server? |
||
|
|
||
| # Check for uv (Python package manager) | ||
| AC_PATH_PROG([UV], [uv]) | ||
| if test -z "$UV"; then | ||
| AC_MSG_WARN([uv not found. MCP server build will attempt to use pip as fallback.]) | ||
| fi | ||
| fi | ||
|
|
||
| # | ||
| # pax support | ||
| # | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| # 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. | ||
| # | ||
| # Makefile for Apache Cloudberry MCP Server | ||
| # | ||
| # This Makefile integrates the Python-based MCP server into the | ||
| # Cloudberry build system. It uses uv (preferred) or pip for | ||
| # dependency management and installation. | ||
| # | ||
|
|
||
| # Get build configuration from top-level Makefile | ||
| subdir = mcp-server | ||
| top_builddir = .. | ||
| include $(top_builddir)/src/Makefile.global | ||
|
|
||
| # Installation directories | ||
| # Note: Use $(prefix) directly to avoid automatic /postgresql suffix added by $(datadir) | ||
| MCP_SERVER_BIN_DIR = $(prefix)/bin | ||
|
|
||
| # Python and package manager | ||
| # Note: fastmcp requires Python 3.10+ | ||
| PYTHON3 ?= python3.11 | ||
| UV ?= uv | ||
| PIP3 ?= pip3.11 | ||
|
|
||
| # Determine which package manager to use | ||
| USE_UV := $(shell command -v $(UV) 2> /dev/null) | ||
|
|
||
| # Build directory | ||
| BUILD_DIR = dist | ||
| VENV_DIR = .venv | ||
|
|
||
| .PHONY: all build install installdirs uninstall clean distclean | ||
|
|
||
| all: build | ||
|
|
||
| # Build the MCP server package | ||
| build: | ||
| @echo "Building Apache Cloudberry MCP Server..." | ||
| ifdef USE_UV | ||
| @echo "Using uv for build..." | ||
| $(UV) build | ||
| else | ||
| @echo "Using pip for build..." | ||
| $(PYTHON3) -m pip install --upgrade build | ||
| $(PYTHON3) -m build | ||
| endif | ||
| @echo "MCP Server build complete." | ||
|
|
||
| # Install the MCP server | ||
| install: build installdirs | ||
| @echo "Installing Apache Cloudberry MCP Server..." | ||
| ifdef USE_UV | ||
| @echo "Installing with uv..." | ||
| $(UV) pip install --system --prefix=$(DESTDIR)$(prefix) $(BUILD_DIR)/*.whl | ||
| else | ||
| @echo "Installing with pip..." | ||
| $(PIP3) install --target=$(DESTDIR)$(prefix)/lib/python$$($(PYTHON3) -c "import sys; print('%d.%d' % (sys.version_info.major, sys.version_info.minor))")/site-packages $(BUILD_DIR)/*.whl | ||
| endif | ||
| @# Create a wrapper script for easier invocation | ||
| @echo '#!/bin/sh' > '$(DESTDIR)$(MCP_SERVER_BIN_DIR)/cloudberry-mcp-server' | ||
| @echo '# Wrapper script for Apache Cloudberry MCP Server' >> '$(DESTDIR)$(MCP_SERVER_BIN_DIR)/cloudberry-mcp-server' | ||
| @echo '' >> '$(DESTDIR)$(MCP_SERVER_BIN_DIR)/cloudberry-mcp-server' | ||
| @echo '# Detect Python version and set PYTHONPATH' >> '$(DESTDIR)$(MCP_SERVER_BIN_DIR)/cloudberry-mcp-server' | ||
| @echo 'PYTHON_VERSION=$$($(PYTHON3) -c "import sys; print(\"python%d.%d\" % (sys.version_info.major, sys.version_info.minor))")' >> '$(DESTDIR)$(MCP_SERVER_BIN_DIR)/cloudberry-mcp-server' | ||
| @echo 'GPHOME="$$(cd "$$(dirname "$$0")/.." && pwd)"' >> '$(DESTDIR)$(MCP_SERVER_BIN_DIR)/cloudberry-mcp-server' | ||
| @echo 'export PYTHONPATH="$$GPHOME/lib/$$PYTHON_VERSION/site-packages:$$PYTHONPATH"' >> '$(DESTDIR)$(MCP_SERVER_BIN_DIR)/cloudberry-mcp-server' | ||
| @echo '' >> '$(DESTDIR)$(MCP_SERVER_BIN_DIR)/cloudberry-mcp-server' | ||
| @echo 'exec $(PYTHON3) -m cbmcp.server "$$@"' >> '$(DESTDIR)$(MCP_SERVER_BIN_DIR)/cloudberry-mcp-server' | ||
| @chmod +x '$(DESTDIR)$(MCP_SERVER_BIN_DIR)/cloudberry-mcp-server' | ||
| @echo "MCP Server installation complete." | ||
| @echo "Installed to: $(DESTDIR)$(prefix)" | ||
| @echo "You can run it with: cloudberry-mcp-server" | ||
|
|
||
| # Create installation directories | ||
| installdirs: | ||
| $(MKDIR_P) '$(DESTDIR)$(MCP_SERVER_BIN_DIR)' | ||
|
|
||
| # Uninstall the MCP server | ||
| uninstall: | ||
| @echo "Uninstalling Apache Cloudberry MCP Server..." | ||
| rm -f '$(DESTDIR)$(MCP_SERVER_BIN_DIR)/cloudberry-mcp-server' | ||
| ifdef USE_UV | ||
| -$(UV) pip uninstall --system cloudberry-mcp-server 2>/dev/null || true | ||
| else | ||
| -$(PIP3) uninstall -y cloudberry-mcp-server 2>/dev/null || true | ||
| endif | ||
| @echo "MCP Server uninstalled." | ||
|
|
||
| # Clean build artifacts | ||
| clean: | ||
| @echo "Cleaning MCP Server build artifacts..." | ||
| rm -rf $(BUILD_DIR) | ||
| rm -rf $(VENV_DIR) | ||
| rm -rf build | ||
| rm -rf *.egg-info | ||
| rm -rf src/*.egg-info | ||
| find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true | ||
| find . -type f -name '*.pyc' -delete 2>/dev/null || true | ||
| find . -type f -name '*.pyo' -delete 2>/dev/null || true | ||
| @echo "MCP Server cleaned." | ||
|
|
||
| # Distclean - remove all generated files | ||
| distclean: clean | ||
| @echo "Deep cleaning MCP Server..." | ||
| rm -rf .pytest_cache | ||
| rm -rf .coverage | ||
| rm -rf htmlcov | ||
| @echo "MCP Server distclean complete." | ||
|
|
||
| # Help target | ||
| help: | ||
| @echo "Apache Cloudberry MCP Server Makefile" | ||
| @echo "" | ||
| @echo "Available targets:" | ||
| @echo " all - Build the MCP server (default)" | ||
| @echo " build - Build the MCP server package" | ||
| @echo " install - Install the MCP server" | ||
| @echo " uninstall - Uninstall the MCP server" | ||
| @echo " clean - Remove build artifacts" | ||
| @echo " distclean - Remove all generated files" | ||
| @echo " help - Show this help message" | ||
| @echo "" | ||
| @echo "Configuration:" | ||
| @echo " PYTHON3 = $(PYTHON3)" | ||
| ifdef USE_UV | ||
| @echo " UV = $(UV) (using uv)" | ||
| else | ||
| @echo " PIP3 = $(PIP3) (using pip)" | ||
| endif | ||
| @echo " Install to = $(prefix)" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should set this feature in
src/Makefile.global.in?