Skip to content

Passing A URL Parameter to SSE Transport #205

Closed
@maxxrdrgz

Description

@maxxrdrgz

Hello,

I'm trying to setup this MCP server as a remote server using SSE Transport. I'm trying to gauge how feasible it might be for me to modify the code to receive a url parameter from the client, and using that in the JiraFetcher (or the JiraClient) object. For example, in the server.py code, you can certainly parse URL parameters like my example below. But I'm having trouble passing the parameter elsewhere in the code. I'd be happy to contribute if someone else can nudge me in the right directions (or let me know if this is not possible).

The client's url might look like this:
"url": "http://SERVER:8000/sse?jira_api_token=JIRAPERSONALTOKEN",

async def run_server(transport: str = "stdio", port: int = 8000) -> None:
    """Run the MCP Atlassian server with the specified transport."""
    if transport == "sse":
        from mcp.server.sse import SseServerTransport
        from starlette.applications import Starlette
        from starlette.requests import Request
        from starlette.routing import Mount, Route

        sse = SseServerTransport("/messages/")

        async def handle_sse(request: Request) -> None:
            # Extract query parameters
            query_params = request.query_params
            api_key = query_params.get("jira_api_token")  # Get the API key from query parameters

            if not api_key:
                print("API key is missing!")
                return

            print(f"Received API Key: {api_key}")

            async with sse.connect_sse(
                request.scope, request.receive, request._send
            ) as streams:
                await app.run(
                    streams[0], streams[1], app.create_initialization_options()
                )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions