# MCP Server

## Overview

The Sling CLI includes a built-in MCP (Model Context Protocol) server that enables AI assistants like Claude, ChatGPT, and GitHub Copilot to interact with your data infrastructure through a standardized interface. MCP is an open protocol that allows AI models to connect to external tools and data sources safely and efficiently.

By running `sling mcp`, you expose Sling's powerful data movement and transformation capabilities to AI assistants, enabling them to:

* Query and explore databases across 30+ database systems
* Manage files across cloud storage providers (S3, Azure, GCS, etc.)
* Execute data replications and pipelines
* Create and test API specifications
* Discover schemas, tables, and columns

{% embed url="<https://f.slingdata.io/videos/mcp.demo.20251201.mp4>" %}
Sling MCP Demo
{% endembed %}

## Core Capabilities

The Sling MCP server exposes six main tools that AI assistants can use:

### 1. Connection Tool

Manages connections to databases, file systems, and APIs.

**Actions:**

* `list` - List all configured connections
* `discover` - Discover tables, files, or endpoints in a connection
* `test` - Test connection validity
* `set` - Create or update a connection
* `docs` - Fetch connection documentation

### 2. Database Tool

Provides database-specific operations for querying and schema exploration.

**Actions:**

* `docs` - Fetch database documentation
* `query` - Execute SQL queries (read-only by default)
* `get_schemata` - Get detailed schema information (databases, schemas, tables, columns)
* `get_schemas` - List available schemas
* `get_columns` - Get column metadata for specific tables

### 3. File System Tool

Manages files across local and cloud storage systems.

**Actions:**

* `list` - List files and directories
* `copy` - Copy files between connections
* `inspect` - Get file metadata and statistics
* `docs` - Fetch file system documentation

### 4. API Spec Tool

Creates and manages API specifications for REST APIs.

**Actions:**

* `parse` - Parse and validate API specification files
* `test` - Test API endpoints defined in specifications
* `docs` - Fetch API specification documentation

### 5. Replication Tool

Executes data replication configurations.

**Actions:**

* `parse` - Parse replication YAML files
* `compile` - Compile and validate replications
* `run` - Execute replications
* `docs` - Fetch replication documentation

### 6. Pipeline Tool

Manages and executes data pipelines.

**Actions:**

* `parse` - Parse pipeline configurations
* `run` - Execute pipelines
* `docs` - Fetch pipeline documentation

## Installation

### Prerequisites

1. **Install Sling CLI**: Follow the [installation guide](/sling-cli/getting-started.md)
2. **Verify installation**: Run `sling --version`
3. **Set up connections**: Configure your database and storage connections using [environment variables](/sling-cli/environment.md)

### VSCode with GitHub Copilot

GitHub Copilot in VSCode supports MCP servers through workspace or user configuration:

#### Workspace Configuration

Create `.vscode/mcp.json` in your project root:

```json
{
  "servers": {
    "sling": {
      "type": "stdio",
      "command": "sling",
      "args": ["mcp"],
      "env": {
        "SLING_CLI_TOKEN": "your-token-here"
      }
    }
  }
}
```

#### User Configuration (Global)

1. Open Command Palette (`Cmd+Shift+P` or `Ctrl+Shift+P`)
2. Run `MCP: Add Server`
3. Select "Global"
4. Enter configuration:

```json
{
  "name": "sling",
  "type": "stdio",
  "command": "sling",
  "args": ["mcp"],
  "env": {
    "SLING_CLI_TOKEN": "your-token-here"
  }
}
```

#### Using with Copilot

1. Open Chat view (`Ctrl+Alt+I` or `Cmd+Alt+I`)
2. Select "Agent mode" from the dropdown
3. Click "Tools" button to see available Sling tools
4. Start using Sling commands in your prompts

![Sling MCP on VSCode](/files/RJ7E383gmukDIyGnGKvi)

![Sling MCP on VSCode](/files/MjXOPp9QGe5RMIe0xQV6)

![Sling MCP on VSCode](/files/tCFF364dN99QVhgvQgT1)

### Claude Desktop

Claude Desktop supports MCP servers through a configuration file. Here's how to set up Sling:

{% tabs %}
{% tab title="macOS" %}

1. Open the configuration file:

```bash
open ~/Library/Application\ Support/Claude/claude_desktop_config.json
```

2. Add the Sling MCP server configuration:

