Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting 401 un-authorised for Remote MCP - When tried accessing within langgraph

Krishna Kumar Natarajan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 23, 2025

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 ! 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events