We tried accessing Atlassian's remote MCP with langgraph as the host ( instead of claude desktop / vs code )
How we tried :::
from langchain_mcp_adapters.client import MultiServerMCPClient
from langgraph.prebuilt import create_react_agent
from langchain_openai import AzureChatOpenAI
# Get OAuth token for Atlassian MCP
access_token = await get_access_token()
if not access_token:
logger.error("Failed to get access token. Exiting.")
return
# Configure MCP server with OAuth token
mcp_servers = {
"atlassian": {
"url": "https://mcp.atlassian.com/v1/sse",
"transport": "sse",
"headers": {
"Authorization": f"Bearer {access_token}"
}
}
}
try:
logger.info("Connecting to Atlassian MCP server...")
async with MultiServerMCPClient(mcp_servers) as client:
logger.info("Connected to Atlassian MCP server")
# Get tools from the MCP client
tools = client.get_tools()
logger.info(f"Retrieved {len(tools)} tools from Atlassian MCP")
# Create a ReAct agent using the Azure OpenAI model and MCP tools
agent = create_react_agent(llm, tools)
# Your query to the agent
query = "What is stop logic in Confluence?" # You can change this to your specific query
logger.info(f"Sending query to agent: {query}")
# Invoke the agent with your question
response = await agent.ainvoke({
"messages": [{"role": "user", "content": query}]
})
# Print the last message content from the agent
print("\nAgent Response:")
print(response["messages"][-1].content)
Here we are getting 401 un-authorised.
Note: We tried with Basic Auth as well.. Even there we were getting 401 un-authorised.
code sample used:
auth_string = f"{CONFLUENCE_USERNAME}:{CONFLUENCE_API_TOKEN}"
import base64
encoded_auth = base64.b64encode(auth_string.encode()).decode()
# Get OAuth token for Atlassian MCP
access_token = await get_access_token()
if not access_token:
logger.error("Failed to get access token. Exiting.")
return
# Configure MCP server with OAuth token
mcp_servers = {
"atlassian": {
"url": "https://mcp.atlassian.com/v1/sse",
"transport": "sse",
"headers": {
"Authorization": "Basic {encoded_auth}"
}
}
}
try:
logger.info("Connecting to Atlassian MCP server...")
async with MultiServerMCPClient(mcp_servers) as client:
logger.info("Connected to Atlassian MCP server")
# Get tools from the MCP client
tools = client.get_tools()
logger.info(f"Retrieved {len(tools)} tools from Atlassian MCP")
# Create a ReAct agent using the Azure OpenAI model and MCP tools
agent = create_react_agent(llm, tools)
# Your query to the agent
query = "What is stop logic in Confluence?" # You can change this to your specific query
logger.info(f"Sending query to agent: {query}")
# Invoke the agent with your question
response = await agent.ainvoke({
"messages": [{"role": "user", "content": query}]
})
# Print the last message content from the agent
print("\nAgent Response:")
print(response["messages"][-1].content)
Kindly help here to connect to remote mcp within agent code. Thanks !
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.