```json
{
  "mcpServers": {
    "sling": {
      "command": "sling",
      "args": ["mcp"],
      "env": {
        "SLING_CLI_TOKEN": "your-token-here"
      }
    }
  }
}
```

3. Restart Claude Desktop
4. Look for the MCP indicator (🔌) in the bottom-right corner of the chat input
   {% endtab %}

{% tab title="Windows" %}

1. Open the configuration file at:

```
%APPDATA%\Claude\claude_desktop_config.json
```

2. Add the Sling MCP server configuration:

```json
{
  "mcpServers": {
    "sling": {
      "command": "sling",
      "args": ["mcp"],
      "env": {
        "SLING_CLI_TOKEN": "your-token-here"
      }
    }
  }
}
```

3. Restart Claude Desktop
4. Look for the MCP indicator (🔌) in the bottom-right corner of the chat input
   {% endtab %}
   {% endtabs %}

![Sling MCP on Claude Desktop](/files/cg2mrr6jfJIaZnwOzgkB)

![Sling MCP on Claude Desktop](/files/1zgz6LhJMr2GAatu7LR9)

![Sling MCP on Claude Desktop](/files/Hnh3uGXvpD8N7kRBnBIG)

### Claude Code

Claude Code supports MCP servers at three configuration scopes:

#### Local Scope (Project-specific)

```bash
# Add for current project only
claude mcp add sling --args "mcp" --env SLING_CLI_TOKEN=your-token-here
```

#### Project Scope (Shared with team)

Create `.mcp.json` in your project root:

```json
{
  "servers": {
    "sling": {
      "type": "stdio",
      "command": "sling",
      "args": ["mcp"],
      "env": {
        "SLING_CLI_TOKEN": "${SLING_CLI_TOKEN}"
      }
    }
  }
}
```

#### User Scope (Global)

```bash
# Add globally for all projects
claude mcp add sling --scope user --args "mcp" --env SLING_CLI_TOKEN=your-token-here
```

Alternatively, edit `~/.claude.json` directly:

```json
{
  "mcpServers": {
    "sling": {
      "command": "sling",
      "args": ["mcp"],
      "env": {
        "SLING_CLI_TOKEN": "your-token-here"
      }
    }
  }
}
```

### ChatGPT Desktop

