Skip to content

feat: introduce api client <> server separation #62

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

Merged
merged 4 commits into from
Apr 3, 2025

Conversation

alexander-zuev
Copy link
Owner

@alexander-zuev alexander-zuev commented Mar 19, 2025

Query MCP

This PR enables release of v0.4 of this MCP server (renamed Query MCP to account for the future development) and includes a number of changes, most critical of which:

  • introduces support for working with MCP api to enable feature access
  • fixes several annoying bugs (shutdown, default connection values)
  • introduces proper startup + shutdown procedure
  • introduces proper base http client

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring (no functional changes)

Checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • New and existing unit tests pass locally with my changes

@alexander-zuev alexander-zuev self-assigned this Mar 19, 2025
@alexander-zuev alexander-zuev marked this pull request as draft March 19, 2025 06:15
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a separation between the API client and server along with a new feature manager for enhanced query and premium feature access. Key changes include:

  • Adding a new feature manager service to handle feature access and tool execution.
  • Refactoring service initialization and shutdown (including a new lifespan function with forced termination).
  • Updating client implementations (API, management, SDK) and configuration schemas.

Reviewed Changes

Copilot reviewed 33 out of 35 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
supabase_mcp/services/database/postgres_client.py Updated connection pool typing and enhanced pool closing logic.
supabase_mcp/services/api/api_manager.py Updated API client import references.
supabase_mcp/main.py Revised application lifespan and shutdown sequence.
supabase_mcp/exceptions.py Added custom exceptions for feature access errors.
supabase_mcp/core/feature_manager.py Introduced a new feature management service implementation.
supabase_mcp/core/container.py Refactored container to a singleton ServicesContainer with new services.
supabase_mcp/clients/sdk_client.py Minor updates to logging messages.
supabase_mcp/clients/management_client.py Corrected logging messages and now uses configured API URL.
supabase_mcp/clients/base_http_client.py New async HTTP client with retry logic for network requests.
supabase_mcp/clients/api_client.py New Query API client implementation with proper error handling.
smithery.yaml Added Query API key configuration and mapping.
pyproject.toml Updated dependencies and version bumps.
README.md Updated documentation to reflect the new Query MCP branding.
Files not reviewed (2)
  • .env.example: Language not supported
  • .env.test.example: Language not supported

@@ -17,6 +17,8 @@
# Define a type variable for generic return types
T = TypeVar("T")

# TODO: Use a context manager to properly handle the connection pool
Copy link
Preview

Copilot AI Apr 3, 2025

Choose a reason for hiding this comment

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

Consider implementing a context manager for the connection pool to ensure it is properly closed even when exceptions occur.

Copilot uses AI. Check for mistakes.

Comment on lines +30 to +33
import os

# Register tools
mcp = ToolRegistry(mcp=mcp, services_container=services_container).register_tools()
os._exit(0) # Use 0 for successful termination

Copy link
Preview

Copilot AI Apr 3, 2025

Choose a reason for hiding this comment

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

Using os._exit(0) forces an abrupt termination that bypasses graceful cleanup; consider replacing it with a more orderly shutdown mechanism if possible.

Suggested change
import os
# Register tools
mcp = ToolRegistry(mcp=mcp, services_container=services_container).register_tools()
os._exit(0) # Use 0 for successful termination
import sys
sys.exit(0) # Use 0 for successful termination

Copilot uses AI. Check for mistakes.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 39.00929% with 197 lines in your changes missing coverage. Please review.

Project coverage is 78.4%. Comparing base (d674529) to head (0a89712).

Files with missing lines Patch % Lines
supabase_mcp/core/feature_manager.py 21.7% 90 Missing ⚠️
supabase_mcp/clients/base_http_client.py 32.3% 44 Missing ⚠️
supabase_mcp/clients/api_client.py 57.5% 17 Missing ⚠️
supabase_mcp/tools/registry.py 18.7% 13 Missing ⚠️
supabase_mcp/core/container.py 59.2% 11 Missing ⚠️
supabase_mcp/main.py 38.8% 11 Missing ⚠️
supabase_mcp/settings.py 79.1% 5 Missing ⚠️
supabase_mcp/exceptions.py 50.0% 4 Missing ⚠️
supabase_mcp/clients/sdk_client.py 50.0% 2 Missing ⚠️

Impacted file tree graph

@@           Coverage Diff           @@
##            main     #62     +/-   ##
=======================================
- Coverage   84.0%   78.4%   -5.6%     
=======================================
  Files         26      29      +3     
  Lines       1682    1932    +250     
=======================================
+ Hits        1413    1515    +102     
- Misses       269     417    +148     
Files with missing lines Coverage Δ
supabase_mcp/clients/management_client.py 81.6% <100.0%> (ø)
supabase_mcp/services/api/api_manager.py 79.0% <100.0%> (ø)
supabase_mcp/services/database/postgres_client.py 87.3% <100.0%> (ø)
supabase_mcp/clients/sdk_client.py 89.0% <50.0%> (ø)
supabase_mcp/exceptions.py 90.9% <50.0%> (-9.1%) ⬇️
supabase_mcp/settings.py 89.0% <79.1%> (-5.0%) ⬇️
supabase_mcp/core/container.py 79.6% <59.2%> (-20.4%) ⬇️
supabase_mcp/main.py 59.3% <38.8%> (-29.6%) ⬇️
supabase_mcp/tools/registry.py 75.0% <18.7%> (+29.4%) ⬆️
supabase_mcp/clients/api_client.py 57.5% <57.5%> (ø)
... and 2 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexander-zuev alexander-zuev marked this pull request as ready for review April 3, 2025 09:03
@alexander-zuev alexander-zuev merged commit a88ee4a into main Apr 3, 2025
2 checks passed
@alexander-zuev alexander-zuev deleted the feat/api-server branch April 4, 2025 15:10
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.

2 participants