Skip to main content
The Caylex Navigator is a remote Model Context Protocol (MCP) server that exposes a compact set of meta-tools to Claude. You can connect it to Anthropic’s Messages API in three ways:

FastMCP client

Recommended. Keep your existing Messages API loop and control exactly when MCP tools are refreshed.

Anthropic tool runner

Let Anthropic’s Python SDK run the tool-use loop while your application owns the MCP connection.

Hosted MCP connector

The shortest integration, but Anthropic may cache MCP tool definitions across requests and chats.

Which approach should I use?

  • Use the FastMCP client if you already have a custom agent harness or need fresh tool definitions after users authenticate. This is the recommended production approach.
  • Use the Anthropic tool runner if you want a customer-managed MCP connection but do not already have a tool-use loop.
  • Use the hosted MCP connector for the smallest proof of concept, when delayed tool-definition refreshes are acceptable.
anthropic.beta.messages.tool_runner is part of the regular anthropic Python SDK. It is not the Claude Agent SDK. The tool runner is a client-side convenience wrapper around repeated Messages API calls; the Agent SDK is a separate, higher-level agent harness with built-in tools, hooks, permissions, and subagents.

Common authentication

All three approaches below use a bearer token that packs the Caylex Navigator API key, end-user email, and chat session ID into one string:
  • Token = base64url(JSON{"api_key": "...", "user_email": "...", "session_id": "..."}) (padding optional)
  • api_key and user_email are required.
  • session_id is optional but strongly encouraged. It groups a chat’s tool calls into one session in Caylex history and analytics.
  • Send the result as Authorization: Bearer <token>.
The packed token is not signed or encrypted. Your Navigator API key is the real credential and is validated on every request. Build the token server-side and treat it like an API key.

Group tool calls by chat session

Generate one UUID when a chat begins and reuse it for every request in that chat:
The value must be a valid UUID. Start a new UUID for each new chat.

Prerequisites

  • Python 3.10+
  • A Caylex Navigator Instance with an API key (create one here)
  • Users authenticated with your project’s servers (set up auth links)
  • These environment variables:

System prompt and conversation messages

Anthropic accepts the system prompt through the top-level system parameter. Do not add a message with role: "system" — the messages array contains only user and assistant turns.
For subsequent turns, preserve the existing conversation_messages and append the new user message. The examples below show one user turn plus any tool-use iterations it triggers. This approach uses FastMCP’s lightweight client-only package to call tools/list and tools/call directly. You pass the freshly discovered tools to the regular Messages API and keep control of your existing agent loop.

Using a coding agent? Grab the Agent Skill

A ready-made SKILL.md for Claude Code, Cursor, and similar coding agents that implements this integration in your existing Messages API harness.
Install the dependencies:
fastmcp-slim[client] uses the normal from fastmcp import Client import while avoiding FastMCP’s server framework and other server-side dependencies.
main.py

Refresh after authentication

The tool definitions passed to one Claude tool loop remain fixed for that loop. If get_authentication_status_and_link returns a link and the user authenticates:
  1. Finish the current agent turn after presenting the link.
  2. Before the user’s next turn, call mcp.list_tools() again.
  3. Rebuild claude_tools from the returned list.
  4. Continue with the same chat_session_id and conversation history.
This gives Claude the latest suggest_tools description and authenticated-server list without relying on a third-party MCP catalog cache.

Anthropic tool runner

This option also owns the MCP connection, but uses Anthropic’s beta tool runner to execute the tool-use loop automatically. It is convenient if you do not already have a custom loop. Install:
main.py
async_mcp_tool copies each MCP tool’s name, description, and input schema into an Anthropic tool, then forwards Claude’s calls to ClientSession.call_tool(). The tool runner appends results and repeats Messages API calls until Claude returns a final answer.
This still uses Anthropic’s regular Python SDK and Messages API. It does not install or invoke the Claude Agent SDK. Because the tool runner owns the inner tool loop, applications with custom retries, streaming, approvals, or persistence may prefer the FastMCP approach above.

Anthropic hosted MCP connector

Anthropic’s hosted MCP connector performs MCP discovery and execution inside Anthropic’s infrastructure. It requires the least code because your application does not run an MCP client. Install:
main.py
Anthropic’s hosted connector may cache the model-facing MCP tool catalog independently of your chat messages. A new chat does not always force a fresh tools/list request, and there is currently no supported API option to force a refresh.This matters because Caylex tool descriptions include live, user-specific information such as the authenticated-server list in suggest_tools. After a user authenticates, Claude may temporarily see an older server list or an older catalog that omits get_authentication_status_and_link.Use the FastMCP or tool-runner approach when fresh tool definitions are required.
The hosted connector requires client.beta.messages.create, an mcp_toolset, and the mcp-client-2025-11-20 beta header. Its tool events use mcp_tool_use / mcp_tool_result; customer-managed integrations use ordinary tool_use / tool_result blocks.

Troubleshooting

If you use Anthropic’s hosted connector, the model-facing MCP catalog may be cached across requests or chats. There is currently no supported force-refresh parameter. Switch to a customer-managed MCP client, or wait for Anthropic’s catalog cache to refresh.With FastMCP, call mcp.list_tools() before each user turn and rebuild the Anthropic tool definitions. With the tool runner, start the next turn with a fresh list_tools() result.
Authentication likely failed. Confirm that the token decodes to the correct api_key, user_email, and UUID session_id, and that the API key belongs to the same environment as the Navigator URL.
The user_email packed into the token must exactly match the email the user authenticated with through an Auth Link.
Generate one UUID when the chat begins and include it as session_id in every bearer token for that chat. Do not generate a new UUID for each MCP request.
The Navigator ignores unknown top-level arguments instead of failing the whole call. It reports them in response _meta under caylex/ignored_arguments, including the field names and reason.

Further reading