Skip to main content
Give the agent you’re building search, research, enrichment, and other paid tools through one MCP connection. Your framework finds and calls the tools. Locus enforces access and spending limits.

How it works

Every framework connects to the same Locus MCP server with a Locus Pro Enterprise agent key, in one of two ways:
  • Hosted MCP. You pass the Locus URL and key in the tool settings, and the model provider’s API connects to Locus for you.
  • Runtime MCP client. Your own process opens the MCP connection and hands the Locus tools to your framework.
Either way, the agent key’s tools and budget apply to every call. For a desktop or coding client you use yourself, use interactive OAuth instead.

Before you start

1

Create an agent key

Create an agent key with the tools, account, expiry, and budget your agent needs. Create it on your trusted backend, never in the agent runtime.
2

Give the runtime its values

Store the key in your runtime’s secret manager:
Runtime environment
In TypeScript, the Node SDK has a preset for most frameworks. A preset takes the connection your backend created and fills in that framework’s authorization fields.

Choose an integration

Copy-paste code for every framework, in Python and TypeScript, is in the framework reference.

Example: OpenAI Responses API

This hosted example lets OpenAI call Locus directly. It uses the values from Before you start:
research.py
This example skips per-call approval, so set tool and spending limits on the agent key first. The other frameworks follow the same pattern: point the MCP client at the Locus URL and pass the agent key.

OpenAI

OpenAI calls Locus as a hosted MCP tool from the Responses API, the Agents SDK, or the managed Agents API.
  • The Responses API and Agents SDK take the raw lcac_… key. The managed Agents API takes the full Bearer lcac_… value and needs no Locus preset.
  • TypeScript presets: openAIResponsesMcpTool and openAIAgentsHostedMcpTool. They default to requireApproval: "never". Set it to "always" if your application should ask before each call. The agent key’s limits apply either way.

Anthropic

  • Messages API. Anthropic’s hosted MCP connector calls Locus directly. It expects the raw lcac_… key. Preset: anthropicMessagesMcp.
  • Claude Agent SDK. MCP runs in your application over HTTP, with the full Authorization header. Preset: claudeAgentSdkMcpServer. Use @anthropic-ai/claude-agent-sdk 0.2.70 or later.

Vercel AI SDK

Use @ai-sdk/mcp to create an MCP client with the vercelAIMcpTransport preset, then pass its tools to generateText(), streamText(), or an agent. Keep the client open for the agent’s lifetime and close it at shutdown. Check isError on tool results, or use parseMcpToolResult(). Store paid results before generating an answer so an interrupted turn does not repeat the purchase.

Google Gen AI and ADK

  • Gen AI Interactions API. Hosted remote MCP over Streamable HTTP. Use a server name without hyphens; the googleGenAIMcpServer preset defaults to locus_pro.
  • Google ADK. A runtime McpToolset in Python. Install google-adk[mcp] for the compatible MCP dependency.

LangChain

LangChain’s MCP adapters turn Locus tools into normal LangChain tools, in Python or TypeScript. The TypeScript preset is langChainMcpServer. create_agent builds a LangGraph agent, so the same tools work in your own LangGraph graphs. Locus returns results as text and structured content, which LangChain passes to any model provider.

LlamaIndex

LlamaIndex Python and LlamaIndexTS both include MCP tool adapters that turn Locus tools into native callable tools. The TypeScript preset is llamaIndexTSMcpServer. The Python adapter needs MCP 1.x, so keep the pins from the framework reference.

CrewAI and AutoGen

CrewAI and AutoGen both accept authenticated Streamable HTTP MCP servers. Give each deployment its own agent key.
  • CrewAI. Refresh the worker’s tool list after you change your workspace catalog.
  • AutoGen. Use McpWorkbench as a context manager so the MCP session closes. It needs MCP 1.x.

Strands Agents

Strands Agents connects through MCPClient and passes the Locus tools to an Agent, which opens and closes the session for you. Use strands-agents 1.53 or later. Add tool_filters if the agent should see only some Locus tools.

Mastra

Mastra’s MCPClient from @mastra/mcp supports authenticated Streamable HTTP and converts Locus tools into Mastra tools. The preset is mastraMcpServer.

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. In TypeScript, mcpHttpConnection returns the URL and headers. On the Python MCP 2.x client, read structured results from result.structured_content. A custom adapter needs four operations:
  1. Connect with the MCP URL and authorization header.
  2. Call tools/list and map each JSON Schema into the framework’s tool type.
  3. Route tool calls back to MCP tools/call without changing arguments.
  4. Treat a resolved result with isError: true as a failed tool call.
In TypeScript, parseMcpToolResult() keeps Locus billing details, artifacts, retry guidance, and application errors. Pi needs a custom extension. Locus’s Pi integration is experimental, so use the raw MCP or REST API path.
If you set a per-run budget on the agent key, pass one loop_id across every paid call in that run. Reuse the same idempotency key when retrying an uncertain paid call.

Next steps

Agent keys

Scope the key your framework uses.

Node SDK

Create agent keys and call tools from your server.

Model inference

Pay for model calls from the same balance.

Paid tool calls

See how price caps, approvals, and retries work.