rapunzl logo green investing castle
Request Free DemoFree Demo
rapunzl mobile hamburger icon

Rapunzl Agent Access Setup Guide

This guide shows how to connect an AI agent or your own code to Rapunzl's stock market simulator. Everything an agent does in Rapunzl uses simulated money and real market data.

Setup happens once. You create an access key in your Rapunzl settings, add it to your AI app or script, and then ask your agent in plain English.

Before You Start: Who Can Use Agent Access

Agent Access is available to students 13 and older, teachers and Rapunzl family plans. Students who use Rapunzl through a school or district can use it once the school or district turns it on.

Who Can Create a Key

  • Students 13 and older, including children on a Rapunzl family plan.
  • Teachers, including teachers whose district uses district sign-in.
  • Anyone whose own account has an active Rapunzl plan.

Who Cannot

  • Students in a school or district that has not turned Agent Access on.
  • Children under 13.
  • Accounts without a plan that are not student or teacher accounts. They see an upgrade prompt instead.
  • A parent account that bought a plan for a child but holds no plan itself. The child's own account is the eligible one.
  • Deactivated accounts.

For family and individual plans, Agent Access is included while the plan is active.

Check the AI App's Age Rules

Each AI app sets its own age rules, and the app is not run by Rapunzl. Its own terms and privacy policy apply to everything you do in it.

  • Anthropic's Consumer Terms require users to be at least 18.
  • OpenAI's Terms of Use require users to be at least 13, and users under 18 need a parent's or guardian's permission.

Students under 18 can use an AI tool their school provides, one a parent approves where the app's rules allow, or a script they write themselves.

What the AI App Sees

The AI app sees what its access key allows and nothing more: your username; the cash, holdings, orders and trades in the portfolios you picked; your competition standing; and market data. It never receives your password, email address, date of birth or payment information.

Create an Access Key

You create each key once, in your Rapunzl settings. The key is what your AI app or script uses to act for you.

  1. Sign in to rapunzl.app and go to Settings, then Agent access.
  2. Create a new key and give it a name you will recognize, such as the laptop or app it is for. The name appears in your order history next to every trade the agent places.
  3. Choose what the key can do. Look only lets the agent read your account. Look and trade also lets it place and cancel orders.
  4. Choose which portfolios the key can see and trade. Stock and crypto portfolios are chosen separately.
  5. Keys expire on their own, and the settings page warns you before one does.
  6. Copy the key and keep it private. Treat it like a password: anyone who has it can do what the key allows. Rapunzl shows the full key once, when you create it. If you lose it, revoke it and create a new one.

Optional Permissions

Optional permissions you can add to a key
PermissionWhat it lets the agent doName in settings
Follow live updatesFollow fills and cancellations as they happen.stream
Build custom Stock Scanner screensCreate custom screens on plans that include building screens.screener_build
Save chart layoutsSave chart layouts that appear in the Rapunzl apps.chart_layout_write

You can cap what a key may trade: how many orders it may place in a day, the largest value of one order, and a list of the symbols it may trade.

You can have up to 5 live keys at a time. Rapunzl notifies you in the app when a key is created, and when each key places its initial order.

Connect a Desktop AI App

Status: Available now

Claude Desktop runs Rapunzl's connector on your computer. The connector reads your access key from an environment variable, a named setting the program picks up when it starts.

  1. In Claude Desktop, open Settings, then Developer, then Edit Config. This opens the configuration file, claude_desktop_config.json. On a Mac it is in ~/Library/Application Support/Claude. On Windows it is in %APPDATA%\Claude.
  2. Add Rapunzl as an MCP server, the program your app talks to, with the snippet below. Replace the sample key with your own access key. The connector starts with uvx, which comes with uv, a Python tool runner. Install uv before you restart the app if you do not have it.
  3. Restart Claude Desktop.
  4. Ask a simple question to check the connection, such as what is in your Rapunzl portfolio.
Claude Desktop configuration
{
  "mcpServers": {
    "rapunzl": {
      "command": "uvx",
      "args": ["rapunzl-mcp"],
      "env": {
        "RAPUNZL_API_KEY": "rpz_live_paste_your_key_here"
      }
    }
  }
}

Tell your agent to ask before every trade. Rapunzl's tools tell agents to check with you before placing an order, but the AI app decides, so say it at the start of the chat.

Connect a Coding Agent in Your Terminal

Status: Available now

Claude Code connects to Rapunzl over HTTPS, the standard way apps talk to websites, with your access key sent in a header, an extra line of information that travels with each request.

  1. Run the command below in your terminal. Replace the server address with the one shown on the Agent access page in your Rapunzl settings, and replace the sample key with your own access key.
  2. Check that Rapunzl is listed by running claude mcp list.
  3. Ask Claude Code to look up a quote or read your portfolio.
Claude Code command
claude mcp add --transport http rapunzl <server address from the Agent access page> --header "Authorization: Bearer rpz_live_paste_your_key_here"

