Skip to content

Running Simple Auth Github Example throws 404 error #679

Closed

Description

@mopg

Describe the bug
When running the example in https://github.com/modelcontextprotocol/python-sdk/blob/main/examples/servers/simple-auth/mcp_simple_auth/server.py exactly as is the MCP client (Claude Code in this case) keeps returning

MCP server "github-server" Error: SSE error: Non-200 status code (404)
MCP server "github-server" Connection failed: SSE error: Non-200 status code (404)

In the server output it shows:

INFO:     Started server process [28396]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://localhost:3002 (Press CTRL+C to quit)
INFO:     ::1:58316 - "GET / HTTP/1.1" 404 Not Found

To Reproduce
Steps to reproduce the behavior (instructions in README.md):

  1. uv run mcp-simple-auth
  2. claude mcp add to add server
  3. claude, which throws error
  4. See error

Expected behavior
The MCP server starting properly.

Desktop (please complete the following information):

  • OS: MacOS

Activity

  1. lukekulik commented on May 12, 2025

    @lukekulik

    I'm running into the same issue, could one of the maintainers take a look?

  2. self-assigned this
    on May 13, 2025
  3. ihrpr commented on May 17, 2025

    @ihrpr
    Contributor

    @mopg have you tried running with inspector?

    Please can you share the parameters you are using to set up the server?

  4. mopg commented on May 17, 2025

    @mopg
    ContributorAuthor

    Thanks for help, @ihrpr!

    So with inspector, I'm now getting the following (also using the latest server.py from a few days ago) (so 401 instead of 404):

    New SSE connection. NOTE: The sse transport is deprecated and has been replaced by streamable-http
    Query parameters: [Object: null prototype] {
      url: 'http://localhost:8000/sse',
      transportType: 'sse'
    }
    SSE transport: url=http://localhost:8000/sse, headers=Accept
    Received 401 Unauthorized from MCP server: SSE error: Non-200 status code (401)
    

    And on the server logs

    INFO:     Started server process [27494]
    INFO:     Waiting for application startup.
    INFO:     Application startup complete.
    INFO:     Uvicorn running on http://localhost:8000 (Press CTRL+C to quit)
    INFO:     ::1:61155 - "GET /sse HTTP/1.1" 401 Unauthorized
    INFO:     ::1:61195 - "GET /sse HTTP/1.1" 401 Unauthorized
    

    I get this after clicking "Connect" with the parameters below in the inspector.
    Image

    I ran the inspector using npx @modelcontextprotocol/inspector uv run mcp-simple-auth

    This is all using version mcp==1.9.0.

  5. ihrpr commented on May 19, 2025

    @ihrpr
    Contributor

    thanks, there is Inspector issues we are looking at now: modelcontextprotocol/inspector#390

  6. mopg commented on May 19, 2025

    @mopg
    ContributorAuthor

    Eh ok, seeing the inspector issues indeed. But I'm still getting this 401 error also when using Claude Code. So that seems to be unrelated for this particular issue.

    @ihrpr are you able to run the example without any problems then? (Just in Claude, Cursor, wherever)

  7. ihrpr commented on May 19, 2025

    @ihrpr
    Contributor

    @ihrpr are you able to run the example without any problems then? (Just in Claude, Cursor, wherever)

    yes, I can run with test clients as well as now with inspector (after the inspector fix)

    Have you made any change to the server?

  8. RamyaPrasad24 commented on May 20, 2025

    @RamyaPrasad24

    I initially faced the same issue, now able to run with inspector.
    Thanks for the fix!
    However, I am now encountering a new issue with my simple client setup to communicate with the server

    httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'http://localhost:8000/sse' error

    My client code :

    from mcp import ClientSession
    from mcp.client.sse import sse_client
    import anyio
    from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
    from mcp.shared.message import SessionMessage
    from mcp.shared.session import RequestResponder
    import mcp.types as types
    import argparse
    import logging
    import sys
    from functools import partial
    from urllib.parse import urlparse
    
    if not sys.warnoptions:
        import warnings
    
        warnings.simplefilter("ignore")
    
    logging.basicConfig(level=logging.INFO)
    logger = logging.getLogger("client")
    
    async def message_handler(
        message: RequestResponder[types.ServerRequest, types.ClientResult]
        | types.ServerNotification
        | Exception,
    ) -> None:
        if isinstance(message, Exception):
            logger.error("Error: %s", message)
            return
    
        logger.info("Received message from server: %s", message)
    
    async def run_session(
        read_stream: MemoryObjectReceiveStream[SessionMessage | Exception],
        write_stream: MemoryObjectSendStream[SessionMessage],
        client_info: types.Implementation | None = None,
    ):
        async with ClientSession(
            read_stream,
            write_stream,
            message_handler=message_handler,
            client_info=client_info,
        ) as session:
            logger.info("Initializing session")
            await session.initialize()
            logger.info("Initialized")
          
    async def main():
        async with sse_client("http://localhost:8000/sse") as (
            read_stream,
            write_stream,
            _,
        ):
            # Create a session using the client streams
            async with ClientSession(read_stream, write_stream) as session:
                # Initialize the connection
                await session.initialize()
                # List available tools
                tools = await session.list_tools()
                print("Available Tools:", tools)
                # Call a tool
                tool_result = await session.call_tool("get_user_profile")
    
    if __name__ == "__main__":
        anyio.run(main)
    

    @ihrpr Could you please assist in resolving this error? Any guidance on how to handle authentication or properly configure my client would be greatly appreciated.

    Thank you!

  9. felixweinberger commented on Oct 3, 2025

    @felixweinberger
    Contributor

    Closing as initial inspector issue has been resolved.

    If there's still an issue you're facing please feel free to reopen or open a new one with the detailed repro!

  10. added
    bugSomething isn't working
    authIssues and PRs related to Authentication / OAuth
    on Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

authIssues and PRs related to Authentication / OAuthbugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions