Skip to content

502 while using localhost sse #2707

@DoctorReid

Description

@DoctorReid

** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.

Describe the bug

Try to connect to localhost sse mcp server but got 502

To Reproduce

  1. Run mcp server in local, other clients can connect to it.
import datetime

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("real-fastmcp-server", port=9999)

@mcp.tool()
def echo(text: str) -> str:
    """
    Echo back input text with timestamp

    Args:
        text: input text

    Returns:
        str: input text with timestamp
    """
    timestamp = datetime.datetime.now().isoformat()
    return f"[{timestamp}] Echo: {text}"


if __name__ == "__main__":
    mcp.run(transport='sse')
  1. Try to connect to it
import asyncio

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

async def main():
    connection_params = SseConnectionParams(url="http://localhost:9999/sse")
    toolset = MCPToolset(connection_params=connection_params)
    tools = await toolset.get_tools()

if __name__ == "__main__":
    asyncio.run(main())
  1. Error occurs
    | httpx.HTTPStatusError: Server error '502 Bad Gateway' for url 'http://localhost:9999/sse'

Expected behavior
Should be able to connect to mcp server

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Python version(python -V): 3.11
  • ADK version(pip show google-adk): 1.12.0

Model Information:
For example, which model is being used.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

mcp[Component] Issues about MCP supporttools[Component] This issue is related to tools

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions