Skip to content

feat: auto-connect via RABBITMQ_* env vars for mcp-aggregator compatibility#42

Open
mrnicegyu11 wants to merge 2 commits into
amazon-mq:mainfrom
ITISFoundation:feat/auto-connect-env-vars
Open

feat: auto-connect via RABBITMQ_* env vars for mcp-aggregator compatibility#42
mrnicegyu11 wants to merge 2 commits into
amazon-mq:mainfrom
ITISFoundation:feat/auto-connect-env-vars

Conversation

@mrnicegyu11
Copy link
Copy Markdown
Contributor

I run this server behind an MCP aggregator (fastmcp), and in that setup the subprocess of the mcp-server-rabbitmq does not stay around between calls. Whatever connection the LLM established through initialize_connection is gone by the next call. A bit tedious... This feature makes the situation a bit better.

The env-var naming and such are fully up for discussion, in case you guys have preferences. I'd love to see this merged upstream, then I could basically stop using custom forks of the mcp-server-rabbitmq since it will work for my usecase fully then. :--) If not, no worries as well, thanks for your time and consideration.

Cheers

Issue #, if available: n/a

Description of changes:
This PR adds a small _auto_connect_from_env() step at startup. When RABBITMQ_HOST, RABBITMQ_USERNAME and RABBITMQ_PASSWORD are present in the environment, the server connects on spawn and registers a broker into the existing multi-broker registry. Tools are then usable from the first call. If the variables are not set, nothing changes — manual initialization still works exactly as before.
Optional variables: RABBITMQ_PORT (default 5671), RABBITMQ_MANAGEMENT_PORT, RABBITMQ_USE_TLS (default true), RABBITMQ_ALIAS.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Stdio MCP servers start fresh each session — no connection state
survives. The LLM has to call initialize_connection before doing
anything useful, and it forgets roughly half the time.

Auto-connect from environment at startup when RABBITMQ_HOST,
RABBITMQ_USERNAME, and RABBITMQ_PASSWORD are set. Optional:
RABBITMQ_PORT, RABBITMQ_MANAGEMENT_PORT, RABBITMQ_USE_TLS,
RABBITMQ_ALIAS. If env vars are absent, behavior is unchanged.
@mrnicegyu11 mrnicegyu11 marked this pull request as ready for review May 7, 2026 15:37
Copy link
Copy Markdown
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems nice to have. Instead of many environment variables though we might be able to get away with a few URIs that contain all of the info:

export RABBITMQ_MANAGEMENT_ENDPOINT=http://guest:guest@localhost:15672
export RABBITMQ_AMQP_ENDPOINT=amqps://admin:pass@example.com:5671

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.

2 participants