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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- etrade_mcp/server.py:67-82 (handler)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."
- etrade_mcp/server.py:67-67 (registration)Tool registration decorator @mcp.tool() for etrade_get_auth_url.@mcp.tool()
- etrade_mcp/server.py:68-75 (schema)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 """
- etrade_mcp/server.py:23-37 (helper)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
- etrade_mcp/auth.py:43-53 (helper)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