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"},
            },
        },
    ),
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full disclosure burden. States connection is established but omits critical behavioral details: failure modes, timeout behavior, whether idempotent/reentrant, what indicates success, and that it establishes persistent stateful session.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences: first establishes action/target, second states critical prerequisite. No redundancy, appropriately front-loaded with action verb. Every word serves selection or invocation clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Adequate for a connection primitive given good schema coverage, but minimal for complexity involved. Acknowledges prerequisite nature but omits error conditions, lifecycle management (timeouts/reconnects), and side effects expected of a stateful network connection tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so baseline applies. Description mentions 'TWS or IB Gateway' which contextualizes the connection targets, but does not elaborate on parameter interactions or required vs optional usage beyond schema defaults.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clear specific verb (Connect) and resources (TWS or IB Gateway). Distinguishes from siblings 'disconnect' and 'is_connected' by specifying it establishes the connection to these specific trading platforms.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly states critical sequencing constraint: 'Must be called before using other tools.' This clearly establishes the prerequisite relationship with the 30+ sibling trading operations. Lacks explicit guidance on when not to use (e.g., if already connected).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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