Tell your agent to ask before every trade. Rapunzl's tools tell agents to check with you before placing an order, but the AI app decides, so say it at the start of the chat.

Connect a Code Editor or Another MCP App

Status: Available now

Cursor and other apps that support MCP, the open standard AI apps use to connect to other apps, use the same Rapunzl server. Connect over HTTPS, or run the connector on your computer.

Settings to enter in an MCP app
SettingValue
Server addressThe address shown on the Agent access page in your Rapunzl settings. It ends in /mcp.
TransportStreamable HTTP, the main way to connect. The local connector uses stdio.
Header that carries your keyAuthorization: Bearer followed by your access key
Command to run it locallyuvx rapunzl-mcp, with the environment variable RAPUNZL_API_KEY set to your key

In Cursor, add the server to your MCP configuration file, mcp.json. For every project, use .cursor/mcp.json in your home folder. For one project, use .cursor/mcp.json in that project's folder. Replace the server address and the sample key.

Cursor configuration
{
  "mcpServers": {
    "rapunzl": {
      "url": "<server address from the Agent access page>",
      "headers": {
        "Authorization": "Bearer rpz_live_paste_your_key_here"
      }
    }
  }
}

To run the connector on your computer instead, use the command uvx rapunzl-mcp with RAPUNZL_API_KEY set to your key, the same way as the Claude Desktop snippet. If your app is not listed in this guide, enter the same settings in its MCP configuration.

Tell your agent to ask before every trade. Rapunzl's tools tell agents to check with you before placing an order, but the AI app decides, so say it at the start of the chat.

Call Rapunzl From Your Own Code

Status: Available now

Your own code can use Rapunzl's Agent API, the way code talks to Rapunzl directly. It follows the same rules and limits as an AI app and sees the same tools. The example below uses the MCP library for Python, which calls the tools by name.

  • Base address: the address shown on the Agent access page in your Rapunzl settings. The Agent API address ends in /agents/ and the MCP server address ends in /mcp.
  • Send your key with every request in the header Authorization: Bearer followed by your access key. Never put the key in the web address.

Install the library with pip install mcp. Set RAPUNZL_MCP_URL to the MCP server address, RAPUNZL_API_KEY to your key and RAPUNZL_PORTFOLIO_ID to the number of a stock portfolio the key can trade.

Python example: get a quote and preview an order
import asyncio
import os

from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

SERVER = os.environ["RAPUNZL_MCP_URL"]
HEADERS = {"Authorization": "Bearer " + os.environ["RAPUNZL_API_KEY"]}
PORTFOLIO_ID = int(os.environ["RAPUNZL_PORTFOLIO_ID"])


async def main():
    async with streamablehttp_client(SERVER, headers=HEADERS) as (read, write, _):
        async with ClientSession(read, write) as session:
            await session.initialize()

            quote = await session.call_tool("get_quote", {"symbols": ["AAPL"]})
            print(quote.content[0].text)

            # A preview shows what Rapunzl would do. Nothing is placed.
            preview = await session.call_tool(
                "preview_order",
                {
                    "portfolio": {"portfolio_type": "stock", "portfolio_id": PORTFOLIO_ID},
                    "symbol": "AAPL",
                    "side": "buy",
                    "at_open": False,
                    "quantity": 1,
                    "order_type": "market",
                    "time_in_force": "day",
                    "client_order_id": "setup-guide-example-1",
                },
            )
            print(preview.content[0].text)


if __name__ == "__main__":
    asyncio.run(main())

Preview an order before you place it. A preview shows what Rapunzl would do without trading.

Scripts can follow fills as they happen through Rapunzl's real-time stream. The key needs the live updates permission. Set RAPUNZL_STREAM_URL to the stream address shown on the Agent access page. The key goes in the header, not in the web address.

Follow fills as they happen
curl -N -H "Authorization: Bearer $RAPUNZL_API_KEY" "$RAPUNZL_STREAM_URL?clientId=my-script"

If your code cannot hold a stream open, ask for order events since a saved bookmark instead, with the get_order_events_since tool. The wait_for_order_events tool waits for new events and then returns.

What Your Agent Can Do: The Tools in Plain English

Your agent uses the same simulator, market data and research tools you use in the app.

Find Stocks and Crypto
Search everything Rapunzl supports and check whether a symbol can be traded.search_symbols, get_symbol
Read Your Portfolios
Cash, positions, open orders and past trades for the portfolios you picked, plus your competition standing.whoami, list_portfolios, get_portfolio, get_positions, get_orders, get_order, get_transactions, get_portfolio_history
Get Live Quotes and History
Real-time quotes, the same market data you see in the app, plus history of past quotes. Stocks have a data point for each minute, 5 minutes, day, week or month. Crypto has one for each minute up to each day.get_market_status, get_quote, list_timeframes, get_price_history
Run Rapunzl's Analysis Tools
Technical indicators, candlestick patterns, support and resistance, and the AI chart read.list_indicators, list_candlestick_patterns, compute_indicators, detect_patterns, support_resistance, analyze_chart
Use the Stock Scanner
Run Rapunzl's Stock Scanner ideas to find candidates. On plans that include building screens, run custom screens too.list_screener_presets, list_screener_fields, run_screen, explain_screen, list_saved_screens, save_screen
Preview, Place and Cancel Orders
Market, limit, stop, stop-limit and one-cancels-the-other orders. Orders can last for the day, until cancelled or until a date you set. An agent can buy, sell, short and cover. It checks what happened afterward with the order events tools.preview_order, place_order, place_oco, cancel_order, cancel_all_orders, flatten_positions, get_order_events_since, wait_for_order_events

