Blog·June 22, 2026

How to Add MCP to Claude Code

Claude CodeMCPAI coding agentsagentic search

Claude Code is useful because it can work inside your project: read files, edit code, run commands, and iterate with you.

MCP is how you give it tools outside the repo.

The Model Context Protocol turns external systems into tools Claude Code can call during a session. That can mean a database, an issue tracker, a monitoring system, a browser automation tool, or a search layer like Ninelayer.

This guide shows the practical setup path for a remote MCP server.

The Short Version

For a hosted MCP server, Claude Code supports remote HTTP servers. Add one with:

claude mcp add --transport http ninelayer https://mcp.ninelayer.in/mcp \
  --header "Authorization: Bearer $NINELAYER_API_TOKEN"

Then open Claude Code and run:

/mcp

You should see the server, connection status, and available tools.

For Ninelayer, the important tools are:

  • ninelayer_deep_search
  • ninelayer_get_url
  • academic_search

Option 1: Add MCP with the Claude CLI

Use the CLI when the integration is personal to your machine.

export NINELAYER_API_TOKEN="your-token"

claude mcp add --transport http ninelayer https://mcp.ninelayer.in/mcp \
  --header "Authorization: Bearer $NINELAYER_API_TOKEN"

This is the lowest-friction path for one developer.

It also keeps the token out of your repository.

Option 2: Add Project-Level MCP with .mcp.json

Use a project-level .mcp.json when every developer in the repo should see the same server name and endpoint.

Create .mcp.json at the project root:

{
  "mcpServers": {
    "ninelayer": {
      "type": "http",
      "url": "https://mcp.ninelayer.in/mcp",
      "headers": {
        "Authorization": "Bearer ${NINELAYER_API_TOKEN}"
      }
    }
  }
}

Then each developer sets their own token:

export NINELAYER_API_TOKEN="your-token"

This gives the team a shared integration without committing credentials.

Choosing the Right Scope

Claude Code supports multiple MCP configuration scopes.

Use local scope when:

  • you are experimenting
  • the server is private to your machine
  • the integration contains personal credentials

Use project scope when:

  • everyone in the repo should use the same tool name
  • the server is part of the development workflow
  • credentials can be supplied through environment variables

Use user scope when:

  • you want the same server across many projects
  • the tool is part of your personal agent setup

For search, project scope often works well because prompts can reference the same tool name across the team.

Verify the Server

After adding the server, start Claude Code in the project and run:

/mcp

Then ask for a small, explicit tool call:

Use the ninelayer MCP server to search for the current official Next.js App Router cache docs. Return the source URLs before answering.

The goal is not just to see that the server is connected.

The goal is to confirm Claude can discover and use the right tool before it edits anything.

A Better Prompt Pattern

For coding tasks that depend on fresh documentation, make retrieval a required first step:

Before editing files, use ninelayer_deep_search to find current official docs.

Task:
Update this authentication route to the current SDK pattern.

Search requirements:
- prefer official docs
- include source URLs in your reasoning summary
- ignore stale tutorials unless they explain a current migration issue

Only edit files after the search result confirms the API.

That small prompt turns MCP from a decorative integration into part of the engineering workflow.

Common Mistakes

Committing real tokens. Use environment variables in .mcp.json.

Using project scope for personal servers. If the server is not useful to the whole team, keep it local.

Adding too many tools at once. Claude Code works best when the relevant tools are easy to discover.

Letting search happen after the edit. If the task depends on current docs, search should happen before code generation.

Where Ninelayer Fits

Ninelayer is a remote MCP search server for AI agents.

Instead of giving Claude Code raw search snippets or noisy HTML, it returns compact, source-aware evidence that is easier to use inside an edit-test loop.

Use it when Claude Code needs current technical context:

  • SDK migrations
  • framework breaking changes
  • package errors
  • GitHub issue research
  • documentation lookups
  • RAG and retrieval debugging

Claude Code gives you the coding agent.

MCP gives it tools.

Ninelayer gives it a cleaner search layer.

Sources

  1. Claude Code docs: Connect Claude Code to tools via MCP
  2. Model Context Protocol: Introduction to MCP
← Back to Blog