Skip to main content
Glama
jjmerri

E*TRADE MCP Server

by jjmerri

etrade_get_auth_url

Generate E*TRADE OAuth authorization URL to begin authentication process for accessing market data and trading APIs.

Instructions

Get E*TRADE OAuth authorization URL. This is the first step in authentication - returns a URL for the user to visit.

Returns: Authorization URL that the user should visit in their browser

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main handler for etrade_get_auth_url tool. Gets auth instance, request token, builds and returns the authorization URL with instructions.
    @mcp.tool()
    def etrade_get_auth_url() -> str:
        """
        Get E*TRADE OAuth authorization URL.
        This is the first step in authentication - returns a URL for the user to visit.
        
        Returns:
            Authorization URL that the user should visit in their browser
        """
        global _request_token, _request_token_secret
        
        auth = get_auth()
        _request_token, _request_token_secret = auth.get_request_token()
        authorize_url = auth.get_authorize_url(_request_token)
        
        return f"Please visit this URL and authorize the application:\n{authorize_url}\n\nAfter authorizing, you will receive a verification code. Use etrade_authenticate with that code."
  • Tool registration decorator @mcp.tool() for etrade_get_auth_url.
    @mcp.tool()
  • Function signature and docstring defining input (none) and output (str: auth URL).
    def etrade_get_auth_url() -> str:
        """
        Get E*TRADE OAuth authorization URL.
        This is the first step in authentication - returns a URL for the user to visit.
        
        Returns:
            Authorization URL that the user should visit in their browser
        """
  • Helper to get or initialize the global ETradeAuth instance.
    def get_auth() -> ETradeAuth:
        """Get or create auth instance"""
        global _auth
        if _auth is None:
            consumer_key = os.getenv("ETRADE_CONSUMER_KEY")
            consumer_secret = os.getenv("ETRADE_CONSUMER_SECRET")
            environment = os.getenv("ETRADE_ENVIRONMENT", "sandbox")
            
            if not consumer_key or not consumer_secret:
                raise ValueError(
                    "ETRADE_CONSUMER_KEY and ETRADE_CONSUMER_SECRET must be set in environment variables"
                )
            
            _auth = ETradeAuth(consumer_key, consumer_secret, environment)
        return _auth
  • ETradeAuth.get_request_token() method called by the handler to obtain OAuth request token and secret.
    def get_request_token(self) -> Tuple[str, str]:
        """
        Get OAuth request token
        
        Returns:
            Tuple of (request_token, request_token_secret)
        """
        request_token, request_token_secret = self.oauth_service.get_request_token(
            params={"oauth_callback": "oob", "format": "json"}
        )
        return request_token, request_token_secret

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/jjmerri/etrade-mcp'

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