You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "aminghadersohi (via GitHub)" <gi...@apache.org> on 2025/09/16 17:44:32 UTC

[PR] feat(mcp): Add core MCP service scaffolding - PR1 [superset]

aminghadersohi opened a new pull request, #35160:
URL: https://github.com/apache/superset/pull/35160

   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   This PR introduces the basic scaffold for the Superset MCP (Model Context Protocol) service, enabling AI agents to interact programmatically with Apache Superset.
   
   **Rationale:**
   Breaking this into smaller PRs makes it easier for reviewers to evaluate the changes incrementally rather than reviewing a large implementation all at once.
   
   **What's Included:**
   - CLI commands: `superset mcp run` and `superset mcp setup`
   - Basic FastMCP server using HTTP transport
   - Flask integration for Superset context
   - Configuration setup script
   - Development environment support
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   N/A - This PR adds backend service scaffolding only, no UI changes.
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   1. **Verify the MCP service can be imported without errors:**
      ```bash
      python -c "import superset.mcp_service; print('✅ MCP service imports successfully')"
      ```
      Expected output: `✅ MCP service imports successfully`
   
   2. **Test the CLI commands are available:**
      ```bash
      superset --help | grep mcp
      ```
      Expected output: Shows `mcp` command group
   
   3. **Run the setup command:**
      ```bash
      superset mcp setup
      ```
      Expected: Creates/updates `superset_config.py` with MCP settings
   
   4. **Test the MCP server startup (optional):**
      ```bash
      # Note: This requires superset to be running and fastmcp installed
      superset mcp run --help
      ```
      Expected: Shows help for MCP server options
   
   5. **Verify no impact on existing Superset:**
      ```bash
      # Start Superset normally
      superset run -p 8088 --with-threads --reload
      # Navigate to http://localhost:8088
      # Verify all existing functionality works as expected
      ```
   
   6. **Run pre-commit checks:**
      ```bash
      pre-commit run --all-files
      ```
      All checks should pass (mypy, ruff, pylint)
   
   7. **Test Node.js proxy (if Node.js available):**
      ```bash
      cd superset/mcp_service
      node index.js --help
      ```
      Expected: Shows Node.js MCP proxy options
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [x] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   **Notes:**
   - Foundational scaffold with minimal functionality, completely isolated from existing code
   - Requires `fastmcp` library (added to `requirements/development.in`)
   - Zero risk - no impact on existing Superset functionality


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): Add core MCP service scaffolding - PR1 [superset]

Posted by "github-advanced-security[bot] (via GitHub)" <gi...@apache.org>.
github-advanced-security[bot] commented on code in PR #35160:
URL: https://github.com/apache/superset/pull/35160#discussion_r2353228309


