Connect Claude to MCP server

SupportedPython 3.12+Claude Agent SDKLearning series · Part 3MODEL_CALL + TOOL_CALL

Use the Claude Agent SDK’s supported in-process MCP server, limit a tool surface, and separate MCP tool discovery from runtime authorization.

Last updated

1. Learning objective

Configure an MCP server

Use the Claude Agent SDK’s supported in-process MCP server, limit a tool surface, and separate MCP tool discovery from runtime authorization.

  • Guide 2 concepts
  • Claude Agent SDK credential and model access

2. Technical context

Understand MCP authorization

MCP makes tools discoverable, but discovery is not authority. A client must explicitly decide which server and tools to trust, while the tool host remains responsible for execution.

3. Run without AIGP

Run MCP

Run the existing claude-agent-tool-intg lab. It creates an in-process MCP server containing only lookup_policy and disables Agent SDK built-in tools.

terminal · lab
cd labs/agent-frameworks/anthropic/claude-agent-tool-intg
python3 -m venv .venv && source .venv/bin/activate
python -m pip install -r requirements.txt
export ANTHROPIC_API_KEY=...
export CLAUDE_MODEL=...
python app.py

Configure MCP server

The existing lab creates one in-process MCP server, disables built-in tools, and approves only the application-owned policy tool.

agent.py · MCP configuration
policy_server = create_sdk_mcp_server(
    name="policy",
    version="1.0.0",
    tools=[lookup_policy],
)

ClaudeAgentOptions(
    tools=[],
    allowed_tools=[POLICY_TOOL_NAME],
    mcp_servers={"policy": policy_server},
    strict_mcp_config=True,
)

4. Configure AIGP

Configure AIGP tracking

Enable the existing optional runtime-evidence adapter. It observes the model and application tool lifecycle through public SDK hooks. It does not record MCP discovery requests, tool arguments, or tool results.

Privacy boundary: retain bounded identifiers, lifecycle, status, timing, digests, and references only. Do not submit prompts, responses, tool arguments/results, credentials, or raw SDK payloads.

Authenticate local AIGP requests

Obtain a short-lived token

If your local OSS stack uses Keycloak, the organization and project headers are scope selectors, not authentication. Generate a token from the generated local OAuth client and pass it only through AI_GOVERNANCE_ACCESS_TOKEN for this terminal session.

terminal · local Keycloak token
# Run from the OSS repository after its local Keycloak stack is ready.
cd /path/to/ai-governance-oss
./servers.sh up

# This ignored file contains the local walkthrough client credentials.
# It does not contain an access token.
set -a
source .env.oauth.generated
set +a

# Mint one short-lived token in memory for this terminal only.
export AI_GOVERNANCE_ACCESS_TOKEN="$(
  uv run python -c 'from ai_governance.oauth import access_token_from_environment; print(access_token_from_environment())'
)"

# Return to the Claude lab. Its .env supplies Claude and AIGP scope settings.
cd /path/to/labs/agent-frameworks/anthropic/claude-agent-tool-intg
set -a
source .env
set +a
python app.py

# Remove the in-memory token when the session is over.
unset AI_GOVERNANCE_ACCESS_TOKEN

Never commit, print, paste into a screenshot, or add the token to .env. For development-mode and production workload identities, see Developer Authentication.

5. Inspect execution evidence

Inspect MCP evidence

Inspect the Agent Executions timeline for the one TOOL_CALL. The evidence establishes that the instrumented application reported a tool result; it is not an authorization grant for arbitrary MCP tools.

Only use a Studio screenshot after a run has been completed and its route, tenant scope, and visible data have been verified. This guide does not substitute a conceptual image for product evidence.

Verified execution d716945e-f271-490d-bfae-97e6582bd10d. Studio records the reported tool-call lifecycle; the MCP configuration is shown above from the lab source.

6. Test failure handling

Test missing policies

Request a missing policy. The local MCP tool returns an application result. An unavailable AIGP evidence endpoint remains fail-open here because this guide has no protected mutation.

7. Technical boundaries

Understand MCP boundaries

  • The Agent SDK and application configure trusted MCP servers and allowed tools.
  • The MCP server owns its tool implementation and authentication boundary.
  • AIGP has no implicit MCP execution or discovery authority.

8. Next step

Track agent executions

This is a documented integration boundary, not an implicit AIGP feature. Continue only with the capabilities explicitly marked ready in the learning path.

Back to developer guides