Skip to content

feat: add MCP_SERVER_ENDPOINT env var with transport auto-detection#1056

Open
koepalex wants to merge 2 commits intomodelcontextprotocol:mainfrom
koepalex:main
Open

feat: add MCP_SERVER_ENDPOINT env var with transport auto-detection#1056
koepalex wants to merge 2 commits intomodelcontextprotocol:mainfrom
koepalex:main

Conversation

@koepalex
Copy link

@koepalex koepalex commented Feb 4, 2026

Summary

modelcontextprotocol/inspector is a great tool, that I use regularly to test my own MCP servers. In my environment the server endpoint of the mcp server changes (e.g. running multiple instances, port already occupied etc.) to address this I use either dotnet aspire or docker compose which will start the mcp server along with the inspector. I would like to pass the currently used mcp server endpoint as environment variable.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Refactoring (no functional changes)
  • Test updates
  • Build/CI improvements

Changes Made

server/src/index.ts:

  • Added detectTransportFromEndpoint() function to auto-detect transport type from URL path
  • Added MCP_SERVER_ENDPOINT environment variable support
  • Updated /config endpoint to return effective server URL and auto-detected transport
  • CLI args (--server-url, --transport) take precedence over env var

README.md:

  • Added MCP_SERVER_ENDPOINT to the configuration table with description

Usage example:

SSE transport (auto-detected from /sse path)

MCP_SERVER_ENDPOINT=http://localhost:8080/sse npx @modelcontextprotocol/inspector

Streamable HTTP transport (auto-detected from /mcp path)

MCP_SERVER_ENDPOINT=http://localhost:8080/mcp npx @modelcontextprotocol/inspector

Related Issues

Testing

  • Tested in UI mode
  • Tested in CLI mode
  • Tested with STDIO transport
  • Tested with SSE transport
  • Tested with Streamable HTTP transport
  • Added/updated automated tests
  • Manual testing performed

Test Results and/or Instructions

$env:MCP_SERVER_ENDPOINT='http://localhost:1234/sse'
npm run start
image
$env:MCP_SERVER_ENDPOINT='http://localhost:5678/mcp'
npm run start
image

Checklist

  • Code follows the style guidelines (ran npm run prettier-fix)
  • Self-review completed
  • Code is commented where necessary
  • Documentation updated (README, comments, etc.)

Breaking Changes

Additional Context

As this is a relatively small change, I hope it can get merged before V2 (architecture changes) are done, even if it is not a bugfix.

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.

1 participant