{% hint style="warning" %}
**Note:** As of 2025, OpenAI has announced plans to add native MCP support to ChatGPT Desktop, but implementation is pending. Check the [OpenAI Developer Community](https://community.openai.com/) for updates.
{% endhint %}

For now, you can use bridge solutions like the [chatgpt-mcp server](https://github.com/xncbf/chatgpt-mcp) that enables MCP interaction through the ChatGPT macOS app:

```json
{
  "mcpServers": {
    "chatgpt-sling-bridge": {
      "command": "uvx",
      "args": ["chatgpt-mcp"],
      "env": {
        "SLING_MCP_COMMAND": "sling mcp",
        "SLING_CLI_TOKEN": "your-token-here"
      }
    }
  }
}
```

## Usage Examples

### Querying a Database

**Simple Analysis Prompt to AI Assistant:**

{% code overflow="wrap" %}

```
Use sling connection `postgres_prod` to query the sales table in my warehouse connection and show me the top 10 revenue generating products this month
```

{% endcode %}

The assistant will construct and execute:

{% code overflow="wrap" %}

```json
{
  "action": "query",
  "input": {
    "connection": "postgres_prod",
    "query": "SELECT product_id, SUM(revenue) as total_revenue FROM sales WHERE date >= '2025-01-01' GROUP BY product_id ORDER BY total_revenue DESC LIMIT 10"
  }
}

```

{% endcode %}

**Table Comparison Prompt to AI Assistant:**

{% code overflow="wrap" %}

```
Use sling in connection `snowflake_dw` to compare the tables: dbt_dev.core_transactions (dev table) and finance.core_transactions (prod table). Compare the counts and null counts as well as distinct counts.
```

{% endcode %}

The assistant will construct and execute multiple queries and return a summary.

### Discovering Database Tables

**Prompt to AI Assistant:**

{% code overflow="wrap" %}

```
Using Sling, show me all tables in my `postgres_rds` connection that start with "customer_"
```

{% endcode %}

The assistant will use:

```json
{
  "action": "discover",
  "input": {
    "connection": "postgres_rds",
    "pattern": "*.customer_*"
  }
}
```

### Copying Files Between Storage Systems

**Prompt to AI Assistant:**

{% code overflow="wrap" %}

```
Use sling to copy all CSV files from connection `aws_s3` folder "raw/2025/" to connection `AZURE_PROD` "processed/" folder
```

{% endcode %}

The assistant will execute:

```json
{
  "action": "copy",
  "input": {
    "source_location": "aws_s3/raw/2025/*.csv",
    "target_location": "azure_prod/processed/",
    "recursive": true
  }
}
```

## MCP Prompts

The Sling MCP server provides specialized prompts that guide AI assistants through complex API specification workflows. These prompts are pre-built conversation templates that help with creating, extending, and debugging API integrations.

### api\_spec\_create\_spec

Creates a complete Sling API specification from scratch by analyzing API documentation and building endpoints with authentication, pagination, and data extraction configuration.

**Arguments:**

| Argument          | Required | Description                                       |
| ----------------- | -------- | ------------------------------------------------- |
| `spec_name`       | Yes      | Name for the API specification (used as filename) |
| `spec_file_path`  | No       | Full file path for the spec file                  |
| `connection_name` | Yes      | Name for the API connection to create and test    |
| `api_docs_url`    | Yes      | URL to the API documentation website              |
| `endpoint_names`  | Yes      | Comma-separated list of endpoint names to include |
| `additional_info` | No       | Additional instructions or requirements           |

**Workflow:**

1. Fetches Sling API spec documentation
2. Analyzes the target API documentation (using browser if available)
3. Creates the specification file
4. Creates or uses existing connection
5. Tests and iterates until endpoints work correctly

### api\_spec\_add\_endpoint

Adds a new endpoint to an existing Sling API specification by analyzing endpoint documentation and implementing proper configuration.

**Arguments:**

| Argument            | Required | Description                                    |
| ------------------- | -------- | ---------------------------------------------- |
| `spec_file_path`    | Yes      | Full file path to the existing spec file       |
| `endpoint_name`     | Yes      | Name of the new endpoint to add                |
| `endpoint_docs_url` | No       | URL to the specific endpoint documentation     |
| `additional_info`   | No       | Additional instructions for the implementation |

**Workflow:**

1. Fetches Sling API spec documentation
2. Loads and parses the existing specification
3. Analyzes endpoint documentation
4. Implements the new endpoint following existing patterns
5. Tests until the endpoint returns data successfully

### api\_spec\_debug\_endpoint

Debugs and fixes issues with an existing endpoint in a Sling API specification by analyzing errors and adjusting configuration.

**Arguments:**

| Argument          | Required | Description                           |
| ----------------- | -------- | ------------------------------------- |
| `spec_file_path`  | Yes      | Full file path to the spec file       |
| `endpoint_name`   | Yes      | Name of the endpoint to debug and fix |
| `additional_info` | No       | Additional context about the issues   |

**Workflow:**

1. Fetches Sling API spec documentation
2. Loads and examines the current specification
3. Analyzes API documentation for verification
4. Tests and diagnoses issues
5. Fixes configuration and iterates until successful

**Common issues checked:**

* Authentication (token format, headers, auth type)
* URL construction (base URLs, parameter encoding)
* Data extraction (JMESPath expressions)
* Pagination (next page logic, stop conditions)
* Rate limiting (request rates, backoff strategies)

## Troubleshooting

### Log Locations

* **Claude Desktop**: `~/Library/Logs/Claude/` (macOS) or `%APPDATA%\Claude\logs\` (Windows)
* **Claude Code**: View logs with `claude mcp logs sling`
* **VSCode**: Use Command Palette > "MCP: Show Logs"

### Debug Output

Enable trace logging for detailed debugging:

```json
{
  "mcpServers": {
    "sling": {
      "command": "sling",
      "args": ["mcp"],
      "env": {
        "SLING_CLI_TOKEN": "your-token-here",
        "DEBUG": "TRACE"
      }
    }
  }
}
```

### Resources

* [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
* [Sling Environment Configuration](/sling-cli/environment.md)
* [Sling Replications Guide](/concepts/replication.md)
* [Sling Pipelines Guide](/concepts/pipeline.md)

{% hint style="success" %}
**Pro Tip:** Start with simple operations like listing connections and discovering tables before moving to complex replications and pipelines. This helps you understand how the AI assistant interacts with your data infrastructure.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.slingdata.io/sling-cli/ai/mcp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
