adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

[Question] Connect to mcp-remote server

Open dttran-glo opened this issue 1 year ago • 6 comments

To setup connection to the Atlassian Remote MCP Server beta, you can use the following configuration -

{
  "mcpServers": {
    "atlassian": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://mcp.atlassian.com/v1/sse"]
    }
  }
}

Please someone guide me to use with MCPToolset

dttran-glo avatar Jun 10 '25 09:06 dttran-glo

Hi @dttran-glo,

I have tried to implement this same case for a project I am working on, here are some things that have worked for me and you could try:

Tool definition

from google.adk.tools.mcp_tool.mcp_toolset import MCPToolset, StdioServerParameters

jira_tool = MCPToolset(
    connection_params=StdioServerParameters(
        command='npx',
        args=[
            "-y", "mcp-remote", "https://mcp.atlassian.com/v1/sse",
            "--jira-url=https://your-project.atlassian.net",
            "[email protected]",
            "--jira-token=your_token"
        ],
        env={}
    )
)

You can obtain the token from this option https://id.atlassian.com/manage-profile/security/api-tokens

With this you could run the agent passing the previous tool.

If you need access to confluence as well, you can add these flags

"--confluence-url", "https://your-company.atlassian.net/wiki", "--confluence-username", "[email protected]", "--confluence-token", "your_api_token"

Timeout error

If during the agent startup you get a timeout error, after investigating I see that it is because an authorization error, something that worked for me was to run the following command in the terminal

npx -y mcp-remote https://mcp.atlassian.com/v1/sse --jira-url=https://your-project.atlassian.net/ --jira-username=[[email protected]](mailto:[email protected]) --jira-token=YOUR_TOKEN

This will open a window in the browser in which Jira requests permissions, just accept and you will be able to run the agent again.

cloudid error

Probably, when the agent makes the first interaction with the Jira MCP it will tell you that it needs the cloudId of the project in Jira, you can tell it to use the #getAccessibleAtlassianResources tool to get the cloudId and give it to you, then you can set the cloudId in the prompt or give it the instruction on how to get the cloudId. After this the agent could interact with the MCP without any problem.

What's next

After some tests I find that the authorization that was accepted to solve the timeout error is temporary, I think it lasts about 1 hour, after that the window to accept the permissions comes up again, this is a problem if you plan to use the agent on a server as in my case, if anyone has any idea how to increase the time or if there is something I am doing wrong, please let me know. 🙌

jfolaya8 avatar Jun 11 '25 12:06 jfolaya8

I have found the right way to handle this, with mcp-remote it automatically manages the session, this is why it opens a tab in the browser and is not really making use of the args that are being sent, if you want to make use of the parameters you send it is best to use uvx, this already manages the session with the token you send --jira-token

jira_tool = MCPToolset(
    connection_params=StdioServerParameters(
        command='uvx',
        args=[
            "mcp-atlassian",
            "--jira-url=https://your-project.atlassian.net",
            "[email protected]",
            "--jira-token=your_token"
        ],
        env={}
    )
)

jfolaya8 avatar Jun 12 '25 13:06 jfolaya8

@jfolaya8 thank you <3

dttran-glo avatar Jun 12 '25 16:06 dttran-glo

This seems resolved already, by the content in the thread. If I'm wrong please feel free to reopen.

tpryan avatar Aug 12 '25 18:08 tpryan

Is there anyways to use the official server with bearer token stored else where?

phuoc-nguyen-ts avatar Aug 13 '25 05:08 phuoc-nguyen-ts

You should be able to wire things up using Cloud Secrets or any other third party secret manager. But thats's not wired into the ADK api at the moment.

tpryan avatar Aug 13 '25 16:08 tpryan