Skip to content

[model-gateway][doc] Add STDIO Explicitly to Example in README#14393

Merged
slin1237 merged 2 commits intosgl-project:mainfrom
xuwenyihust:wenyixu-update-gateway-mcp-readme
Dec 4, 2025
Merged

[model-gateway][doc] Add STDIO Explicitly to Example in README#14393
slin1237 merged 2 commits intosgl-project:mainfrom
xuwenyihust:wenyixu-update-gateway-mcp-readme

Conversation

@xuwenyihust
Copy link
Contributor

Motivation

There's a small discrepancy between the README and the current implementation,
The README.md suggests that for an stdio transport, the protocol field is optional and can be inferred from the presence of a command
with example

servers:
  - name: "filesystem"
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
    required: false

...
`protocol`: Protocol type (`"sse"` or `"streamable"`; STDIO is inferred from `command`)
...

But i realized that protocol field could be mandatory during McpTransport deserialization, and omitting protocol: "stdio" will cause an error

Screenshot 2025-12-04 at 12 02 35 PM

Modifications

Update README to explictly set protocol as stdio.

Accuracy Tests

Can successfully connect with protocol: "stdio" added.

servers:
  - name: "filesystem"
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-filesystem", "./tmp"]
    protocol: "stdio"
    required: false
Screenshot 2025-12-04 at 12 16 12 PM Screenshot 2025-12-04 at 12 16 32 PM

Checklist

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Dec 4, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @xuwenyihust, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an inconsistency in the sgl-router's README.md by updating the example configuration and the description of the protocol field. The change ensures that users correctly configure STDIO transport by explicitly specifying protocol: "stdio", preventing potential deserialization errors and improving documentation accuracy.

Highlights

  • Documentation Correction: The README.md has been updated to explicitly include protocol: "stdio" in the example configuration for STDIO transport, addressing a discrepancy where the protocol was previously suggested to be inferable.
  • Protocol Field Clarification: The description of the protocol field in the documentation has been revised to explicitly list "stdio" as a valid protocol type, alongside "sse" and "streamable", reflecting its mandatory nature for STDIO transport.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses a documentation issue in README.md regarding the MCP configuration for stdio transports. The documentation previously suggested that the protocol field was optional, while the implementation requires it to be explicitly declared. The changes update the example and the field description to reflect the correct usage, which is a valuable clarification. I have one minor suggestion to improve the readability of the updated documentation.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@slin1237 slin1237 merged commit 78647e0 into sgl-project:main Dec 4, 2025
56 checks passed
yingluosanqian pushed a commit to yingluosanqian/sglang that referenced this pull request Dec 4, 2025
tonyluj pushed a commit to openanolis/sglang that referenced this pull request Dec 5, 2025
tonyluj pushed a commit to openanolis/sglang that referenced this pull request Dec 5, 2025
yuchengz816-bot pushed a commit to yuchengz816-bot/sglang that referenced this pull request Dec 8, 2025
tonyluj pushed a commit to openanolis/sglang that referenced this pull request Dec 12, 2025
tonyluj pushed a commit to openanolis/sglang that referenced this pull request Dec 12, 2025
tonyluj pushed a commit to openanolis/sglang that referenced this pull request Dec 12, 2025
@zhaotyer
Copy link

Motivation

There's a small discrepancy between the README and the current implementation, The README.md suggests that for an stdio transport, the protocol field is optional and can be inferred from the presence of a command with example

servers:
  - name: "filesystem"
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
    required: false

...
`protocol`: Protocol type (`"sse"` or `"streamable"`; STDIO is inferred from `command`)
...

But i realized that protocol field could be mandatory during McpTransport deserialization, and omitting protocol: "stdio" will cause an error

Screenshot 2025-12-04 at 12 02 35 PM ## Modifications Update README to explictly set `protocol` as `stdio`.

Accuracy Tests

Can successfully connect with protocol: "stdio" added.

servers:
  - name: "filesystem"
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-filesystem", "./tmp"]
    protocol: "stdio"
    required: false

Screenshot 2025-12-04 at 12 16 12 PM Screenshot 2025-12-04 at 12 16 32 PM

Checklist

This MCP service can start normally, but how do I use it?
I start filesystem mcp and qwen3-30b-a3b-2507-instruct
Start command:
python3 -m sglang_router.launch_router --host 0.0.0.0 --port 30000 --mcp-config-path ./mcp-config.yaml --policy cache_aware --worker-urls http://172.17.124.39:3218
mcp-config.yaml

servers:
  - name: "filesystem"
    command: "npx"
    args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
    protocol: "stdio"
    required: false

pool:
  max_connections: 100
  idle_timeout: 300

inventory:
  enable_refresh: true
  tool_ttl: 300
  refresh_interval: 300

and test_mcp.py

import openai

# 配置客户端
client = openai.OpenAI(
    base_url="http://localhost:30000/v1",
    api_key="not-used",
)

# 正确的filesystem MCP工具定义
filesystem_tool = {
    "type": "mcp",
    "server_label": "filesystem",
    "server_description": "Filesystem access server",
    "require_approval": "never",
    "server_url": "stdio://filesystem",  # 必须包含server_url
}

