measuremy.site

Adding an MCP server to Claude Code

View of a computer monitor displaying green digital security code in an indoor setting.
Photo by Tima Miroshnichenko on Pexels

What you need before you start

Claude Code manages MCP servers through commands in the terminal. You do not need to edit a config file for most cases, although project scope may create one. Before you start, have the server's connection details ready.

Choose the right scope

Claude Code can add a server at different scopes. The right choice depends on whether the server should be available everywhere or only in one project.

Check Claude Code's current documentation for the exact flags and behavior in your version.

Add a local server

If the MCP server runs as a local command, such as a small script or CLI tool, you add it with the standard MCP add command. The important parts are the server name, the transport type, the scope, and the command that starts the server.

claude mcp add my-server --transport stdio --scope user -- my-command --flag

Replace my-server with a name you will recognise, and replace my-command --flag with the command your server provider supplied. The --transport stdio part tells Claude Code that the server is a local process.

Add a hosted server

If the server is hosted, you will usually add it with a URL and a remote transport type such as SSE or HTTP. Use the URL exactly as your provider gives it to you. Do not paste the URL into a normal chat prompt and ask Claude Code to guess the setup; use the MCP management command instead.

The command follows the same pattern as a local server, but the transport is remote and the final argument is the provider's URL. Some providers give you a one-sentence instruction that includes the full command, which is the easiest way to avoid transport or scope mistakes.

Authenticate if required

Some hosted MCP servers use OAuth instead of an API key. After you add the server and restart Claude Code, a browser window may open for sign-in. Once you approve the sign-in, the connection is active without copying a key into your config.

A hosted analytics MCP server may work this way. For example, measuremy.site uses browser sign-in and no API key, so one sign-in can cover all your sites. If your server uses OAuth, keep the browser session available during setup.

Test the connection

After adding a server, restart Claude Code. Then check that the server is listed and shows as connected.

claude mcp list

If the server does not appear, check the scope you used. A server added at project scope will not show up when you run Claude Code from a different directory. A server added at user scope should be visible across projects.

Use the tools in a project

Once the server is connected, you can ask Claude Code to use its tools in normal language. You do not need to call the server directly or write HTTP requests. For an analytics server, you might ask for the top pages this week, a funnel report, or a list of campaign links.

The agent decides which tools to call and reads the results for you. If the server offers multiple tools, start with a small request to confirm the connection works before asking for a large report.

Troubleshooting common problems

Keep credentials out of shared files

If you use project scope for a server that needs an API key, be careful not to commit secrets into a project config file that other people can read. Prefer OAuth where it is offered, or use user scope for private credentials. This is a general security practice, not a rule about any specific server.

Adding an MCP server to Claude Code is mostly a matter of choosing a scope, running one management command, restarting, and confirming the connection. Once that is done, the server's tools become part of your normal workflow in the terminal. Start with a small, specific request after setup so you can see whether the server is returning data before you rely on it for decisions.

See it on your own site

measuremy.site is cookieless analytics your coding agent can read. 30-day free trial, no card. Plans from $9/month.

Start free trial See the live demo

Add measuremy.site analytics to this project: connect the measuremy.site MCP server at https://a.measuremy.site/mcp for all my projects (claude mcp add --scope user; it signs in with OAuth, no key, and one sign-in covers every site), then tell me how to sign in. Details: measuremy.site/llms.txt

Free tools

All free tools

More from the blog