PUBLIC BETA OFFER

Save 50% off on an Eligible Learning PlanValid for 1-month plan, 3-month plan, 12-month plan · Code LPXBETA50 · Ends Dec 6, 2026

Integrate MCP servers into Claude Code and agent workflows

Configure MCP scope, transport, credentials, and discovery, then verify the intended read path.

Explore project, user, and local MCP configuration and the responsibilities of an API adapter. A shared documentation integration shows how credential references, resource catalogs, and known-answer reads establish a narrowly scoped access result.

Knowledge domain
Tool Design & MCP Integration
Topics & tags
Published
Author
LearningPathX Editorial TeamContent version 1.0
Resources

Integrate MCP servers into Claude Code and agent workflows

Learning objectives

By the end of this topic, you should be able to:

  • Choose project, user or local configuration scope for an MCP integration.
  • Separate configuration, connection, discovery and authorized execution.
  • Reference credentials through the supported environment mechanism without committing secret values.
  • Use resources and clear tool descriptions to expose relevant information efficiently.

Choose scope before adding a server

A project-scoped .mcp.json can share a reviewed server definition with a team through version control. A user-scoped definition is appropriate for personal tools intended across projects. Local scope is tied to the current project for that user rather than being a shared repository definition.

The supplied Claude Code material locates project definitions in .mcp.json and user/local records in the user's configuration, described as ~/.claude.json. Its scope list gives local, project and user as the precedence order, but its personal-override examples conflict with that list; establish the actual client and resolved entry rather than treating this as one unqualified rule. The same source describes enterprise managed configuration as overriding local settings; choosing a user scope does not bypass organization controls. Inspect the effective configuration when names collide; "personal" is not a substitute for identifying the actual scope.

For the supplied CLI scope model, choose the scope explicitly when adding a server:

Scope argument Configuration location Where it applies and who receives it
--scope project Project .mcp.json Current project; share the reviewed definition through version control
--scope user User ~/.claude.json That user's projects; not distributed to teammates
--scope local Project-specific record in user ~/.claude.json This project for this user; not a team-shared definition

The materials describe local scope as the default when a scope argument is omitted. Omitting --scope user therefore does not establish a personal integration across all projects. Inspect the effective scope after configuration; the table specifies scope arguments rather than a complete server-installation command.

Sharing a reviewed definition that contains only non-secret settings and approved credential references does not distribute the referenced secret values; sharing a definition that contains literal secrets can expose them. Sharing configuration does not by itself authorize sharing or using credentials or approve every operation. A repository can describe a service without granting all contributors access to its data. Review project configuration before enabling it, and check how approval works in the actual interactive or non-interactive environment rather than assuming every launch shows the same prompts.

Keep credentials out of versioned configuration

Use supported environment expansion for values that differ by machine or account. This illustrative .mcp.json fragment uses an intentionally non-working example endpoint:

{
  "mcpServers": {
    "docs-service": {
      "type": "http",
      "url": "https://docs.example.invalid/mcp",
      "headers": {
        "Authorization": "Bearer ${DOCS_TOKEN}"
      }
    }
  }
}

The literal ${DOCS_TOKEN} is a configuration reference, not a real credential. The actual value must be provided through the approved environment or secret mechanism available to the process launching the client. An IDE or background service may not inherit the variables set in a different terminal.

The source describes ${VAR} and default forms such as ${VAR:-default} in supported fields. Use defaults for suitable non-secret settings, not an invented credential. Detect missing or unresolved values before relying on authentication. Do not print the secret while diagnosing whether it is present or commit it merely to make a connection work.

In the adopted materials, glossary entries govern terminology, while the Dxx domain files remain the primary factual source when claims conflict. A glossary description of structured JSON does not replace the actual client's parsing, scope resolution, credential-delivery and authentication checks.

Match the server entry to its transport

A local stdio server is launched as a process with a command, arguments and environment. A remote integration needs the transport and endpoint supported by the selected client and server. Do not assume that an arbitrary URL or a configuration copied from another application has the correct shape.

Check the effective server name, executable or endpoint, transport, process environment and authentication. For stdio, protocol output and diagnostic logs need appropriate channels; a process waiting for a client is not necessarily hung. For a remote endpoint, distinguish connectivity from authorized tool access.

