Skip to content

Conversation

aminghadersohi
Copy link
Owner

@aminghadersohi aminghadersohi commented Sep 16, 2025

SUMMARY

This PR adds an endpoint/blueprint to Apache Superset /api/v1/mcp-client|proxy, enabling integration with AI tools and external services through a superset hosted endpoint that should hopefully mean it also takes care of multi tennancy.

PR #1: apache#35163
The implementation includes:

  • MCP HTTP Proxy: new blueprint behind feature flag:/api/v1/mcp-proxy/ reverse proxies to mcp service via http (localhost 5008)
  • MCP Client Proxy: new blueprint behind feature flag: /api/v1/mcp-client/ reverse proxies to mcp service by using the FastMCP provided Client class - used in tests.
  • FastMCP Integration: Leverages the FastMCP library for Python MCP support
  • Feature Flag Protection: All MCP functionality is gated behind the MCP_SERVICE feature flag

This enhancement enables multi-tenancy to be achieved automatically via superset (Theoretically)

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A - Backend service addition

TESTING INSTRUCTIONS

  1. Enable the MCP_SERVICE feature flag in your config:

    FEATURE_FLAGS = {
        "MCP_SERVICE": True,
    }
  2. Install the FastMCP dependency:

    pip install fastmcp>=2.8.1
  3. Test the MCP HTTP proxy:

    ./test_mcp_proxy.sh
  4. Test the MCP client proxy:

    ./test_mcp_client_proxy.sh
  5. Run all MCP tests:

    ./test_mcp_all.sh
  6. Verify endpoints are registered:

    • HTTP proxy: /mcp/sse
    • Client proxy: /mcp-client/<server_name>/<method>

ADDITIONAL INFORMATION

  • Has associated issue: Related to AI/LLM integration initiatives
  • Required feature flags: MCP_SERVICE
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
  • Introduces new feature or API
  • Removes existing feature or API

Technical Details:

  • The MCP service provides an internal 'native' connection between Superset's APIs and its mcp service via code.

Security Considerations:

  • MCP endpoints are protected by Superset's existing authentication/authorization
  • Feature flag ensures MCP is opt-in only
  • Input validation on all proxy endpoints
  • No direct execution of untrusted code

Performance Impact:

  • Minimal - MCP proxies are lightweight and only active when feature flag is enabled

@aminghadersohi aminghadersohi changed the title feat: Pr2 - Add MCP (Model Context Protocol) service integration feat: Pr2 - Add MCP blueprint to superset Sep 16, 2025
@aminghadersohi aminghadersohi changed the title feat: Pr2 - Add MCP blueprint to superset feat: Pr2 - Add MCP blueprint to superset /api/v1/mcp Sep 16, 2025
@aminghadersohi aminghadersohi changed the title feat: Pr2 - Add MCP blueprint to superset /api/v1/mcp feat(mcp): Pr2 - Add MCP blueprint to superset /api/v1/mcp Sep 16, 2025
@aminghadersohi aminghadersohi force-pushed the feat/mcp_service_pr1_scaffold branch from 42af216 to 2221f8b Compare September 17, 2025 01:42
@aminghadersohi aminghadersohi force-pushed the feat/mcp_service_pr2_integration branch from cd668b9 to d6b0c9a Compare September 17, 2025 01:42
…perset

This commit introduces the basic scaffold for the MCP service that enables
AI agents to interact with Apache Superset programmatically.

## Key Components

### Core Structure
- **CLI Interface**: `superset mcp run` and `superset mcp setup` commands
- **FastMCP Server**: HTTP-based MCP server using FastMCP protocol
- **Flask Integration**: Singleton pattern for Superset app integration
- **Configuration Setup**: Automated setup script for MCP service config

### Files Added
- `superset/cli/mcp.py`: CLI commands for running and setting up MCP service
- `superset/mcp_service/`: Core MCP service package with server, app, and config
- `superset/mcp_service/scripts/setup.py`: Configuration setup utilities
- `superset/config_mcp.py`: MCP-specific configuration template
- Development container configurations for MCP-enabled development

### Features
- Basic HTTP transport for MCP communication
- Configuration management for Superset integration
- Development environment setup with Docker support
- Node.js proxy support for alternative connection methods

This scaffold provides the foundation for subsequent PRs that will add:
- Authentication and authorization
- Tool implementations (dashboards, charts, datasets)
- Advanced middleware and permissions
- Production-ready features

The implementation follows Superset's architectural patterns and can be
extended incrementally without breaking changes.
@aminghadersohi aminghadersohi force-pushed the feat/mcp_service_pr1_scaffold branch from 2221f8b to ed73757 Compare September 19, 2025 17:45
- Add mcp_config.py with centralized MCP configuration
- Refactor setup.py to use import-based config instead of hardcoded strings
- Update README with manual setup instructions following standard Superset patterns
- Replace hidden MCP_DEBUG env var with proper app.config setting
- Remove opinionated warnings filter to let logger.ini handle warnings
- Make configuration more maintainable and discoverable
Add Flask-style application factory for FastMCP instances with support for:
- Custom authentication providers via auth parameter
- Middleware and lifespan handlers
- Tag-based tool filtering (include_tags/exclude_tags)
- Additional configuration options
- Backward compatibility with existing mcp instance

Examples provided in superset/mcp_service/examples/ showing usage
patterns for secure, filtered, and custom configurations.
Fix invalid import from non-existent superset.mcp_service.config module
to use get_mcp_config() from superset.mcp_service.mcp_config instead.
Add health_check tool in system/tool/ that returns:
- Service status and timestamp
- System information (Python version, platform)
- Basic uptime information

Tool is automatically registered via import in __init__.py
for easy connectivity testing of the MCP service.
- Replace complex threading singleton with simple module-level pattern
- Clean up server.py imports and formatting
- Update README.md with better configuration examples
Remove mcp_service/scripts/ directory and superset mcp setup command
to simplify the MCP service implementation.
- Only configure basic logging if no handlers exist (respects logging.ini)
- Only override SQLAlchemy logger levels if they're at default levels
- Prevents interference with production logging configuration
Remove time.sleep(0.1) from signal handler in simple_proxy.py
as it's not a maintainable solution for cleanup. FastMCP
proxy should handle its own cleanup when process exits.
- Add MCP HTTP proxy for server communication
- Add MCP client proxy for stdio-based servers
- Include FastMCP dependency for Python MCP support
- Add proxy scripts and test utilities
- Register MCP blueprints with feature flag MCP_SERVICE
@aminghadersohi aminghadersohi force-pushed the feat/mcp_service_pr2_integration branch from d6b0c9a to 4fcf371 Compare September 22, 2025 19:59
@aminghadersohi aminghadersohi changed the title feat(mcp): Pr2 - Add MCP blueprint to superset /api/v1/mcp feat(mcp): experimental - Add MCP blueprint to superset /api/v1/mcp Sep 22, 2025
@aminghadersohi aminghadersohi force-pushed the feat/mcp_service_pr1_scaffold branch from be6d3b1 to 6bb4feb Compare September 25, 2025 17:54
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.

1 participant