Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions superset/mcp_service/index.js → superset/mcp_service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,35 @@
* Entry point for the MCP server when used as a Node.js module.
*/

const { spawn } = require('child_process');
const path = require('path');
import type { ChildProcess } from 'child_process';
import * as path from 'path';

interface SupersetMCPServerOptions {
transport?: string;
host?: string;
port?: number;
debug?: boolean;
pythonPath?: string | null;
supersetRoot?: string | null;
configPath?: string | null;
}

interface ResolvedSupersetMCPServerOptions {
transport: string;
host: string;
port: number;
debug: boolean;
pythonPath: string | null;
supersetRoot: string | null;
configPath: string | null;
}

class SupersetMCPServer {
constructor(options = {}) {
private readonly options: ResolvedSupersetMCPServerOptions;

private process: ChildProcess | null;

constructor(options: SupersetMCPServerOptions = {}) {
this.options = {
transport: options.transport || 'http',
host: options.host || '127.0.0.1',
Expand All @@ -40,17 +64,18 @@ class SupersetMCPServer {
this.process = null;
}

start() {
const runner = require('./bin/superset-mcp.js');
// The bin script handles the execution
start(): void {
// The bin script handles the execution. Resolve it relative to the
// package root so the lookup works from the compiled output directory.
require(path.join(__dirname, '..', 'bin', 'superset-mcp.js'));
}
Comment on lines +67 to 71

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚩 Pre-existing: stop() is a no-op because start() never sets this.process

The start() method at superset/mcp_service/index.ts:67-71 calls require() to load the bin script, which internally spawns a Python child process. However, that child process reference is local to the bin script (superset/mcp_service/bin/superset-mcp.js:250) and is never exported or returned. As a result, this.process remains null after start(), and stop() at line 73-78 can never actually kill the spawned process. This is unchanged from the original JS — the old code also never set this.process — but it means the class's lifecycle management is incomplete. If anyone ever calls stop(), it silently does nothing.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks — agreed, and as the note says this is pre-existing: the original index.js also never set this.process, so stop() has always been a no-op. This PR is intentionally a behavior-preserving JS→TS migration, so I've left the lifecycle logic unchanged rather than expanding scope here. Properly wiring up start()/stop() (e.g. having the bin runner expose the spawned ChildProcess so it can be tracked and killed) would be a good follow-up, but it's a functional change beyond this migration.


stop() {
stop(): void {
if (this.process) {
this.process.kill();
this.process = null;
}
}
}

module.exports = SupersetMCPServer;
export = SupersetMCPServer;
54 changes: 54 additions & 0 deletions superset/mcp_service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions superset/mcp_service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
"name": "@superset/mcp-server",
"version": "1.0.0",
"description": "Apache Superset MCP (Model Context Protocol) Server",
"main": "index.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
"superset-mcp": "./bin/superset-mcp.js"
},
"scripts": {
"build": "tsc",
"type-check": "tsc --noEmit",
"start": "node bin/superset-mcp.js",
"stdio": "node bin/superset-mcp.js --stdio",
"http": "node bin/superset-mcp.js --http"
Expand All @@ -30,6 +33,9 @@
"node": ">=18.0.0"
},
"dependencies": {},
"devDependencies": {},
"devDependencies": {
"@types/node": "^22.10.2",
"typescript": "^5.9.3"
},
"preferGlobal": false
}
13 changes: 13 additions & 0 deletions superset/mcp_service/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"outDir": "dist",
"target": "es2020",
"module": "commonjs",
"declaration": true,
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["index.ts"]
}