The source includes CLI management commands such as claude mcp get <name> and claude mcp list. Use the installed CLI's supported syntax and inspect status. A recognized configuration is not proof that a representative authorized request succeeded. Test a harmless known-answer operation before depending on the integration. CLI expands to Command Line Interface in the adopted terminology; that name does not validate a particular installed command or payload signature.

Understand discovery and adapter responsibilities

An MCP host maintains client connections to servers and discovers their advertised capabilities. Tools are listed with tools/list and invoked with tools/call. Available tools can change, so handle updates and reconnects without assuming a startup list remains permanent. The adopted MCP account specifically supports notifications when the advertised tool list changes. A notification is a reason to refresh actual relevant capability state, not proof the new definition is connected, permitted or already executed.

Availability does not require every tool definition to be loaded into the model context at once. A host may defer tool schemas and discover relevant capabilities on demand. Conversely, a configured but disconnected or unauthorized server is not a usable capability merely because its name is visible. MCP expands to Model Context Protocol. The source client account describes default deferred schemas with only names/server instructions initially loaded, and no fixed per-server tool cap. Those claims are client-snapshot behavior, not a universal protocol guarantee; actual definitions, resource payloads, discovery and results still consume the task’s context budget.

A raw Messages API application does not automatically read a Claude Code .mcp.json file. Its harness must connect the MCP client, obtain tools, convert the relevant schemas and results, and manage the model/tool loop. Native MCP field names and API tool-definition fields belong to their respective contracts; adapter compatibility is an explicit integration responsibility.

Use resources as a catalog rather than a data dump

MCP resources can expose document catalogs, issue summaries or database schemas using stable URIs. A small catalog can tell an agent what information exists before it performs a broad search. Listing the catalog and reading a selected resource are still operations with access and context costs.

A resource description can include a name, content type and annotations such as intended audience, priority and last-modified information. The source describes audience values user and assistant, and priority on a zero-to-one scale. Treat these as context-selection metadata, not access-control guarantees or proof of freshness.

The host decides how resources are presented or included. A high priority does not guarantee automatic loading in every client, and an assistant audience label does not grant permission to retrieve private data. Filter appropriately, then load only the material needed for the question. A complete catalog is not the same as complete access to every underlying document.

Make specialized tools discoverable and appropriate

A specialized issue search or database query can answer a question that local Grep cannot, especially when the relevant information lives outside the repository or needs structured filtering. Explain those distinctions in the MCP tool's description, including inputs, outputs and scope.

Tool annotations can disclose whether an operation requires open-world access or may make destructive changes. In an invented read-only review restricted to local files, an external-search operation disclosed as needing open-world access and a record-deletion operation disclosed as destructive are both out of scope; do not dispatch them without the separately required authorization. These tool disclosures guide selection and differ from a resource's audience, priority and lastModified hints. An annotation does not enforce authorization or prove execution; inspect the actual supported tool contract and trusted execution policy.

Prefer the capability that fits the task and approved environment. A simple local text search may be served well by a built-in tool; a structured external issue query may need its dedicated integration. Neither "always use MCP" nor "always use a CLI" follows from context overhead alone.

Inspect actual tool selections, parameter failures and result quality. Correct overlapping descriptions and disable unnecessary integrations where appropriate. Do not generalize a benchmark percentage into a guarantee that every integration becomes faster or more accurate.

Evaluate an existing server before building one

For a standard integration, evaluate an existing implementation first. Check maintenance, supported features, authentication, permission scope and compatibility with the required workflow. Being a community server is not by itself evidence of security or suitability. More specifically, the source distinguishes Anthropic’s connector-directory review from individual user-configured MCP servers, which that account says Anthropic does not security-audit or manage. Directory presence, community authorship or writing a server yourself cannot substitute for the actual trust, compatibility and policy assessment.

A custom server is justified when the team needs operations, constraints or data handling that suitable existing integrations cannot supply. Define the smallest required interface and maintain its lifecycle. Avoid installing a package merely because an illustrative name appears in a document; verify the actual implementation selected for deployment.

Worked example: a shared documentation integration

In this invented team workflow, the approved documentation service exposes a small catalog and a read-only document loader. The shared repository contains the reviewed server definition; each authorized user supplies their own token through the approved mechanism.

