# MCP Server Config

Tabnine CLI supports [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) servers, which extend 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
```

### See Also

* [Commands](/main/getting-started/tabnine-cli/features/commands.md)
* [Settings](/main/getting-started/tabnine-cli/features/settings.md)


---

# 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.tabnine.com/main/getting-started/tabnine-cli/features/mcp-server-config.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.
