Skip to main content
Glama
nadavgb-atom

ib-async-mcp

by nadavgb-atom

connect

Establish connection to Interactive Brokers TWS or Gateway to enable account management, market data access, and trade execution through the ib-async MCP server.

Instructions

Connect to TWS or IB Gateway. Must be called before using other tools.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostNoTWS/Gateway host127.0.0.1
portNoPort (7496 for TWS, 4001 for Gateway)
client_idNoClient ID
readonlyNoRead-only mode

Implementation Reference

  • The handler logic for the 'connect' tool in _handle_tool function, which manages the connection to TWS/Gateway using IB.connectAsync.
    if name == "connect":
        if ib is not None and ib.isConnected():
            return {"status": "already_connected"}
        ib = IB()
        await ib.connectAsync(
            host=args.get("host", "127.0.0.1"),
            port=args.get("port", 7496),
            clientId=args.get("client_id", 1),
            readonly=args.get("readonly", True),
        )
        return {"status": "connected", "accounts": ib.managedAccounts()}
  • Definition and schema of the 'connect' tool.
    Tool(
        name="connect",
        description="Connect to TWS or IB Gateway. Must be called before using other tools.",
        inputSchema={
            "type": "object",
            "properties": {
                "host": {"type": "string", "default": "127.0.0.1", "description": "TWS/Gateway host"},
                "port": {"type": "integer", "default": 7496, "description": "Port (7496 for TWS, 4001 for Gateway)"},
                "client_id": {"type": "integer", "default": 1, "description": "Client ID"},
                "readonly": {"type": "boolean", "default": True, "description": "Read-only mode"},
            },
        },
    ),

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/nadavgb-atom/ib-async-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server