-
Notifications
You must be signed in to change notification settings - Fork 615
[BUG]: MCP Servers with tool name starts with "_" is failing to add to gateway #2528
Description
🐞 Bug Summary
Briefly describe the issue or unexpected behavior.
The Problem: Gateway is erroring out with Invalid Tool Name
The Gateway is rejecting one of the tools because its name starts with "_".
The Error:
Value error, Tool name must start with a letter... input_value='_5gpt_query_by_market_id'
Error LOG:
2026-01-27 20:37:41,218 - mcpgateway.services.argon2_service - INFO - Initialized Argon2PasswordService with time_cost=3, memory_cost=65536, parallelism=1
2026-01-27 20:37:41,219 - mcpgateway.middleware.auth_middleware - INFO - ✓ Authenticated user: admin@verizon.com
2026-01-27 20:37:41,222 - mcpgateway.services.security_logger - INFO - Authentication attempt: Authentication successful for user admin@verizon.com
2026-01-27 20:37:41,223 - mcpgateway.services.structured_logger - INFO - [http_gateway] Request started: POST /admin/gateways
2026-01-27 20:37:41,228 - mcpgateway.services.argon2_service - INFO - Initialized Argon2PasswordService with time_cost=3, memory_cost=65536, parallelism=1
2026-01-27 20:37:41,231 - mcpgateway.admin - INFO - DEBUG: oauth_config_json from form = 'None'
2026-01-27 20:37:41,231 - mcpgateway.admin - INFO - DEBUG: Individual OAuth fields - grant_type='', issuer=''
2026-01-27 20:37:41,231 - mcpgateway.admin - INFO - DEBUG: auth_type from form: 'authheaders', oauth_config present: False
2026-01-27 20:37:41,636 - mcpgateway.services.gateway_service - ERROR - Gateway initialization failed for https://dev-langflow-atlas.verizon.com:7860/api/v1/mcp/project/5623a781-c68b-4130-a9a8-a1fce6482999/streamable: unhandled errors in a TaskGroup (1 sub-exception)
- Exception Group Traceback (most recent call last):
| File "/app/mcpgateway/services/gateway_service.py", line 2919, in _initialize_gateway
| capabilities, tools, resources, prompts = await self.connect_to_streamablehttp_server(url, authentication, ca_certificate)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/app/mcpgateway/services/gateway_service.py", line 3818, in connect_to_streamablehttp_server
| async with streamablehttp_client(url=server_url, headers=authentication, httpx_client_factory=get_httpx_client_factory) as (read_stream, write_stream, _get_session_id):
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/lib64/python3.12/contextlib.py", line 231, in aexit
| await self.gen.athrow(value)
| File "/app/.venv/lib64/python3.12/site-packages/mcp/client/streamable_http.py", line 717, in streamablehttp_client
| async with streamable_http_client(
| ^^^^^^^^^^^^^^^^^^^^^^^
| File "/usr/lib64/python3.12/contextlib.py", line 231, in aexit
| await self.gen.athrow(value)
| File "/app/.venv/lib64/python3.12/site-packages/mcp/client/streamable_http.py", line 647, in streamable_http_client
| async with anyio.create_task_group() as tg:
| ^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/app/.venv/lib64/python3.12/site-packages/anyio/_backends/_asyncio.py", line 783, in aexit
| raise BaseExceptionGroup(
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Exception Group Traceback (most recent call last):
| File "/app/.venv/lib64/python3.12/site-packages/mcp/client/streamable_http.py", line 670, in streamable_http_client
| yield (
| File "/app/.venv/lib64/python3.12/site-packages/mcp/client/streamable_http.py", line 722, in streamablehttp_client
| yield streams
| File "/app/mcpgateway/services/gateway_service.py", line 3819, in connect_to_streamablehttp_server
| async with ClientSession(read_stream, write_stream) as session:
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/app/.venv/lib64/python3.12/site-packages/mcp/shared/session.py", line 238, in aexit
| return await self._task_group.aexit(exc_type, exc_val, exc_tb)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/app/.venv/lib64/python3.12/site-packages/anyio/_backends/_asyncio.py", line 783, in aexit
| raise BaseExceptionGroup(
| ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
+-+---------------- 1 ----------------
| Traceback (most recent call last):
| File "/app/mcpgateway/services/gateway_service.py", line 3829, in connect_to_streamablehttp_server
| tools = [ToolCreate.model_validate(tool) for tool in tools]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| File "/app/.venv/lib64/python3.12/site-packages/pydantic/main.py", line 716, in model_validate
| return cls.pydantic_validator.validate_python(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| pydantic_core._pydantic_core.ValidationError: 1 validation error for ToolCreate
| name
| Value error, Tool name must start with a letter and contain only letters, numbers, and underscore [type=value_error, input_value='_5gpt_query_by_market_id', input_type=str]
| For further information visit https://errors.pydantic.dev/2.12/v/value_error
+------------------------------------
2026-01-27 20:37:41,637 - mcpgateway.services.gateway_service - ERROR - GatewayConnectionError in group: (GatewayConnectionError('Failed to initialize gateway at https://dev-langflow-atlas.verizon.com:7860/api/v1/mcp/project/5623a781-c68b-4130-a9a8-a1fce6482999/streamable'),)
2026-01-27 20:37:41,638 - mcpgateway.services.structured_logger - ERROR - [gateway_service] Gateway creation failed due to connection error
2026-01-27 20:37:41,641 - mcpgateway.services.structured_logger - ERROR - [http_gateway] Request completed: POST /admin/gateways - 502
2026-01-27 20:38:46,075 - mcpgateway.services.argon2_service - INFO - Initialized Argon2PasswordService with time_cost=3, memory_cost=65536, parallelism=1
2026-01-27 20:38:46,076 - mcpgateway.middleware.auth_middleware - INFO - ✓ Authenticated user: admin@verizon.com
2026-01-27 20:38:46,079 - mcpgateway.services.security_logger - INFO - Authentication attempt: Authentication successful for user admin@verizon.com
2026-01-27 20:38:46,080 - mcpgateway.services.structured_logger - INFO - [http_gateway] Request started: GET /admin/gateways/b55b64c8166540c6a2d08082c456a4ab
2026-01-27 20:38:46,085 - mcpgateway.services.argon2_service - INFO - Initialized Argon2PasswordService with time_cost=3, memory_cost=65536, parallelism=1
2026-01-27 20:38:46,087 - mcpgateway.services.structured_logger - INFO - [gateway_service] Gateway retrieved successfully
2026-01-27 20:38:46,090 - mcpgateway.services.structured_logger - INFO - [http_gateway] Request completed: GET /admin/gateways/b55b64c8166540c6a2d08082c456a4ab - 200
🧩 Affected Component
Select the area of the project impacted:
-
mcpgateway- API -
mcpgateway- UI (admin panel) -
mcpgateway.wrapper- stdio wrapper - Federation or Transports
- CLI, Makefiles, or shell scripts
- Container setup (Docker/Podman/Compose)
- Other (explain below)
🔁 Steps to Reproduce
- ...
- ...
- ...
🤔 Expected Behavior
What should have happened instead?
📓 Logs / Error Output
Paste any relevant stack traces or logs here.
🧠 Environment Info
You can retrieve most of this from the /version endpoint.
| Key | Value |
|---|---|
| Version or commit | e.g. v0.9.0 or main@a1b2c3d |
| Runtime | e.g. Python 3.11, Gunicorn |
| Platform / OS | e.g. Ubuntu 22.04, macOS |
| Container | e.g. Docker, Podman, none |
🧩 Additional Context (optional)
Add any configuration details, flags, or related issues.