Skip to content

fix: correct endpoint selection for streamable HTTP auto-registration#29

Open
ABruneel04 wants to merge 2 commits intocontextforge-org:mainfrom
ABruneel04:bugfix/auto-registration
Open

fix: correct endpoint selection for streamable HTTP auto-registration#29
ABruneel04 wants to merge 2 commits intocontextforge-org:mainfrom
ABruneel04:bugfix/auto-registration

Conversation

@ABruneel04
Copy link

Description

Summary

Fixes auto-registration endpoint selection when using --expose-streamable-http flag. The system was incorrectly attempting to register at the /sse endpoint instead of /mcp for Streamable HTTP connections.

Problem

When running cforge run with the --expose-streamable-http flag, auto-registration failed with a 404 error because the system attempted to register at the /sse endpoint, which doesn't exist for Streamable HTTP servers.

Solution

Updated the boolean logic in cforge/commands/server/run.py to correctly determine the endpoint type:

Before:

is_sse = expose_sse or expose_streamable_http or (not expose_sse and not expose_streamable_http)

After:

is_sse = expose_sse or not expose_streamable_http

This ensures:

  • When only --expose-streamable-http is enabled → uses /mcp endpoint
  • When only --expose-sse is enabled → uses /sse endpoint
  • When both flags are enabled → defaults to /sse endpoint (SSE takes priority)
  • When neither flag is specified → defaults to /sse endpoint

Testing

Added comprehensive test coverage for all endpoint selection scenarios:

  • test_run_registration_with_streamable_http_only - Verifies /mcp endpoint is used when only streamable HTTP is enabled
  • test_run_registration_with_both_protocols_defaults_to_sse - Verifies SSE takes priority when both protocols are enabled
  • test_run_registration_without_protocol_flags_defaults_to_sse - Verifies SSE is the default when no flags are specified

Live Testing: Tested end-to-end with the original failing command to confirm the fix resolves the auto-registration issue.

Changes

  • Modified cforge/commands/server/run.py - Fixed endpoint selection logic
  • Added 94 lines of test coverage in tests/commands/server/test_run.py

Closes

Closes #27

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • My code follows the style guidelines of this project (Black, isort, Ruff, Pylint)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes
  • I have signed my commits with DCO (git commit -s)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Auto-registration not working with cforge run --expose-streamable-http

1 participant