> For the complete documentation index, see [llms.txt](https://docs.tabnine.com/main/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tabnine.com/main/getting-started/tabnine-agent/mcp-intro-and-setup/mcp-server-config.md).

# MCP Server Config

Tabnine IDE and Tabnine CLI support. [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) servers. This extends the CLI with additional tools and context providers. MCP servers are configured in `settings.json` and managed with the `tabnine mcp` CLI commands or the `/mcp` slash command in interactive mode.

## Configuration File Location

MCP server configurations live in the `mcpServers` key of `settings.json`. The CLI loads settings from multiple scopes, merged in this precedence order (highest wins last):

| Priority    | Scope           | Path (macOS/Linux)                                                                                          |
| ----------- | --------------- | ----------------------------------------------------------------------------------------------------------- |
| 1           | Schema defaults | Built-in                                                                                                    |
| 2           | System defaults | Sibling to system settings                                                                                  |
| 3           | User            | `~/.tabnine/agent/settings.json`                                                                            |
| 4           | Workspace       | `<project>/.tabnine/agent/settings.json`                                                                    |
| 5 (highest) | System          | `/Library/Application Support/TabnineCli/settings.json` (macOS) or `/etc/tabnine-cli/settings.json` (Linux) |

MCP servers use a **shallow merge** strategy: workspace-level servers merge with (not replace) user-level servers. If the same server name exists in both scopes, the higher-priority scope wins.

Workspace settings are only loaded if the workspace is trusted.

## Configuration Format

### Stdio Transport (Local Process)

```json
{
  "mcpServers": {
    "server-name": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/dir"],
      "env": {
        "TOKEN": "your-token"
      },
      "cwd": "/optional/working/directory",
      "timeout": 30000
    }
  }
}
```

### HTTP/SSE Transport (Remote Server)

```json
{
  "mcpServers": {
    "remote-server": {
      "url": "https://example.com/mcp",
      "type": "http",
      "headers": {
        "Authorization": "Bearer your-token"
      }
    }
  }
}
```

When `type` is omitted, the CLI tries Streamable HTTP first and falls back to SSE automatically if the HTTP connection fails. Set `type` explicitly to `"sse"` or `"http"` to skip auto-detection.

### Configuration Fields

| Field          | Type                             | Description                                                                                              |
| -------------- | -------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `command`      | `string`                         | Executable to run for stdio transport.                                                                   |
| `args`         | `string[]`                       | Arguments passed to the stdio command.                                                                   |
| `env`          | `object`                         | Environment variables set for the server process.                                                        |
| `cwd`          | `string`                         | Working directory for the server process.                                                                |
| `url`          | `string`                         | URL for SSE or HTTP transport.                                                                           |
| `type`         | `"stdio"` \| `"sse"` \| `"http"` | Transport type. Defaults to `"http"` when `url` is set.                                                  |
| `headers`      | `object`                         | HTTP headers sent to the server (useful for authentication).                                             |
| `timeout`      | `number`                         | Request timeout in milliseconds. Defaults to 600000 (10 minutes).                                        |
| `trust`        | `boolean`                        | When `true` and the workspace is trusted, tools from this server are auto-approved without confirmation. |
| `description`  | `string`                         | Human-readable description of the server.                                                                |
| `includeTools` | `string[]`                       | Allowlist of tools to enable. When omitted, all tools are enabled.                                       |
| `excludeTools` | `string[]`                       | Tools to disable even if exposed by the server.                                                          |

## MCP Management Commands

### Adding a Server

```bash
tabnine mcp add <name> <commandOrUrl> [args...]
```

| Flag                      | Description                                          |
| ------------------------- | ---------------------------------------------------- |
| `-s, --scope`             | `"user"` or `"project"` (default: `"project"`)       |
| `-t, --transport, --type` | `"stdio"`, `"sse"`, or `"http"` (default: `"stdio"`) |
| `-e, --env`               | Environment variables as `KEY=value` (repeatable)    |
| `-H, --header`            | HTTP headers as `"Key: value"` (repeatable)          |
| `--timeout`               | Connection timeout in milliseconds                   |
| `--trust`                 | Bypass all tool call confirmation prompts            |
| `--description`           | Server description                                   |
| `--include-tools`         | Comma-separated tool allowlist                       |
| `--exclude-tools`         | Comma-separated tool blocklist                       |

***Example:***

```bash
tabnine mcp add filesystem npx -y @modelcontextprotocol/server-filesystem /path/to/dir --scope user
```

### Listing Servers

```bash
tabnine mcp list
```

Status indicators: `✓` Connected, `✗` Disconnected, `⛔` Blocked, `○` Disabled.

### Enabling and Disabling Servers

```bash
tabnine mcp enable <name>
tabnine mcp disable <name>
```

Both accept a `--session` flag for session-only changes. Persistent enablement state is stored in `~/.tabnine/agent/mcp-server-enablement.json`, separate from the server configuration. Servers are enabled by default.

### Removing a Server

```bash
tabnine mcp remove <name>
```

Accepts `--scope` (`"user"` or `"project"`, default: `"project"`).

## Interactive Mode: `/mcp` Slash Command

In interactive mode, the `/mcp` slash command provides these subcommands:

| Subcommand | Aliases        | Description                                    |
| ---------- | -------------- | ---------------------------------------------- |
| `list`     | `ls`, `nodesc` | List configured MCP servers and tools          |
| `desc`     | `description`  | List servers and tools with descriptions       |
| `schema`   | —              | List servers, tools, descriptions, and schemas |
| `auth`     | —              | Authenticate with an OAuth-enabled MCP server  |
| `reload`   | `refresh`      | Reload MCP servers                             |
| `enable`   | —              | Enable a disabled MCP server                   |
| `disable`  | —              | Disable an MCP server                          |

Running `/mcp` with no subcommand defaults to `list`.

## Runtime Flags

### Filtering MCP Servers

```bash
tabnine --allowed-mcp-server-names server1,server2
```

When this flag is set, only the named servers are loaded. The comma-separated format and space-separated format are both accepted.

## Examples

### Filesystem Server

```json
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user/projects"]
    }
  }
}
```

### GitHub Server

```json
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
      }
    }
  }
}
```

### Remote HTTP Server with Authentication

```json
{
  "mcpServers": {
    "custom-api": {
      "url": "https://my-api.example.com/mcp",
      "type": "http",
      "headers": {
        "Authorization": "Bearer my-token"
      },
      "trust": true
    }
  }
}
```

## Troubleshooting

Verify your servers are configured and reachable:

```bash
tabnine mcp list
```

For detailed connection diagnostics, start the CLI with debug logging:

```bash
tabnine --debug
```

### **Using Environment Variables in MCP Server Configuration**

MCP server configurations in `.tabnine/mcp_servers.json` support environment variable interpolation, so you can reference secrets and tokens stored in your OS environment instead of hardcoding them into config files.

#### **Supported Syntax**

| Syntax             | Example              | Resolves to                        |
| ------------------ | -------------------- | ---------------------------------- |
| `$VARIABLE_NAME`   | `$SONARQUBE_TOKEN`   | Value of `SONARQUBE_TOKEN` env var |
| `${VARIABLE_NAME}` | `${SONARQUBE_TOKEN}` | Value of `SONARQUBE_TOKEN` env var |

On Windows, `%VARIABLE_NAME%` is also supported. Both `$VAR` and `${VAR}` syntaxes are equivalent and follow POSIX/Bash conventions via `dotenv-expand`.

{% hint style="info" %}
The `${env:VAR_NAME}` syntax used by some other tools is not supported.
{% endhint %}

Environment variables are resolved in the following fields:

* `env` values in stdio transport configurations (environment variables passed to child processes)
* `requestInit.headers` values in SSE and Streamable-HTTP transport configurations

Other fields such as `url`, `command`, `args`, and `cwd` are passed through as-is and do not undergo interpolation.

Variables are resolved at connection time, not when the config file is loaded. If you update an environment variable, the new value takes effect the next time the MCP server connection is established.

If a referenced environment variable is not set, it is replaced with an empty string. No warning is displayed.

The following configuration uses environment variable interpolation for both SSE header authentication and stdio environment variables:

```json
{
  "mcpServers": {
    "sonarqube-mcp": {
      "url": "https://sonar.example.com/api",
      "requestInit": {
        "headers": {
          "Authorization": "Bearer ${SONARQUBE_TOKEN}"
        }
      }
    },
    "gitlab-mcp": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-gitlab"],
      "env": {
        "GITLAB_PERSONAL_ACCESS_TOKEN": "${MY_GITLAB_TOKEN}",
        "GITLAB_API_URL": "https://gitlab.example.com/api/v4"
      }
    }
  }
}
```

Multiple placeholders and literal text can be combined in a single value. For example, `"Bearer ${TOKEN}"` resolves to `"Bearer sk-abc123"`. This feature is supported in VS Code and JetBrains. The CLI has built-in environment variable expansion.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.tabnine.com/main/getting-started/tabnine-agent/mcp-intro-and-setup/mcp-server-config.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