# 发送请求
try:
    response = client.responses.create(
        model="atom",
        input="请列出 /tmp 目录中的所有文件",
        tools=[filesystem_tool],
        stream=False,
        tool_choice="auto",
    )
    
    print(f"请求成功: {response.id}")
    print(f"状态: {response.status}")
    
    # 处理响应...
    
except Exception as e:
    print(f"错误: {e}")

model server error log:

[2026-01-28 09:17:25] INFO:     10.224.1.1:13249 - "POST /v1/responses HTTP/1.1" 500 Internal Server Error
[2026-01-28 09:17:25] ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/fastapi/applications.py", line 1139, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/applications.py", line 107, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/cors.py", line 85, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/exceptions.py", line 63, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.12/dist-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 716, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 736, in app
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 290, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 119, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 105, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 385, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 284, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/sgl-workspace/sglang/python/sglang/srt/entrypoints/http_server.py", line 1272, in v1_responses_request
    request_obj = ResponsesRequest(**request)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ResponsesRequest
tools.0.type
  Input should be 'web_search_preview' or 'code_interpreter' [type=literal_error, input_value='mcp', input_type=str]
    For further information visit https://errors.pydantic.dev/2.12/v/literal_error
[2026-01-28 09:17:25] INFO:     10.224.1.1:18446 - "POST /v1/responses HTTP/1.1" 500 Internal Server Error
[2026-01-28 09:17:25] ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/dist-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/fastapi/applications.py", line 1139, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/applications.py", line 107, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/cors.py", line 85, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/middleware/exceptions.py", line 63, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.12/dist-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 716, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 736, in app
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/routing.py", line 290, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 119, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.12/dist-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 105, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 385, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/fastapi/routing.py", line 284, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/sgl-workspace/sglang/python/sglang/srt/entrypoints/http_server.py", line 1272, in v1_responses_request
    request_obj = ResponsesRequest(**request)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/dist-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for ResponsesRequest
tools.0.type
  Input should be 'web_search_preview' or 'code_interpreter' [type=literal_error, input_value='mcp', input_type=str]
    For further information visit https://errors.pydantic.dev/2.12/v/literal_error

gateway error log:

026-01-28 09:16:52  INFO http_request{method=GET uri=/workers version=HTTP/1.1 module="smg" request_id="req-8nROlzEtKCBbsAUMJSHp5VNP"}: smg::request: /home/runner/work/sglang/sglang/src/middleware.rs:310: started processing request
2026-01-28 09:16:52  INFO http_request{method=GET uri=/workers version=HTTP/1.1 module="smg" request_id="req-8nROlzEtKCBbsAUMJSHp5VNP" status_code=200 latency=323}: smg::response: /home/runner/work/sglang/sglang/src/middleware.rs:359: finished processing request
2026-01-28 09:17:24  INFO http_request{method=POST uri=/v1/responses version=HTTP/1.1 module="smg" request_id="resp-SN7quU9R2BCCTOJbw837wk5l"}: smg::request: /home/runner/work/sglang/sglang/src/middleware.rs:310: started processing request
2026-01-28 09:17:24 ERROR http_request{method=POST uri=/v1/responses version=HTTP/1.1 module="smg" request_id="resp-SN7quU9R2BCCTOJbw837wk5l" status_code=500 latency=452391}: smg::response: /home/runner/work/sglang/sglang/src/middleware.rs:349: request failed with server error
2026-01-28 09:17:25  INFO http_request{method=POST uri=/v1/responses version=HTTP/1.1 module="smg" request_id="resp-bFz41QezkAXL3EWPrHbRlfGj"}: smg::request: /home/runner/work/sglang/sglang/src/middleware.rs:310: started processing request
2026-01-28 09:17:25  INFO http_request{method=POST uri=/v1/responses version=HTTP/1.1 module="smg" request_id="resp-bFz41QezkAXL3EWPrHbRlfGj"}: smg::core::circuit_breaker: /home/runner/work/sglang/sglang/src/core/circuit_breaker.rs:286: Circuit breaker state transition: closed -> open
2026-01-28 09:17:25 ERROR http_request{method=POST uri=/v1/responses version=HTTP/1.1 module="smg" request_id="resp-bFz41QezkAXL3EWPrHbRlfGj" status_code=500 latency=418309}: smg::response: /home/runner/work/sglang/sglang/src/middleware.rs:349: request failed with server error
2026-01-28 09:17:26  INFO http_request{method=POST uri=/v1/responses version=HTTP/1.1 module="smg" request_id="resp-OAXbgxK6X850puuUQSwKZum5"}: smg::request: /home/runner/work/sglang/sglang/src/middleware.rs:310: started processing request
2026-01-28 09:17:27 ERROR http_request{method=POST uri=/v1/responses version=HTTP/1.1 module="smg" request_id="resp-OAXbgxK6X850puuUQSwKZum5" status_code=503 latency=422915}: smg::response: /home/runner/work/sglang/sglang/src/middleware.rs:349: request failed with server error

I want to know how to test Filesystem MCP?
@xuwenyihust

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

Labels

documentation Improvements or additions to documentation model-gateway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments