You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR allows connecting to mcp servers that requires OAuth.
I needed this functionality to get my langgraph agent working with
cloudflare mcp servers which have auth enabled.
This was adapted from
`modelcontextprotocol/python-sdk/`[mcp_simple_auth_client](https://github.com/modelcontextprotocol/python-sdk/tree/main/examples/clients/simple-auth-client/mcp_simple_auth_client)
Sample code for how to use
```
oauth_provider = langchain_mcp_adapters.auth.create_oauth_provider("https://mcpserver.with.oauth.org")
client = MultiServerMCPClient(
connections={
"server_with_auth": {
"transport": "sse",
"url": "https://mcpserver.with.oauth.org/sse",
"auth": oauth_provider, #server with auth
},
}
)
# Get list of tools from "server_with_auth" server
async with client.session("server_with_auth") as server_with_auth_session:
tools = await langchain_mcp_adapters.tools.load_mcp_tools(server_with_auth_session)
print(f"\n Found {len(tools)} tools:")
for tool in tools:
print(f"- {tool.name}: {tool.description or 'No description'}")
```
---------
Co-authored-by: Meena Chockalingam <[email protected]>
Co-authored-by: Eugene Yurtsev <[email protected]>
0 commit comments