From e1620336eda9d35ed35826f738cbac20627a9d3f Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan <12782505+nithishr@users.noreply.github.com> Date: Wed, 23 Apr 2025 18:33:49 +0200 Subject: [PATCH 1/6] Update project version to 0.2.0 and enhance pyproject.toml - Added authors and classifiers to pyproject.toml for better project metadata. --- pyproject.toml | 20 +++++++++++++++++++- src/{mcp_server.py => server.py} | 29 +++++++++++++++++------------ 2 files changed, 36 insertions(+), 13 deletions(-) rename src/{mcp_server.py => server.py} (94%) diff --git a/pyproject.toml b/pyproject.toml index ee2be60..605ef5d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,18 @@ [project] name = "mcp-couchbase" -version = "0.1.0" +version = "0.2.0" description = "Couchbase MCP Server - The Developer Data Platform for Critical Applications in Our AI World" readme = "README.md" requires-python = ">=3.10" license = "Apache-2.0" +authors = [ + { name="Nithish Raghunandanan", email="devadvocates@couchbase.com" }, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3", + "Database :: MCP Server", +] dependencies = [ "click>=8.1.8", @@ -18,3 +26,13 @@ dependencies = [ Homepage = "https://github.com/Couchbase-Ecosystem/mcp-server-couchbase" Documentation = "https://github.com/Couchbase-Ecosystem/mcp-server-couchbase#readme" Issues = "https://github.com/Couchbase-Ecosystem/mcp-server-couchbase/issues" + +[project.scripts] +mcp-couchbase-server = "server:main" + +[build-system] +requires = ["hatchling >= 1.26"] +build-backend = "hatchling.build" + +[tool.ruff.lint] +select = ["E", "F", "I", "T201"] diff --git a/src/mcp_server.py b/src/server.py similarity index 94% rename from src/mcp_server.py rename to src/server.py index 52660f3..23c9594 100644 --- a/src/mcp_server.py +++ b/src/server.py @@ -1,15 +1,15 @@ +import logging +from contextlib import asynccontextmanager +from dataclasses import dataclass from datetime import timedelta -from typing import Any -from mcp.server.fastmcp import FastMCP, Context -from couchbase.cluster import Cluster +from typing import Any, AsyncIterator + +import click from couchbase.auth import PasswordAuthenticator +from couchbase.cluster import Cluster from couchbase.options import ClusterOptions -import logging -from dataclasses import dataclass -from contextlib import asynccontextmanager -from typing import AsyncIterator from lark_sqlpp import modifies_data, modifies_structure, parse_sqlpp -import click +from mcp.server.fastmcp import Context, FastMCP MCP_SERVER_NAME = "couchbase" @@ -75,7 +75,10 @@ def get_settings() -> dict: envvar="READ_ONLY_QUERY_MODE", type=bool, default=True, - help="Enable read-only query mode. Set to True (default) to allow only read-only queries. Can be set to False to allow data modification queries.", + help=( + "Enable read-only query mode. Set to True (default) to allow only read-only " + "queries. Can be set to False to allow data modification queries." + ), ) @click.option( "--transport", @@ -166,7 +169,8 @@ async def app_lifespan(server: FastMCP) -> AsyncIterator[AppContext]: @mcp.tool() def get_scopes_and_collections_in_bucket(ctx: Context) -> dict[str, list[str]]: """Get the names of all scopes and collections in the bucket. - Returns a dictionary with scope names as keys and lists of collection names as values. + Returns a dictionary with scope names as keys and lists of + collection names as values. """ bucket = ctx.request_context.lifespan_context.bucket try: @@ -187,7 +191,8 @@ def get_schema_for_collection( ctx: Context, scope_name: str, collection_name: str ) -> dict[str, Any]: """Get the schema for a collection in the specified scope. - Returns a dictionary with the schema returned by running INFER on the Couchbase collection. + Returns a dictionary with the schema returned by running INFER on the Couchbase + collection. """ try: query = f"INFER {collection_name}" @@ -264,7 +269,7 @@ def run_sql_plus_plus_query( scope = bucket.scope(scope_name) results = [] - # If read-only mode is enabled, check if the query is a data or structure modification query + # If read-only mode is enabled, check if the query modifies data or structure if read_only_query_mode: data_modification_query = modifies_data(parse_sqlpp(query)) structure_modification_query = modifies_structure(parse_sqlpp(query)) From 66e7c251a1e1d50e1d55e94c92e626aeffe3327c Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan <12782505+nithishr@users.noreply.github.com> Date: Wed, 23 Apr 2025 18:41:50 +0200 Subject: [PATCH 2/6] Update project version to 0.2.0-rc.0 and add GitHub Actions workflow for package build and publish - Changed version in pyproject.toml to 0.2.0-rc.0 to indicate a release candidate. - Introduced a new GitHub Actions workflow for building and publishing the package to PyPI, including steps for linting, installation, and release creation. --- .github/workflows/build.yml | 52 +++++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6d29fef --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,52 @@ +name: Build and Publish Package to PyPI + +on: + push: + tags: + - "v[0-9].[0-9]+.[0-9]+*" + workflow_dispatch: + +jobs: + build-and-publish: + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + cache: "pip" + + - name: Install build dependencies + run: | + python -m pip install --upgrade pip + pip install hatch ruff + + - name: Lint with ruff + run: | + ruff check . + + - name: Install package + run: | + pip install -e . + + - name: Build package + run: | + hatch build + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: dist/* + generate_release_notes: true + draft: false + prerelease: false diff --git a/pyproject.toml b/pyproject.toml index 605ef5d..2efbc0a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mcp-couchbase" -version = "0.2.0" +version = "0.2.0-rc.0" description = "Couchbase MCP Server - The Developer Data Platform for Critical Applications in Our AI World" readme = "README.md" requires-python = ">=3.10" From bc4a339175b6767a7dc24f8437165320934643f2 Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan <12782505+nithishr@users.noreply.github.com> Date: Wed, 23 Apr 2025 18:48:54 +0200 Subject: [PATCH 3/6] Update classifiers in pyproject.toml for improved project metadata - Changed the classifier from "Database :: MCP Server" to "Topic :: Database" to better categorize the project. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2efbc0a..83023cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ authors = [ classifiers = [ "Development Status :: 4 - Beta", "Programming Language :: Python :: 3", - "Database :: MCP Server", + "Topic :: Database", ] dependencies = [ From c386e2193e04a8f130026a95d4ea65aa8e970c94 Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan <12782505+nithishr@users.noreply.github.com> Date: Wed, 23 Apr 2025 18:53:21 +0200 Subject: [PATCH 4/6] Add wheel target configuration in pyproject.toml - Introduced a new section for wheel build targets in pyproject.toml, specifying the packages to include during the build process. --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 83023cc..8cadb56 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,3 +36,6 @@ build-backend = "hatchling.build" [tool.ruff.lint] select = ["E", "F", "I", "T201"] + +[tool.hatch.build.targets.wheel] +packages = ["src"] \ No newline at end of file From c2869886dea030605bd756d0107b9d3f3d8ca7d2 Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan <12782505+nithishr@users.noreply.github.com> Date: Wed, 23 Apr 2025 19:07:10 +0200 Subject: [PATCH 5/6] Refactor project structure for packaging. - Updated `pyproject.toml` to change the script entry point to the new module path and added a new build target for the `src/mcp_couchbase` package. - Introduced `__init__.py` in the `src/mcp_couchbase` directory to define it as a package. --- pyproject.toml | 7 +++++-- src/mcp_couchbase/__init__.py | 0 src/{ => mcp_couchbase}/server.py | 0 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 src/mcp_couchbase/__init__.py rename src/{ => mcp_couchbase}/server.py (100%) diff --git a/pyproject.toml b/pyproject.toml index 8cadb56..9d10662 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,7 @@ Documentation = "https://github.com/Couchbase-Ecosystem/mcp-server-couchbase#rea Issues = "https://github.com/Couchbase-Ecosystem/mcp-server-couchbase/issues" [project.scripts] -mcp-couchbase-server = "server:main" +mcp-couchbase-server = "mcp_couchbase.server:main" [build-system] requires = ["hatchling >= 1.26"] @@ -38,4 +38,7 @@ build-backend = "hatchling.build" select = ["E", "F", "I", "T201"] [tool.hatch.build.targets.wheel] -packages = ["src"] \ No newline at end of file +packages = ["src"] + +[tool.hatch.build] +packages = ["src/mcp_couchbase"] \ No newline at end of file diff --git a/src/mcp_couchbase/__init__.py b/src/mcp_couchbase/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/server.py b/src/mcp_couchbase/server.py similarity index 100% rename from src/server.py rename to src/mcp_couchbase/server.py From 6bd25ce99e587854d7b70aa13c6880370780b607 Mon Sep 17 00:00:00 2001 From: Nithish Raghunandanan <12782505+nithishr@users.noreply.github.com> Date: Wed, 23 Apr 2025 20:00:27 +0200 Subject: [PATCH 6/6] Rename project and restructure package for Couchbase MCP Server - Updated `pyproject.toml` to rename the project from "mcp-couchbase" to "mcp-server-couchbase" and adjusted the script entry point accordingly. --- pyproject.toml | 9 +++------ src/mcp_couchbase/__init__.py | 0 src/mcp_server_couchbase/__init__.py | 3 +++ src/{mcp_couchbase => mcp_server_couchbase}/server.py | 0 4 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 src/mcp_couchbase/__init__.py create mode 100644 src/mcp_server_couchbase/__init__.py rename src/{mcp_couchbase => mcp_server_couchbase}/server.py (100%) diff --git a/pyproject.toml b/pyproject.toml index 9d10662..6f02351 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "mcp-couchbase" +name = "mcp-server-couchbase" version = "0.2.0-rc.0" description = "Couchbase MCP Server - The Developer Data Platform for Critical Applications in Our AI World" readme = "README.md" @@ -28,7 +28,7 @@ Documentation = "https://github.com/Couchbase-Ecosystem/mcp-server-couchbase#rea Issues = "https://github.com/Couchbase-Ecosystem/mcp-server-couchbase/issues" [project.scripts] -mcp-couchbase-server = "mcp_couchbase.server:main" +mcp-couchbase-server = "mcp_server_couchbase:main" [build-system] requires = ["hatchling >= 1.26"] @@ -37,8 +37,5 @@ build-backend = "hatchling.build" [tool.ruff.lint] select = ["E", "F", "I", "T201"] -[tool.hatch.build.targets.wheel] -packages = ["src"] - [tool.hatch.build] -packages = ["src/mcp_couchbase"] \ No newline at end of file +packages = ["src/mcp_server_couchbase"] \ No newline at end of file diff --git a/src/mcp_couchbase/__init__.py b/src/mcp_couchbase/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/mcp_server_couchbase/__init__.py b/src/mcp_server_couchbase/__init__.py new file mode 100644 index 0000000..9f5ec7a --- /dev/null +++ b/src/mcp_server_couchbase/__init__.py @@ -0,0 +1,3 @@ +from server import main + +__all__ = ["main"] diff --git a/src/mcp_couchbase/server.py b/src/mcp_server_couchbase/server.py similarity index 100% rename from src/mcp_couchbase/server.py rename to src/mcp_server_couchbase/server.py