Check Supported conclusion
The project entry parses and has the intended transport. The configuration is structurally readable.
The process receives its credential reference correctly. Authentication can be attempted; access is not yet proven.
The connection and catalog request succeed. The authorized catalog is available.
A known-answer load returns DOC-R7 with the expected version and passage. This user's tested read path works for DOC-R7.

The catalog can identify DOC-R7 as "Release guide, revision 2" and provide a resolvable resource URI. A worker requesting a release rule then loads the relevant passage instead of guessing from the title. If DOC-R8 is restricted, the result remains denied even though the catalog lists it.

A supported operator note is: "The read path was checked for DOC-R7 under this account. Other documents and write operations were not validated." For this teaching example, those are expected verification stages; no actual service connection or credential use occurred.

Retain configuration uncertainty and verify the installed contract

The scope list in this source snapshot says Local > Project > User > plugin > connector and selects one whole winning entry without merging fields. Its Desktop Code-tab example and later conflict paragraph instead say a personal User definition wins over Project. Those statements conflict; sharing ~/.claude.json storage does not make Local and User the same scope. Establish the actual client, resolved source and complete entry before claiming a winner or removing an override. The source's managed enterprise override statement does not resolve this User/Project inconsistency.

claude mcp add and add-json examples must be adapted to the installed command contract: actual server name, scope, accepted entry/map/wrapper payload and transport matter. The source describes importing the content inside mcpServers, adding a supported URL type (http, sse or ws) and using letters/numbers/hyphens/underscores for server names. These are snapshot details, not a tested universal signature. Inspect the actual supported command before using a named-map example; copying a placeholder or a different client's wrapper does not establish recognition or connection. For example, the original source quotes the unexecuted shell form claude mcp add-json '{"secure-api":{"type":"http","url":"https://api.example.com/mcp","headers":{"Authorization":"Bearer ${API_AUTH_TOKEN}"}}}' --scope project. Its quoted named-map payload, flag placement and reference expansion must be checked against the installed CLI; this source illustration is not a verified accepted signature or a live connection. It differs from the complete outer mcpServers file wrapper above.

The source distinguishes interactive project-server trust approval and claude mcp reset-project-choices from headless claude -p, SDK/cloud and bypassPermissions with skipDangerousModePermissionPrompt loading. These claims are interface-specific. A configuration loading without a prompt does not grant authentication or operation authorization. For a private experiment, first identify whether all-project User or one-project Local is intended; inspect effective entry/status and actual use before disabling it through supported management such as /mcp. A filename alone cannot identify which private binding would change. The source also names /context to inspect actual prompt-space use alongside /mcp server management. Inspect the real entry, active use and observed context before changing a needed integration; neither command by itself proves connection health or completed execution.

Work through expansion and authentication cases

In the source expansion contract, ${VAR} uses the actual launching environment value. ${VAR:-default} uses a non-sensitive fallback if VAR is absent or empty. Thus with REGION=west, ${REGION:-east} yields west; with an empty or absent REGION it yields east. No credential fallback should be invented to make production authentication appear valid.

The source says an absent direct reference with no fallback leaves literal ${VAR}, emits a server-specific warning in claude mcp list and still allows configuration loading. Preserve that as a scoped client behavior, not evidence of valid credentials. An empty secret, an absent secret, an invalid nonempty secret, a placeholder in an unsupported field and an unavailable endpoint need distinct diagnoses. For the docs example above, a required nonempty DOCS_TOKEN enables an authentication attempt; empty or absent values leave credential delivery unresolved, and successful delivery still may produce a separate service/authentication denial. Inspect redacted status without printing actual secret bytes.

The listed expansion locations are stdio command, args, env and HTTP url, headers. The source GitHub example supplies GITHUB_TOKEN via process env; the HTTP example sends an Authorization Bearer reference. These are different delivery mechanisms. Unix export and PowerShell $env:NAME assignments affect the relevant shell/child launch environment, not every already running IDE or service. Set approved values through the real launch/secret mechanism and check actual state. The original HTTP entry is named secure-api, with type:"http", url:"https://api.example.com/mcp" and Authorization:"Bearer ${API_AUTH_TOKEN}"; claude mcp get secure-api is its source recognition/status example. Neither the example host nor any actual token or service result is verified here. The source shell placeholders are export GITHUB_TOKEN="ghp_your_actual_token_here" for a Unix-like shell and $env:GITHUB_TOKEN = "ghp_your_actual_token_here" for PowerShell. They are unexecuted illustrative syntax, not real secret values, persistent configuration for every process or permission to connect.

