step mcp add accepts server names that produce invalid MCP tool names
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 75/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- nodejs, typescript
- Lĩnh vực
- backend-api-design, cli
Hướng nghiên cứu
Vấn đề nằm trong apps/cli/src/main.ts, nơi lệnh step mcp add chấp nhận tên máy chủ mà không có xác thực. So sánh với sanitizeServerName trong packages/coding-agent/src/step/mcp-import.ts. Bản sửa lỗi nên xác thực hoặc làm sạch tên máy chủ để khớp với bộ ký tự tên công cụ ([a-zA-Z0-9_-]). Kiểm tra bằng cách thêm một máy chủ có tên không hợp lệ và xác minh rằng nó bị từ chối hoặc được làm sạch, và rằng các tên công cụ kết quả (ví dụ: my.server__hello) là hợp lệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What happened?
step mcp add accepts any string as the server name — no charset or length validation. That name is then used verbatim as the model-facing tool-name prefix: packages/coding-agent/src/step/mcp.ts:461 builds
const name = `${server.name}__${sanitizeName(remote.name)}`;
The remote tool name is sanitized; the server name is not, and the provider layer sends it through unchanged. A server added as my.server therefore registers tools like my.server__hello, which violates the tool-name charset both wire protocols require (OpenAI ^[a-zA-Z0-9_-]{1,64}$, Anthropic ^[a-zA-Z0-9_-]{1,128}$). Once such a server connects, every request fails with an API error that doesn't point at the config entry.
The MCP import path already enforces exactly this invariant — sanitizeServerName in packages/coding-agent/src/step/mcp-import.ts, with a comment saying the server name is "restricted to what a tool name may contain". step mcp add (in apps/cli/src/main.ts) is the one path that skips it. Long names can also push server__tool past the 64-char limit.
Steps to reproduce
step mcp add "my.server" -- npx -y some-mcp-server # accepted, stored as-is
step mcp list
cat ~/.stepcode/config.toml
Verified on 0.1.0 built from source (main @ cb5fc14): names like my server/x and my.server demo are accepted and written to config.toml unchanged, and createRemoteTool registers <name>__<tool> with the raw prefix. The TUI /mcp command and the plugin marketplace are not affected — step mcp add is the only unvalidated write path.
Expected behavior
step mcp add should reject (or sanitize with a notice, like the import path does) names outside [a-zA-Z0-9_-], or registration should sanitize the prefix defensively. I'd be happy to implement this — let me know which side you prefer.
Version
0.1.0 (built from source, main @ cb5fc14)
Note: I used an AI assistant to help polish the wording of this report; the repro steps and code reading are my own and were run locally.
- Ngôn ngữ chính
- TypeScript
- Star
- 850
- Fork
- 62
- Merge trung bình
- 1 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 56
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của stepfun-ai/Step-Code
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
stepfun-ai/Step-Code#269 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/build bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stepfun-ai/Step-Code#190 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/tools bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stepfun-ai/Step-Code#186 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/tools bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stepfun-ai/Step-Code#185 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/tools bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
stepfun-ai/Step-Code#184 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của stepfun-ai/Step-Code
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jessepollak/home#2223 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
grep fixture corpus test follows the corpus's loop symlink under the receipt runner (fails on main)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
code-yeongyu/senpi#3756 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
org:external package:deepagents priority:triage topic:memory topic:middleware type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
langchain-ai/deepagents#7059 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
osmlab/name-suggestion-index#12992 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
hemilabs/ui-monorepo#2506 ·
Maintainer thường phản hồi trong vòng 1 ngày