##########
superset/mcp_service/bin/superset-mcp.js:
##########
@@ -0,0 +1,263 @@
+#!/usr/bin/env node
+
+/**
+ * Apache Superset MCP (Model Context Protocol) Server Runner
+ *
+ * OVERVIEW:
+ * This Node.js wrapper script provides an npx-compatible entry point for the Superset MCP service.
+ * It acts as a bridge between npm/npx tooling and the Python-based MCP server implementation.
+ *
+ * FUNCTIONALITY:
+ * - Detects and validates Python environment and Superset installation
+ * - Supports both stdio (Claude Desktop integration) and HTTP transport modes
+ * - Handles command-line argument parsing and environment variable configuration
+ * - Manages Python subprocess lifecycle with proper signal handling
+ * - Provides comprehensive help documentation and error diagnostics
+ *
+ * USAGE PATTERNS (DEVELOPMENT - Not yet published to npm):
+ * - Direct execution: node superset/mcp_service/bin/superset-mcp.js --stdio
+ * - HTTP server: node superset/mcp_service/bin/superset-mcp.js --http --port 6000
+ * - Development debugging: node superset/mcp_service/bin/superset-mcp.js --debug
+ *
+ * FUTURE USAGE (Once published to npm registry):
+ * - npx @superset/mcp-server --stdio
+ * - npx @superset/mcp-server --http --port 6000
+ *
+ * ARCHITECTURE:
+ * This wrapper enables the MCP service to be distributed as an npm package while
+ * maintaining the core Python implementation, bridging Node.js tooling with Python execution.
+ *
+ * PACKAGE STATUS (as of 2025-01-10):
+ * - NOT YET PUBLISHED to npm registry
+ * - Package name reserved: @superset/mcp-server
+ * - Requires package.json with proper metadata and "bin" field for npx execution
+ * - Will need to be published to npm registry before npx commands work
+ *
+ * TODO FOR NPM PUBLISHING:
+ * 1. Create package.json with name "@superset/mcp-server"
+ * 2. Add "bin" field pointing to this file
+ * 3. Set version, description, repository, license
+ * 4. Run npm publish with appropriate access rights
+ */
+
+const { spawn, execSync } = require('child_process');
+const path = require('path');
+const fs = require('fs');
+
+// Parse command line arguments
+const args = process.argv.slice(2);
+const isStdio = args.includes('--stdio') || process.env.FASTMCP_TRANSPORT === 'stdio';
+const isDebug = args.includes('--debug') || process.env.MCP_DEBUG === '1';
+const showHelp = args.includes('--help') || args.includes('-h');
+
+// Configuration
+const DEFAULT_PORT = process.env.MCP_PORT || '5008';
+const DEFAULT_HOST = process.env.MCP_HOST || '127.0.0.1';
+
+// Show help
+if (showHelp) {
+    console.log(`
+Apache Superset MCP Server
+
+Usage:
+  Development: node superset/mcp_service/bin/superset-mcp.js [options]
+  Future (npm): npx @superset/mcp-server [options]
+
+Options:
+  --stdio       Run in stdio mode for direct Claude Desktop integration
+  --http        Run in HTTP mode (default)
+  --port PORT   HTTP port to bind to (default: ${DEFAULT_PORT})
+  --host HOST   HTTP host to bind to (default: ${DEFAULT_HOST})
+  --debug       Enable debug mode
+  --help        Show this help message
+
+Environment Variables:
+  FASTMCP_TRANSPORT     Transport mode (stdio or http)
+  MCP_PORT              HTTP port (default: ${DEFAULT_PORT})
+  MCP_HOST              HTTP host (default: ${DEFAULT_HOST})
+  MCP_DEBUG             Enable debug (set to 1)
+  PYTHONPATH            Python path including Superset root
+  SUPERSET_CONFIG_PATH  Path to superset_config.py
+
+Examples (Development):
+  # Run in stdio mode for Claude Desktop
+  node superset/mcp_service/bin/superset-mcp.js --stdio
+
+  # Run in HTTP mode on custom port
+  node superset/mcp_service/bin/superset-mcp.js --http --port 6000
+
+  # Run with debug output
+  node superset/mcp_service/bin/superset-mcp.js --debug
+
+  # Or use the Python CLI directly:
+  superset mcp run --host 127.0.0.1 --port 6000
+`);
+    process.exit(0);
+}
+
+// Find Superset root directory
+function findSupersetRoot() {
+    // Start from the mcp_service directory
+    let currentDir = path.resolve(__dirname, '..');
+
+    // Walk up until we find the superset root (contains setup.py or pyproject.toml)
+    while (currentDir !== path.dirname(currentDir)) {
+        if (fs.existsSync(path.join(currentDir, 'pyproject.toml')) ||
+            fs.existsSync(path.join(currentDir, 'setup.py'))) {
+            // Check if it's actually the superset root (has superset directory)
+            if (fs.existsSync(path.join(currentDir, 'superset'))) {
+                return currentDir;
+            }
+        }
+        currentDir = path.dirname(currentDir);
+    }
+
+    // Fallback to environment variable
+    if (process.env.PYTHONPATH) {
+        return process.env.PYTHONPATH;
+    }
+
+    throw new Error('Could not find Superset root directory. Please set PYTHONPATH environment variable.');
+}
+
+// Find Python executable
+function findPython() {

Review Comment:
   ## Shell command built from environment values
   
   This shell command depends on an uncontrolled [absolute path](1).
   This shell command depends on an uncontrolled [absolute path](2).
   
   [Show more details](https://github.com/apache/superset/security/code-scanning/2048)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): Add core MCP service scaffolding - PR1 [superset]

Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on PR #35160:
URL: https://github.com/apache/superset/pull/35160#issuecomment-3299749731

   Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment `/korbit-review`.
   
   > Your admin can change your review schedule in the [Korbit Console](https://app.korbit.ai/settings)
   
   
   
   [](79d45b77-dc8f-4c5d-93f2-2aa160cd52f1)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(mcp): Add core MCP service scaffolding - PR1 [superset]

Posted by "aminghadersohi (via GitHub)" <gi...@apache.org>.
aminghadersohi closed pull request #35160: feat(mcp): Add core MCP service scaffolding - PR1 
URL: https://github.com/apache/superset/pull/35160


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org