Skip to main content

Overview

Superset uses the Model Context Protocol (MCP) to provide AI agents with tools and resources for interacting with the desktop app, managing workspaces, and automating workflows. Packages:
  • packages/mcp - Superset cloud MCP server (workspace/device management)
  • packages/desktop-mcp - Desktop automation MCP server (UI testing, browser control)

MCP Protocol Basics

MCP servers expose tools and resources that AI agents can invoke:
  • Tools: Functions the agent can call (e.g., create_workspace, click, navigate)
  • Resources: Data the agent can read (e.g., workspace details, app context)
  • Prompts: Pre-configured prompts for common tasks

Server Initialization

MCP servers are created using @modelcontextprotocol/sdk:

Tool Registration

Tools are registered with Zod schemas for input validation:

Desktop MCP Server

Package: @superset/desktop-mcp Source: packages/desktop-mcp/src/mcp/mcp-server.ts:5 Provides browser automation and UI testing tools.

Server Setup

Available Tools

Source: packages/desktop-mcp/src/mcp/tools/index.ts:20 All tools defined in packages/desktop-mcp/src/mcp/tools/:
  • take_screenshot - Capture app screenshots
  • inspect_dom - Inspect DOM elements
  • click - Click UI elements
  • type_text - Type text into inputs
  • send_keys - Send keyboard shortcuts
  • get_console_logs - Retrieve console logs
  • evaluate_js - Execute JavaScript in app
  • navigate - Navigate to URLs
  • get_window_info - Get window metadata

Tool Example: click

Source: packages/desktop-mcp/src/mcp/tools/click/click.ts:43

Usage Example

Agents invoke desktop MCP tools via the protocol:

Superset MCP Server

Package: @superset/mcp Source: packages/mcp/src/server.ts:4 Provides workspace, device, and task management tools.

Server Setup

Available Tools

Source: packages/mcp/src/tools/index.ts:20 All tools organized by category:

Device Tools

  • list_devices - List registered devices
  • list_workspaces - List workspaces on a device
  • create_workspace - Create new workspace(s)
  • switch_workspace - Switch active workspace
  • delete_workspace - Delete workspace
  • update_workspace - Update workspace config
  • list_projects - List projects
  • get_app_context - Get current app state
  • get_workspace_details - Get workspace metadata
  • start_agent_session - Start agent session on device

Task Tools

  • create_task - Create task
  • update_task - Update task
  • list_tasks - List tasks
  • get_task - Get task details
  • delete_task - Delete task
  • list_task_statuses - List available statuses

Organization Tools

  • list_members - List organization members

Tool Example: create_workspace

Source: packages/mcp/src/tools/devices/create-workspace/create-workspace.ts:20

Authentication Context

MCP tools use a context pattern for authentication:

Building Custom MCP Servers

1. Create Server Structure

package.json:

2. Define Tools

src/tools/my-tool.ts:

3. Register Tools

src/tools/index.ts:

4. Create Server

src/server.ts:

5. Create CLI Entry Point

src/bin.ts:

6. Build and Test

Test with MCP Inspector:

MCP Server Configuration

Add your MCP server to .mcp.json:
For published packages:

Server Lifecycle

Initialization

  1. Server process starts via stdio transport
  2. MCP SDK establishes connection
  3. Tools are registered
  4. Server sends initialized notification

Tool Invocation

  1. Client sends tools/call request
  2. Server validates input with Zod schema
  3. Tool handler executes
  4. Server returns result or error

Shutdown

  1. Client closes connection
  2. Server cleanup handlers run
  3. Process exits

Testing MCP Servers

Unit Testing Tools

Integration Testing

Use @modelcontextprotocol/inspector for manual testing:
This opens a UI for invoking tools and inspecting responses.

Error Handling

Return Errors from Tools

Throw Errors for Server Issues


Best Practices

1. Tool Naming

  • Use snake_case for tool names
  • Be descriptive: create_workspace not create
  • Prefix with category: github_create_issue

2. Input Validation

  • Always use Zod schemas
  • Provide clear descriptions for each parameter
  • Set reasonable defaults
  • Mark optional parameters explicitly

3. Error Messages

  • Return user-friendly error messages
  • Include context: what failed and why
  • Suggest fixes when possible

4. Tool Descriptions

  • Start with action verb: “Create”, “List”, “Update”
  • Explain what the tool does in plain language
  • Include use cases in description

5. Response Format

  • Always return { content: [...] }
  • Use type: "text" for messages
  • Set isError: true for user-facing errors

Example: Full Custom MCP Server

src/server.ts:
src/bin.ts:

Next Steps

Desktop API

Electron IPC APIs for local operations

tRPC Endpoints

Cloud tRPC API reference

MCP SDK Docs

Official MCP documentation

Example MCP Servers

Reference implementations