Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

step mcp add accepts server names that produce invalid MCP tool names

未关闭 适合新手
#140 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
nodejs, typescript

调研方向

问题位于 apps/cli/src/main.ts,其中 step mcp add 命令在没有验证的情况下接受服务器名称。请与 packages/coding-agent/src/step/mcp-import.ts 中的 sanitizeServerName 进行比较。修复应验证或清理服务器名称,以匹配工具名称字符集 ([a-zA-Z0-9_-])。通过添加具有无效名称的服务器进行测试,并验证其被拒绝或清理,以及生成的工具名称(例如 my.server__hello)是有效的。

由索引模型根据 Issue 内容生成。

描述

untriaged
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.

主要语言
TypeScript
星标
1k
派生
65
平均合并
1 天 7 小时
30 天内合并 PR
56

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

stepfun-ai/Step-Code 的其他 Issue

查看 stepfun-ai/Step-Code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。