# How do I connect an AI agent to Interactive Brokers?

Interactive Brokers documents three ways in. An [MCP connector](https://www.interactivebrokers.com/en/trading/ai-integrations.php) at https://api.ibkr.com/v1/api/mcp-public drafts an instruction you submit in the AI Instructions tab. A script uses the [TWS API](https://www.interactivebrokers.com/docs/tws-api/doc/introduction.md) against Trader Workstation or IB Gateway, or the [Client Portal Web API](https://www.interactivebrokers.com/docs/web-api/v1/introduction.md). Start on the [paper username](https://www.interactivebrokers.com/docs/web-api/authentication/paper.md). Checked 2026-10-20. A very limited Autonomous AI Trading rollout invited about 3,000 clients ([Fool](https://www.fool.com/earnings/call-transcripts/2026/10/16/interactive-brokers-ibkr-q3-2026-earnings-call-transcript/), [Benzinga](https://www.benzinga.com/news/26/10/62401363/interactive-brokers-group-q3-2026-earnings-call-transcript)).

Checked on 2026-10-20. No business relationship with Interactive Brokers.

Paper first. Not financial advice.

## Which official IBKR APIs can a script use?

The [TWS API](https://www.interactivebrokers.com/docs/tws-api/doc/introduction.md) is a TCP socket to Trader Workstation or IB Gateway, and Interactive Brokers ships libraries in Python, Java, C++, C#, and VisualBasic. The [Client Portal Web API](https://www.interactivebrokers.com/docs/web-api/v1/introduction.md) is HTTP and websocket, and its introduction says it supports only IBKR Pro accounts. The [AI integrations page](https://www.interactivebrokers.com/en/trading/ai-integrations.php) is the MCP path, and it says instructions never become orders automatically.

The [AI integrations page](https://www.interactivebrokers.com/en/trading/ai-integrations.php) names ChatGPT, Claude, Grok, and Perplexity, plus any MCP client. The custom connector URL on that page is https://api.ibkr.com/v1/api/mcp-public. It says you log in through IBKR's own login screen, and that "your login credentials are never passed to the AI platform." It says "Instructions never become orders automatically." You review the draft and submit it in the AI Instructions tab on an IBKR platform. The page says AI Integration is not available in IN or JP. The disclosure says "The Instructions are created based on information provided by your AI service and may not be accurate or reflect what you wish to do."

Interactive Brokers also described a very limited Autonomous AI Trading rollout, about 3,000 invited clients who had used its human-in-the-loop AI connector, where an eligible client can connect an AI agent of their choice and authorize it to trade autonomously ([Fool transcript](https://www.fool.com/earnings/call-transcripts/2026/10/16/interactive-brokers-ibkr-q3-2026-earnings-call-transcript/), [Benzinga transcript](https://www.benzinga.com/news/26/10/62401363/interactive-brokers-group-q3-2026-earnings-call-transcript)), while the public [AI integrations page](https://www.interactivebrokers.com/en/trading/ai-integrations.php) still says the AI drafts instructions and instructions never become orders automatically.

The [TWS API introduction](https://www.interactivebrokers.com/docs/tws-api/doc/introduction.md) says the TWS API is a TCP socket protocol based on connectivity to Trader Workstation or IB Gateway. It says Interactive Brokers provides code systems in Python, Java, C++, C#, and VisualBasic.

The [Client Portal Web API introduction](https://www.interactivebrokers.com/docs/web-api/v1/introduction.md) says clients use HTTP endpoints and a websocket, with OAuth 1.0a, OAuth 2.0, SSO, and the Java-based CP Gateway. It says an active Interactive Brokers account is required, that you can create one for free, that you wait until the account is fully activated, and that "The Web API supports only IBKR Pro accounts."

The [Client Portal Gateway install page](https://www.interactivebrokers.com/docs/web-api/authentication/cpgw/installation-authentication.md) says to create and fund an IBKR Pro account, then log in at https://localhost:5000 using standard credentials. The [Web API paper page](https://www.interactivebrokers.com/docs/web-api/authentication/paper.md) says to use the paper username when the session should be paper. The two pages do not use the same login sentence. Follow the paper page when you want paper.

## How do I log a paper account in?

For the Web API, Interactive Brokers says there is no live or paper slider. Use the paper username from Client Portal, under Settings, then Paper Trading Account. For TWS and the other platforms, the [glossary](https://www.interactivebrokers.com/campus/glossary-terms/paper-trading-account/) says to select Paper mode at login, or use the paper username and password. New clients receive a paper account. Older accounts may not.

The [paper trading glossary](https://www.interactivebrokers.com/campus/glossary-terms/paper-trading-account/) says to set up paper trading in Client Portal. It says a paper trading account is created within 24 hours under normal business circumstances, and that you are notified by email when it is ready. It says all new clients automatically receive a paper trading account with 1,000,000 USD of paper trading Equity with Loan Value, and that older accounts may not have one. At login you select Live or Paper mode, and you use the paper trading username and password. The same page says the Web API and the TWS API can be used with paper accounts. Limits it names: no VWAP, Auction, RFQ, or Pegged to Market; fills from the top of the book; limited combo trading; stops and other complex order types are always simulated; penny trading for US options is not supported; mutual fund trading is not supported.

The [Web API paper page](https://www.interactivebrokers.com/docs/web-api/authentication/paper.md) says customers are encouraged to authenticate and test with their paper accounts before proceeding to live testing. It says there is no slider, so you authenticate with the paper username. Steps on that page:

1. Log in to Client Portal.
2. Select the Head and Shoulders icon, then Settings.
3. Under Account Configuration, open Paper Trading Account.
4. Read the paper trading username. Reset the paper trading password there if you do not already know it.
5. Log in to the Client Portal Gateway with that username and password.

The [TWS install lesson](https://www.interactivebrokers.com/campus/trading-lessons/installing-configuring-tws-for-the-api/) says paper accounts are compatible with the TWS API, and that it is recommended to test all programs in a paper environment before production trading. It says Read-Only "is enabled by default and will block all API orders" until it is unchecked. It says the default socket port is 7496 for a TWS live session and 7497 for a TWS paper session. IB Gateway defaults are 4001 for live and 4002 for paper.

The [TWS API limitations page](https://www.interactivebrokers.com/docs/tws-api/doc/notes-limitations/tws-api-limitations.md) says that if the regular trading account has been approved and funded, you can open a paper trading account from Account Management. It says the paper environment relies on more simulated technologies than the live environment, so order execution may vary, and that the paper trading environment has inherent limitations.

## What should the agent never be allowed to do?

Do not paste a password into the chat. The [MCP page](https://www.interactivebrokers.com/en/trading/ai-integrations.php) says login credentials are never passed to the AI platform. Do not let the agent clear Read-Only. The [settings page](https://www.interactivebrokers.com/docs/tws-api/doc/setting-management/introduction.md) says that change is manual, in the GUI. Do not treat an instruction as an order. You submit it. Leave cancel-all and close-all off the agent.

1. Do not paste a live password or a paper password into the chat. The [AI integrations page](https://www.interactivebrokers.com/en/trading/ai-integrations.php) says your login credentials are never passed to the AI platform.
2. Do not let the agent clear Read-Only. The [settings introduction](https://www.interactivebrokers.com/docs/tws-api/doc/setting-management/introduction.md) says "Read-Only access to the system must be first disabled manually through the GUI."
3. Do not treat an instruction as an order that has been sent. The [AI integrations page](https://www.interactivebrokers.com/en/trading/ai-integrations.php) says instructions never become orders automatically. You review it and you submit it in the AI Instructions tab.
4. Do not give the agent reqGlobalCancel. The [cancel-all page](https://www.interactivebrokers.com/docs/tws-api/doc/orders/cancelling-an-order/cancel-all-open-orders.md) says that call will cancel ALL open orders, including orders placed from TWS.
5. Do not give the agent Close All Positions. The [TWS Users' Guide](https://www.interactivebrokers.com/download/newMark/PDFs/printable.pdf) says Close All Positions transmits multiple opposite-side orders to close out all positions in the portfolio.
6. Do not start on the live username. The [Web API paper page](https://www.interactivebrokers.com/docs/web-api/authentication/paper.md) says to test with the paper account before live testing. The [TWS lesson](https://www.interactivebrokers.com/campus/trading-lessons/installing-configuring-tws-for-the-api/) says to test in a paper environment before production trading.

## Where do the order check and the kill switch sit?

Before you submit an instruction on an IBKR platform, paste the order into [Agent Order Check](/check). It runs in the browser on this site. The [kill switch](/guides/ai-trading-bot-kill-switch) sits outside the agent. Read-Only API blocks new API orders while it is on, and you turn it off in the GUI. Cancel-all is not that switch. Test on the paper username.

Before you convert an instruction into an order on an IBKR platform, paste that order into the [Agent Order Check](/check). It runs in the browser. The reject list is the [guardrails guide](/guides/ai-agent-trading-guardrails).

The control the agent cannot write is the [kill switch guide](/guides/ai-trading-bot-kill-switch). Read-Only is the IBKR setting that blocks new API orders while it stays checked. The [settings introduction](https://www.interactivebrokers.com/docs/tws-api/doc/setting-management/introduction.md) says the API cannot turn that setting off. You clear it in the GUI. reqGlobalCancel and Close All Positions are a cancel and a close. They are not a lasting block on the next order. Run the refuse test on the paper username from the [paper glossary](https://www.interactivebrokers.com/campus/glossary-terms/paper-trading-account/) and the paper socket in the [TWS lesson](https://www.interactivebrokers.com/campus/trading-lessons/installing-configuring-tws-for-the-api/).

The [broker connectors](/guides/broker-ai-connectors) row for Interactive Brokers MCP quotes the AI integrations page. This page is the setup.

## Questions people ask

### How do I connect an AI agent to Interactive Brokers?

Interactive Brokers documents three ways in. An [MCP connector](https://www.interactivebrokers.com/en/trading/ai-integrations.php) at https://api.ibkr.com/v1/api/mcp-public drafts an instruction you submit in the AI Instructions tab. A script uses the [TWS API](https://www.interactivebrokers.com/docs/tws-api/doc/introduction.md) against Trader Workstation or IB Gateway, or the [Client Portal Web API](https://www.interactivebrokers.com/docs/web-api/v1/introduction.md). Start on the [paper username](https://www.interactivebrokers.com/docs/web-api/authentication/paper.md). Checked 2026-10-20. A very limited Autonomous AI Trading rollout invited about 3,000 clients ([Fool](https://www.fool.com/earnings/call-transcripts/2026/10/16/interactive-brokers-ibkr-q3-2026-earnings-call-transcript/), [Benzinga](https://www.benzinga.com/news/26/10/62401363/interactive-brokers-group-q3-2026-earnings-call-transcript)).

### Which official IBKR APIs can a script use?

The [TWS API](https://www.interactivebrokers.com/docs/tws-api/doc/introduction.md) is a TCP socket to Trader Workstation or IB Gateway, and Interactive Brokers ships libraries in Python, Java, C++, C#, and VisualBasic. The [Client Portal Web API](https://www.interactivebrokers.com/docs/web-api/v1/introduction.md) is HTTP and websocket, and its introduction says it supports only IBKR Pro accounts. The [AI integrations page](https://www.interactivebrokers.com/en/trading/ai-integrations.php) is the MCP path, and it says instructions never become orders automatically.

### How do I log a paper account in?

For the Web API, Interactive Brokers says there is no live or paper slider. Use the paper username from Client Portal, under Settings, then Paper Trading Account. For TWS and the other platforms, the [glossary](https://www.interactivebrokers.com/campus/glossary-terms/paper-trading-account/) says to select Paper mode at login, or use the paper username and password. New clients receive a paper account. Older accounts may not.

### What should the agent never be allowed to do?

Do not paste a password into the chat. The [MCP page](https://www.interactivebrokers.com/en/trading/ai-integrations.php) says login credentials are never passed to the AI platform. Do not let the agent clear Read-Only. The [settings page](https://www.interactivebrokers.com/docs/tws-api/doc/setting-management/introduction.md) says that change is manual, in the GUI. Do not treat an instruction as an order. You submit it. Leave cancel-all and close-all off the agent.

### Where do the order check and the kill switch sit?

Before you submit an instruction on an IBKR platform, paste the order into [Agent Order Check](/check). It runs in the browser on this site. The [kill switch](/guides/ai-trading-bot-kill-switch) sits outside the agent. Read-Only API blocks new API orders while it is on, and you turn it off in the GUI. Cancel-all is not that switch. Test on the paper username.

## Sources checked

Checked on 2026-10-20.

- [IBKR AI integrations](https://www.interactivebrokers.com/en/trading/ai-integrations.php)
- [Fool transcript, IBKR Q3 2026](https://www.fool.com/earnings/call-transcripts/2026/10/16/interactive-brokers-ibkr-q3-2026-earnings-call-transcript/)
- [Benzinga transcript, IBKR Q3 2026](https://www.benzinga.com/news/26/10/62401363/interactive-brokers-group-q3-2026-earnings-call-transcript)
- [TWS API introduction](https://www.interactivebrokers.com/docs/tws-api/doc/introduction.md)
- [TWS API limitations](https://www.interactivebrokers.com/docs/tws-api/doc/notes-limitations/tws-api-limitations.md)
- [Client Portal Web API introduction](https://www.interactivebrokers.com/docs/web-api/v1/introduction.md)
- [Using a paper account (Web API)](https://www.interactivebrokers.com/docs/web-api/authentication/paper.md)
- [Client Portal Gateway install](https://www.interactivebrokers.com/docs/web-api/authentication/cpgw/installation-authentication.md)
- [Paper trading account glossary](https://www.interactivebrokers.com/campus/glossary-terms/paper-trading-account/)
- [Installing and configuring TWS](https://www.interactivebrokers.com/campus/trading-lessons/installing-configuring-tws-for-the-api/)
- [TWS API settings introduction](https://www.interactivebrokers.com/docs/tws-api/doc/setting-management/introduction.md)
- [Cancel all open orders](https://www.interactivebrokers.com/docs/tws-api/doc/orders/cancelling-an-order/cancel-all-open-orders.md)
- [TWS Users' Guide](https://www.interactivebrokers.com/download/newMark/PDFs/printable.pdf)
- [Agent Order Check](/check)
- [Kill switch](/guides/ai-trading-bot-kill-switch)
- [Guardrails](/guides/ai-agent-trading-guardrails)
- [Broker connectors](/guides/broker-ai-connectors)

Educational only. Not financial advice.

Free check: https://theagentictrader.com/check?utm_source=md&utm_medium=agent&utm_campaign=guides-ai-agents-for-interactive-brokers
Weekly note on broker and agent changes: https://theagentictrader.com/subscribe?utm_source=md&utm_medium=agent&utm_campaign=guides-ai-agents-for-interactive-brokers
Desk Kit, $79 one-time. Full refund within 7 days: https://theagentictrader.com/desk-kit?utm_source=md&utm_medium=agent&utm_campaign=guides-ai-agents-for-interactive-brokers
