Skip to main content
Glama

authorize_connection

Authorize connections to live brokerages and data providers for algorithmic trading by providing brokerage-specific credentials.

Instructions

Authorize an external connection with a live brokerage or data provider.

Args: brokerage_id: Brokerage identifier (e.g., "InteractiveBrokersBrokerage") credentials: Dictionary containing brokerage-specific credentials

Returns: Dictionary containing authorization result

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
brokerage_idYes
credentialsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'authorize_connection' tool. It authorizes a brokerage connection by making an authenticated POST request to the QuantConnect 'live/connection/authorize' endpoint with the provided brokerage_id and credentials.
    @mcp.tool()
    async def authorize_connection(
        brokerage_id: str, 
        credentials: Dict[str, Any]
    ) -> Dict[str, Any]:
        """
        Authorize an external connection with a live brokerage or data provider.
    
        Args:
            brokerage_id: Brokerage identifier (e.g., "InteractiveBrokersBrokerage")
            credentials: Dictionary containing brokerage-specific credentials
    
        Returns:
            Dictionary containing authorization result
        """
        auth = get_auth_instance()
        if auth is None:
            return {
                "status": "error",
                "error": "QuantConnect authentication not configured. Use configure_auth() first.",
            }
    
        try:
            # Prepare request data
            request_data = {
                "id": brokerage_id,
                **credentials  # Spread credentials into the request data
            }
    
            # Make API request
            response = await auth.make_authenticated_request(
                endpoint="live/connection/authorize", method="POST", json=request_data
            )
    
            # Parse response
            if response.status_code == 200:
                data = response.json()
    
                if data.get("success", False):
                    connection = data.get("connection", {})
                    
                    return {
                        "status": "success",
                        "brokerage_id": brokerage_id,
                        "connection": connection,
                        "message": f"Successfully authorized connection to {brokerage_id}",
                    }
                else:
                    # API returned success=false
                    errors = data.get("errors", ["Unknown error"])
                    return {
                        "status": "error",
                        "error": "Failed to authorize connection",
                        "details": errors,
                        "brokerage_id": brokerage_id,
                    }
    
            elif response.status_code == 401:
                return {
                    "status": "error",
                    "error": "Authentication failed. Check your credentials and ensure they haven't expired.",
                }
    
            else:
                return {
                    "status": "error",
                    "error": f"API request failed with status {response.status_code}",
                    "response_text": (
                        response.text[:500]
                        if hasattr(response, "text")
                        else "No response text"
                    ),
                }
    
        except Exception as e:
            return {
                "status": "error",
                "error": f"Failed to authorize connection: {str(e)}",
                "brokerage_id": brokerage_id,
            }
  • Calls register_auth_tools which imports and potentially registers tools from auth_tools.py including authorize_connection via module import.
    register_auth_tools(mcp)
  • Calls register_auth_tools(mcp) to register authentication tools, which imports auth_tools.py containing the authorize_connection tool.
    register_auth_tools(mcp)
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'authorize' which implies a write/mutation operation, but does not disclose critical traits such as required permissions, whether this is a one-time or recurring authorization, potential rate limits, error handling, or what happens if authorization fails. The description lacks behavioral details beyond the basic action.

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?

The description is efficiently structured with a clear purpose statement followed by separate sections for Args and Returns. Each sentence earns its place by providing essential information without redundancy. The formatting enhances readability and information retrieval.

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?

Given the complexity of an authorization tool with no annotations, 2 parameters (0% schema coverage), and an output schema, the description is moderately complete. It covers purpose and parameters adequately, and the output schema handles return values, but it lacks behavioral context (e.g., security implications, error cases) which is important for a mutation tool.

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

Parameters4/5

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

Schema description coverage is 0%, so the description must compensate. It provides meaningful semantics for both parameters: 'brokerage_id' is explained as a 'Brokerage identifier' with an example, and 'credentials' as a 'Dictionary containing brokerage-specific credentials'. This adds significant value beyond the bare schema, though it could elaborate on credential formats or requirements.

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?

The description clearly states the specific action ('Authorize an external connection') and the resource ('with a live brokerage or data provider'), distinguishing it from siblings like 'configure_quantconnect_auth' or 'get_auth_status' which handle different aspects of authentication. It uses precise terminology that indicates a live authorization process.

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

Usage Guidelines3/5

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

The description implies usage for authorizing external connections, but does not explicitly state when to use this tool versus alternatives like 'configure_quantconnect_auth' (which might set up auth parameters) or 'get_auth_status' (which checks status). No exclusions or prerequisites are mentioned, leaving usage context somewhat implied rather than clearly defined.

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/taylorwilsdon/quantconnect-mcp'

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