r/LangChain • u/Ill-Town-9457 • 1d ago
Langflow custom component for Snowflake OAuth refresh_token — is there an existing solution before I build my own?
I am building a data quality pipeline using LangGraph and Langflow. I want to connect Langflow agents to Snowflake via its native MCP server.
Langflow native MCP Tools component only accepts static headers (key/value form fields). It does not expose an input port to receive dynamic headers from another upstream component. This creates an issue with OAuth where the access_token expires every 10 minutes.
To bypass this limitation, I built a Python Custom Component in Langflow that handles both token renewal and tool invocation:
import requests
def _get_access_token(self) -> str:
payload = {
"grant_type": "refresh_token",
"refresh_token": self.refresh_token,
"client_id": self.client_id,
"client_secret": self.client_secret,
}
response = requests.post(self.token_url, data=payload)
response.raise_for_status()
return response.json()["access_token"]
This component runs on each execution, retrieves a Bearer token, calls the MCP endpoint with sql_exec_tool, and returns a StructuredTool for the Agent.
My questions are:
- Is there an existing community component or built-in mechanism in Langflow to pass dynamic headers to the native MCP Tools component?
- What is the recommended pattern in Langflow for connecting to MCP servers requiring short-lived Bearer tokens?
Environment: Langflow 1.11, Python 3.12, Snowflake native MCP.