“Incompatible auth server: does not support dynamic client registration” calls for inspection of supported OAuth registration/authentication. A preconfigured app may be needed under the server's actual policy. Client ID, client secret, access token and endpoint are different values; a generic suggestion to use headers/args does not establish that arbitrary secret transport is correct or authorized. Follow the actual client/server app registration and secret-reference path.

Make catalog-to-context delivery concrete

One invented catalog record is {"uri":"docs://release/R7","name":"Release guide, revision 2","mimeType":"text/plain","annotations":{"audience":["assistant"],"priority":0.8,"lastModified":"2026-09-01T12:00:00Z"}}. The custom docs: URI is illustrative and needs a real supporting resolver in an implementation. The authorized host selects this resource, actually reads its value and validates the result. A teaching content value is {"uri":"docs://release/R7","text":"Revision 2: release review requires owner approval.","source_id":"DOC-R7","revision":2}. The expected consumer context includes that text with source/revision; it does not substitute the catalog title for the rule. A restricted R8 resource remains denied even if cataloged. These are expected fixtures, not observed reads.

audience values user/assistant, priority 0–1 and ISO lastModified are optional selection hints. They do not grant access, mandate model inclusion or prove currentness/correctness. Preserve source identity, actual errors and incomplete/truncated content. Budget the real resource payload tokens; deferring tool definitions does not defer already included resource text. A concise catalog may avoid repeated exploratory calls, but discovery, read, conversion and inclusion still cost work and context. Under the stated numeric 0–1 annotation contract, 0 and 1 are valid boundary values; -0.1, 1.1, true, null and "0.8" do not satisfy it. Omitted optional priority is absent, not an inferred zero. These are expected metadata-validation judgments; the actual host determines whether invalid metadata is rejected or omitted, and invalid priority cannot confer access.

The source mcp_resource_to_content/mcp_resource_to_file listing only imports helpers; imports perform no listing, selection, read, conversion or message inclusion. Its anthropic[mcp]/Python3.10+ statements belong to that library snapshot. Obtain actual permitted values and use the supported helper/result path before claiming model access.

Per-server clients maintain their own connections and tools/list/tools/call capability state. The source SDK setMcpServers replacement account makes newly connected tools available on the next turn, while strictMcpConfig can limit the supplied set. After a change, refresh actual listings/policy; do not invoke a removed or merely declared tool from stale state.

FastMCP @mcp.resource exposes read-only URI context, including parameterized resource templates. FastMCP @mcp.tool exposes a callable function interface from signature/documentation with supported input validation. Agent SDK @tool/create_sdk_mcp_server is a different in-process tool interface. Similar names do not make these decorators interchangeable, and structural validation does not establish business truth or permission.

Interpret integration costs and diagnostics

Quiet stdio may be waiting for protocol input, but silence alone cannot distinguish waiting from a crashed, hung or unconnected process. Inspect actual process/transport, handshake, status and capability response; a visible entry is not a working connection.

The source reports a 40% completion-time decrease from repeated description refinement and a Sonnet3.5 SWE-bench Verified example. Keep their historical model/workload attribution and unknown timing/evaluation details; neither proves a local gain. Compare CLI and MCP on equivalent accepted tasks, including definition listings, command help, resource payloads, results, latency, retries, permissions and operator effort separately. Absence of a CLI per-tool listing and deferred MCP schemas describe one phase, not universal total-cost superiority or zero overhead. Use the actual authorized capability that fits the required data and operation. That reported refinement workflow uses a tool-testing agent to attempt a flawed tool dozens of times and revise its description from observed failures. The source also recommends a small prototype with relevant MCP/SDK/library documentation, potentially an llms.txt source. These are proposed/scenario methods here, not trials or a causal timing gain measured in this project.

Summary

MCP integration combines scope, transport, credentials, discovery and result handling. Shared configuration improves consistency without sharing authorization. Use concise catalogs and distinctive tool contracts, then verify the actual account and operation rather than treating registration or visibility as successful access.

PUBLIC BETA OFFER

Save 50% off on an Eligible Learning Plan

Valid for 1-month plan, 3-month plan, 12-month plan · Code LPXBETA50 · Ends Dec 6, 2026