Skip to main content

Using with OpenAI Agents

Legend’s MCP server works natively with the OpenAI Responses API. Pass the server URL and the model discovers tools automatically.

Setup

Add Legend as an MCP tool source in your Responses API call:
The first response includes an mcp_list_tools output with all available tools. The model then decides which to call.

Tool Discovery

On the first request, the API fetches tools:
As long as mcp_list_tools is in the conversation context, the API won’t re-fetch on subsequent turns.

Tool Calls

When the model calls a tool, you see mcp_call items:

Handling Plan Execution

Read-only operations (list_accounts, get_portfolio, list_assets) work seamlessly. For plan execution, your orchestrator needs to handle signing:
Alternatively, use --auto-sign on the CLI for a simpler flow:

Filtering Tools

If you only need a subset of tools, use allowed_tools:
This is useful for read-only agents that shouldn’t create plans.

System Prompt

Add domain context for better tool usage: