https://api.paywithlocus.com/api/credits/mcp.
Locus Pro exposes a hosted Streamable HTTP MCP server. Interactive desktop and
coding clients should use its OAuth discovery flow. The examples on this page
target hosted model APIs, servers, and unattended framework runtimes, so they
use an enterprise Agent Connection
with a scoped lcac_… service credential.
Examples below read the credential from LOCUS_AGENT_CONNECTION. Set it to the
one-time lcac_… value returned when you
create a connection; a tenant
lcr_… secret key does not belong in any of these runtimes.
Connecting Codex, Claude Code, Cursor, Claude Desktop, VS Code, Gemini CLI,
or another person-authorized client? Use the
interactive OAuth setup
instead. Personal accounts do not issue
lcac_… service credentials.Choose an integration
Select an integration to jump directly to its setup guide.OpenAI
Responses API and Agents SDK in Python or TypeScript.
Anthropic
Messages API remote MCP and Claude Agent SDK.
Vercel AI SDK
Load Locus tools through
@ai-sdk/mcp.Gemini Interactions API and Google ADK.
LangChain
MultiServerMCPClient in Python or TypeScript.LlamaIndex
Load MCP tools in Python or TypeScript.
CrewAI and AutoGen
Python multi-agent framework recipes.
Mastra
Configure Mastra’s native MCP client.
Raw MCP and custom frameworks
Official Python and TypeScript clients, plus the custom path.
Supported connections
“SDK preset” means
@withlocus/credits 0.5.2 can turn a newly revealed agent connection into that framework’s exact MCP configuration shape. The framework remains responsible for loading tools and managing its MCP client lifecycle.
These are first-class MCP connection recipes, not native provider packages.
The agent executes tools against Locus’s hosted server, so endpoint scope,
pricing, account binding, expiry, and budgets remain enforced server-side.
Connection values
Create an agent connection in your trusted backend. Save these values when Locus reveals them:- Hosted model APIs such as OpenAI Responses and Anthropic Messages receive the raw
lcac_…token. - Runtime MCP clients receive
Authorization: Bearer lcac_….
Bearer yourself when you use a preset.
MCP versus a native provider
MCP is portable and keeps execution policy on the Locus server. It also means framework-local tool middleware does not wrap the HTTP call unless that framework explicitly supports MCP middleware. Use the direct Node SDK when your application needs to select every endpoint itself or wrap execution inside its own process. Pi is the only framework in the comparison list without a native MCP client. Its custom extension path remains experimental. Locus does not label that path stable until it has a maintained adapter and contract tests. See Connect an agent for coding-client configuration, connection lifecycle, and troubleshooting.OpenAI
OpenAI can call Locus Pro as a hosted MCP tool. Send the rawlcac_… value on every request because OpenAI does not store MCP authorization.
Responses API
- TypeScript preset
- Python
Agents SDK
- TypeScript
- Python
Approval and scope
The presets defaultrequire_approval / requireApproval to never — whatever endpoint allowlist and spend limits the agent connection sets are the enforced boundary, so set them deliberately before relying on this default. Pass requireApproval: "always" to a preset when you also want the model provider to pause for approval before each tool call.
If you narrow tools again with OpenAI’s allowed_tools, keep that list within the connection’s Locus scope. OpenAI-side filtering cannot expand the server-side allowlist.
Anthropic
Use Anthropic’s hosted MCP connector when the Messages API should call Locus directly. Use the Claude Agent SDK HTTP transport when MCP should run in your application.Messages API
The hosted connector expects the rawlcac_… value in authorization_token.
- TypeScript preset
- Python
Claude Agent SDK
The runtime transport expects the completeAuthorization header:
- TypeScript preset
- Python
@anthropic-ai/claude-agent-sdk 0.2.70 or later for the corrected Streamable HTTP Accept header behavior.
Vercel AI SDK
Use@ai-sdk/mcp when your Vercel AI SDK agent should discover and execute Locus tools through Streamable HTTP.
Create the MCP client
Close the MCP client when the agent runtime shuts down. Do not create one
client per model token or tool call.
Tool results
MCP tool failures can resolve withisError: true. If you call the MCP client directly, pass the result through parseMcpToolResult() before treating it as success. Follow Turn structured results into final answers to persist the result before answer generation and recover safely from interrupted turns.
Google Gen AI and ADK
Google supports Locus Pro through two paths: hosted remote MCP in the Gen AI Interactions API, or a runtimeMcpToolset in Google ADK.
Gen AI Interactions API
Remote MCP supports Streamable HTTP. Use a server name without hyphens; the Locus preset defaults tolocus_pro.
- TypeScript preset
- Python
Google ADK
google-adk does not install mcp at all, and mcp 2.0.0 breaks its
toolset imports; the [mcp] extra pins a compatible mcp>=1.24,<2.
googleAdkMcpServer(connection) returns the url and headers constructor values when a Node control plane prepares configuration for a Python worker.
The Gemini or ADK layer can narrow tools, but it cannot widen the connection’s immutable Locus endpoint scope.
LangChain
LangChain’s MCP adapters discover Locus tools and expose them as normal LangChain tools. Use the same scoped connection in Python or TypeScript.- TypeScript
- Python
MultiServerMCPClient can combine Locus with other MCP servers. Keep the Locus connection under its own server name so logs and tool prefixes stay attributable.
The default client is stateless. It creates and cleans up a fresh MCP session for each tool call.
LlamaIndex
Both LlamaIndex Python and LlamaIndexTS include MCP tool adapters. They convert Locus tool schemas into framework-native callable tools.Python
llama-index-tools-mcp 0.5.0 breaks list_tools() against every streamable
HTTP server on mcp 2.x; these pins hold the last working pairing.
BasicMCPClient selects Streamable HTTP for the Locus /mcp URL. Do not set the deprecated SSE transport.
TypeScript
requestInit.headers to the official MCP transport. Version 0.5.2’s preset builds that shape and clones the one-time authorization header.
Restrict tools
Useallowed_tools in McpToolSpec only as a local narrowing layer. Create the Locus connection with tools.enable so an accidental local configuration change cannot widen access.
See Connect an agent for immutable scope and rotation.
CrewAI and AutoGen
CrewAI and AutoGen both accept authenticated Streamable HTTP MCP servers. Give each deployment its own Locus agent connection.CrewAI
cache_tools_list=True avoids repeated discovery inside one worker. Restart or refresh the worker after changing the tenant catalog. The Locus server recomputes the authenticated catalog on every request, but the CrewAI client can retain its last tool list.
If a Node control plane creates connections for Python workers, crewAIMcpServer(connection) returns these keyword values.
AutoGen
autogen-ext 0.7.5 imports break on mcp 2.0.0; keep the mcp pin until
AutoGen supports the 2.x line.
Use McpWorkbench as an async context manager so AutoGen closes the MCP session:
autoGenMcpServer(connection) returns the url and headers values when a Node control plane prepares worker configuration.
Reuse one Locus
loop_id across paid calls in the same autonomous run when
the connection has a per-loop budget. Dedicated tools accept a nested
_locus: { "loop_id": "…" } object; execute accepts loop_id.Mastra
Mastra’sMCPClient supports authenticated Streamable HTTP and converts MCP tools into Mastra tools.
URL and requestInit.headers, matching Mastra’s HTTP server definition. Set a stable id when several runtime components share the same connection configuration.
For a runtime that does not have the Locus management client, build the same entry from stored secrets:
Raw MCP and custom frameworks
Use the official MCP clients when your runtime has no framework adapter. Locus uses Streamable HTTP and standard bearer authorization.TypeScript MCP SDK
This example uses the stable@modelcontextprotocol/sdk package:
@modelcontextprotocol/client. Follow its migration guide when you adopt the newer protocol package; the Locus URL and authorization header do not change.
Python MCP SDK
mcp 2.x the Python SDK exposes structured tool payloads as
result.structured_content (snake_case), not structuredContent.
Locus is stateless and does not issue an MCP-Session-Id. Reconnect with the same agent connection after a transport interruption. Reuse the same idempotency key when retrying a paid call whose outcome is uncertain.
Custom frameworks
A custom adapter needs four operations:- Connect with the MCP URL and authorization header.
- Call
tools/listand map each JSON Schema into the framework’s tool type. - Route tool calls back to MCP
tools/callwithout changing arguments. - Treat a resolved result with
isError: trueas a failed tool call.
parseMcpToolResult() when the adapter is written in TypeScript. It preserves Locus billing metadata, artifacts, retry guidance, and application errors.
Pi
Pi does not ship a native MCP client. You can build a TypeScript extension that registers tools from the official MCP SDK, but this path is experimental and is not part of Locus’s stable compatibility promise. Use raw REST from an extension when you need Pi today, and keep the connection’s endpoint and credit scope narrow. See Connect an agent for transport failures, stale client catalogs, andisError handling.