How Orders Behave

  • Orders never fill the instant they are placed. The simulator fills them on the next trade, or at the open when the market is closed.
  • Restricted symbols can be sold or covered, never opened.
  • Every trade an agent places is labeled in your order history with the name of the key.
  • Agents trade in competitions that allow them. Leaderboards can show which entries are agent-assisted.

Everything an agent does uses simulated money. Rapunzl's tools and data are not investment advice.

Limits, and What Happens When You Hit One

Rapunzl limits requests and orders so a runaway agent cannot flood your account. Keep an eye on them if your script sends many requests.

  • Request limit: each key and each account can send a steady number of requests every minute. Charts, analysis and Stock Scanner runs have lower limits than other requests, and so does placing orders.
  • Daily order limit: each key has a cap on how many orders it can place in a day. You can set a lower cap when you create the key.
  • Trading pauses after repeated rejected orders: if one key has many orders rejected in a short time, Rapunzl pauses trading on that key for a short while and tells you in the app. The pause ends on its own. Looking at your account keeps working.
  • Rapunzl keeps a log of requests for 90 days.

When You Hit a Limit

The request is refused with an error code that names the limit: RATE_LIMITED for requests, or DAILY_ORDER_LIMIT for orders. The response says how many requests you have left and how long to wait, in the headers X-RateLimit-Remaining and Retry-After. An AI app shows the same text in its error message.

  1. Stop the agent or script.
  2. Wait for the time in the Retry-After header, or until the next day for the daily order limit, then try again.
  3. If it keeps happening, ask your agent to make fewer requests, or tighten your script's loop.

When Something Goes Wrong: Error Codes

When Rapunzl refuses a request, the response carries an error code. This table lists what each one means and what to do.

Error codes and what to do
CodeWhat it meansWhat to do
UNAUTHENTICATEDRapunzl did not receive a key, or does not recognize it.Check that the Authorization header is Bearer followed by the whole key.
KEY_EXPIRED, KEY_REVOKEDThe key has expired or was switched off.Create a new key in Settings, then Agent access.
SCOPE_MISSINGThe key is look only and the agent tried to trade, or it lacks another permission it needs.Create a key that can trade, or keep using this one to look.
PORTFOLIO_NOT_ALLOWEDThe key was not given that portfolio.Create a key that includes the portfolio.
ACCOUNT_NOT_ELIGIBLEThe account does not have Agent Access, or the school or district has not turned it on.Check who can use Agent Access at the top of this guide. Students in a district can ask their teacher, school or district to turn it on.
ENTITLEMENT_REQUIREDThe tool, order type or time frame is not included in your Rapunzl plan.Use a tool your plan includes. The response names the feature.
RATE_LIMITEDThe agent sent too many requests.Wait for the time in Retry-After, then try again with fewer requests.
DAILY_ORDER_LIMITThe key reached its order limit for the day.Wait until the limit resets.
ORDER_VALUE_LIMITThe order is worth more than the cap set on the key.Change the order, or change the key's caps.
TRADING_SUSPENDED_FOR_KEYTrading paused after repeated rejected orders.Wait for the pause to end, then check the orders that were rejected.
COMPETITION_NOT_AGENT_APPROVEDThe competition does not allow agents.Check the competition's rules.
IDEMPOTENCY_KEY_REUSEDThe client order id was already used for a different order.Use a new client order id for each new order, and reuse an id when you retry the same order.
DATA_UNAVAILABLERapunzl could not load the market data just now.Try again in a moment.
An order code, such as one for a restricted symbolThe order broke a simulator rule. A restricted symbol can be sold or covered, not opened.Read the message in the response and change the order. The MCP resource rapunzl://reference/order-codes lists every order code.

Switch Off a Key

You can switch off an agent at any time by revoking its key.

  1. Sign in to rapunzl.app and go to Settings, then Agent access.
  2. Find the key by its name and revoke it.
  3. Remove Rapunzl from the AI app or script that used it.
  • A revoked key stops working. Removing Rapunzl from an AI app stops the app from using it, but revoking the key is what stops the key itself.
  • Keys also expire on their own.
  • Changing your password switches off every key. So does deactivating your account.
  • If an agent does something you did not expect, revoke the key right away, then read your order history. Every trade the agent placed is labeled with the key's name.