Skip to content
Back to log

Adding a server to an MCP client

Chainabit's Chao · · 8 min read

In short

A local MCP server needs a command and an access scope. A remote server needs a URL and authentication details. Examples from Claude Desktop, Claude Code, and NEXUS show how these settings work.

What does a server entry define?

According to the Model Context Protocol, MCP servers can give AI applications access to tools and local resources. A local server is a program that runs on your computer. A remote server is hosted on the internet and can provide tools, prompts, and resources.

Adding a server to a client means configuring how the client connects to it. A stdio entry for the local NEXUS MCP server includes the command to run, optional arguments, and an environment field. The CLI you configure determines where the entry is stored on disk and what the top-level key is called.

Remote connections use a server address. The Model Context Protocol specifies that the server developer or administrator should provide the full URL, including the appropriate protocol and any required path segments. Authentication steps vary by server implementation.

Commands and access for local servers

In the Model Context Protocol example for Claude Desktop, the configuration is stored in a JSON file. This file specifies which servers the app should run and how to connect to them. Under Settings, open the Developer tab and select Edit Config. This opens the existing file or creates it if needed.

The file location depends on the operating system. For example, macOS uses ~/Library/Application Support/Claude/claude_desktop_config.json, and Windows uses %APPDATA%\Claude\claude_desktop_config.json. On Linux, the file is located at ~/.config/Claude/claude_desktop_config.json.

In the example, the top-level mcpServers key contains a server entry named filesystem. Claude Desktop displays the name filesystem. The command field uses npx to start the server, and the args array contains the server package and the directories it can access.

In the same example, -y automatically confirms installation of the server package. The package name is @modelcontextprotocol/server-filesystem. You can change the directory paths in args and add more directories to the array. The server runs with your account permissions. The Model Context Protocol advises granting access only to directories you want the server to read and modify.

The Filesystem Server can read file contents and directory structures, create files and directories, move and rename files, and search by name or content. In the Model Context Protocol example, file system operations require explicit user approval before they run. You can decline an operation request.

After saving the configuration, quit Claude Desktop completely and reopen it. Restarting the app starts the server and loads the updated configuration. Once connected, open Manage connectors from the Connectors menu in the message composer, then select filesystem to see the server's list of tools.

Addresses and authorization for remote servers

In the Model Context Protocol example for remote servers, open Connectors in the settings for Claude Desktop or Claude in your browser. From the Add menu, choose Add custom connector and enter the remote MCP server's URL. Then select Add to begin connecting.

Authentication can use OAuth, an API key, or a username and password. The server's authentication steps may redirect you to an external provider or display a form inside Claude. The flow depends on how the server implements authentication.

Once connected, you can access the server's resources and prompts from the Connectors menu in the message composer. The menu shows the available items and lets you choose which ones to add to the conversation. In the connected server's Connectors settings, you can enable or disable individual tools and configure usage limits and other security settings.

Adding a server in Claude Code

Claude Code shows the following basic command for adding a remote HTTP server.

claude mcp add --transport http <name> <url>

Claude Code recommends HTTP as the transport for connecting to remote MCP servers. If the server provides a token header along with its URL, you can use --header. Local stdio servers run as separate processes on your computer. Claude Code shows the following basic form for adding them.

claude mcp add [options] <name> -- <command> [args...]

Here, -- separates Claude Code's options from the command that starts the server and its arguments. Claude Code passes everything after -- to the server unchanged. You can supply environment variables with --env. Claude Code notes that if the server name comes immediately after --env, it treats the name as another key-value pair and rejects it. Insert another option between them, such as --transport stdio.

A server's setup instructions may be written for a different MCP client. Claude Code says you can still add the server using its URL, startup command, or mcpServers JSON block. A URL points to a remote server, while a startup command launches a local stdio process on your computer.

Turn this insight into action.

Use the mobile app to continue with guided workflows.

In the JSON configuration, the type field specifies the connection type. Claude Code also accepts streamable-http as an alias for http. If an entry with url omits type, Claude Code interprets it as a stdio entry and skips the server. Claude Code also notes that SSE transport is deprecated and recommends using HTTP servers where available.

Configuration scope

In Claude Code, a server's scope determines which projects load it and whether its configuration is shared with the team. The default scope is local. The server loads only in the project where you added it, and its configuration stays private to your user account. The entry is stored in ~/.claude.json under the project's path.

Servers in the project scope are stored in the .mcp.json file at the project root. Claude Code creates or updates the file when you add a server in this scope. You can share the file through version control. Servers in the user scope are also stored in ~/.claude.json. They are available across projects on the machine and stay private to your user account.

If the same server is defined in multiple scopes, Claude Code connects to it once using the highest-priority definition. The order of precedence is local, then project, then user. Claude Code uses the entire selected entry as-is, with no merging of fields across scopes.

In interactive sessions, Claude Code asks for approval before using project-scoped servers from .mcp.json. In some runs without an interactive terminal, Claude Code can't display the prompt and loads the servers without asking. According to Claude Code, adding a server to disabledMcpjsonServers blocks it in every permission mode.

Environment variables

Claude Code supports environment variables in .mcp.json. You can reference a variable in a server entry's command, args, env, url, or headers value. ${VAR} expands to the variable's value, and ${VAR:-default} uses default if the variable is unset.

If a referenced variable is unset and has no default, the configuration still loads. Claude Code shows a missing-variable warning for that server in the claude mcp list output and uses the unexpanded ${VAR} text. For remote servers, Claude Code treats some credential variables in url and headers as empty without issuing a warning.

Claude Code considers a variable set if it has been assigned an empty string. In that case, ${VAR:-default} expands to the empty string and bypasses the default. If the remote server's address fails to resolve to a valid URL, claude mcp list may show a URL error.

The local server entry for NEXUS

NEXUS specifies that a CLI coding agent needs a stdio server entry in the CLI's own configuration to call canvas_* and agent_* tools through nexus-mcp. Running the CLI in a NEXUS pane gives it a shell. The MCP connection still requires the server entry. If the agent can do everything it needs with shell commands, it can skip this setup.

In the NEXUS example, the server is named nexus. The command field contains the path to the NEXUS MCP launcher, and args and env are left empty. The CLI determines the top-level key name and where the entry belongs in the file. NEXUS handles authorization in the supported local connection flow, so you can leave the capability token out of the client or provider configuration.

NEXUS automatically writes the entry when it detects certain hosted CLIs that have been enabled in AI Providers. Each supported provider has a NEXUS MCP server toggle, a Connected or Not Connected status, and a Reconnect action. Turning off the provider or its MCP toggle removes the entry NEXUS wrote. If you delete the entry, NEXUS adds it again the next time it starts.

Verifying the connection and understanding its limits

Once the entry is in place, NEXUS instructs you to start the CLI, make a discovery call, and then call tools/list. Discovery verifies the local executable and the protocol. The tools/list call also tests the connection to the running application.

Individual tool calls still have their own authorization requirements after the connection succeeds. According to NEXUS, no role is granted by default, so a canvas tool call can fail if its requirements are unmet even when the connection works.

If the server doesn't appear in the Model Context Protocol example for Claude Desktop, troubleshooting steps include fully restarting the app and checking the JSON syntax and file paths. Paths must be valid and absolute. General logs for MCP connections and connection errors are stored in mcp.log, and each server's log file contains its stderr output. Stdio servers may use stderr for all logging, so these files can contain routine messages as well as errors.

Ready to start?

Download the app and continue from your phone.

End of Entry