MCP ask_codebase rejects explicit languageModel: getLanguageModelKey includes displayName which the MCP schema doesn't expose
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 冷清
- 技术栈
- typescript
- 领域
- api
调研方向
从 packages/web/src/features/mcp/askCodebase.ts 开始,检查请求的 languageModel 如何与已配置的模型进行匹配;将这条路径与 packages/web/src/features/chat/utils.ts 中的 getLanguageModelKey 进行比较。完成的标准是,ask_codebase 接受已配置模型的 schema 的 {provider, model} 形式,同时保留现有的默认行为以及 getLanguageModelKey 的任何其他用途。
由索引模型根据 Issue 内容生成。
描述
Summary
When calling the MCP tool ask_codebase with an explicit languageModel parameter, the request is rejected with 400 Language model '<provider>/<model>' is not configured. — even when list_language_models clearly shows that exact model configured.
Version
- Sourcebot
v4.16.11(Helm chart0.1.76) - MCP client
@sourcebot/mcp@1.0.18(vianpx -y @sourcebot/mcp@latest)
Reproduction
Config in sourcebot.json / helm values sourcebot.config:
models:
- provider: anthropic
model: claude-sonnet-4-6
displayName: Claude Sonnet 4.6
token:
env: ANTHROPIC_API_KEY
- provider: anthropic
model: claude-opus-4-7
displayName: Claude Opus 4.7 (slow, highest quality)
token:
env: ANTHROPIC_API_KEY
- Call
list_language_modelsvia MCP — returns both models as expected:
[
{"provider":"anthropic","model":"claude-sonnet-4-6","displayName":"Claude Sonnet 4.6"},
{"provider":"anthropic","model":"claude-opus-4-7","displayName":"Claude Opus 4.7 (slow, highest quality)"}
]
- Call
ask_codebasewith an explicit language model of the exact shape the tool's JSON schema requires ({provider, model}):
{
"query": "...",
"languageModel": {"provider": "anthropic", "model": "claude-opus-4-7"}
}
Result:
{"statusCode":400,"errorCode":"INVALID_REQUEST_BODY","message":"Language model 'anthropic/claude-opus-4-7' is not configured."}
Same happens for claude-sonnet-4-6 — every explicit model is rejected, regardless of which one.
ask_codebase without languageModel works fine — the implicit default (first model in config) is used correctly. So the failure is specifically in the explicit-selection path.
Root cause
getLanguageModelKey in packages/web/src/features/chat/utils.ts builds the match key from provider + model + displayName:
export const getLanguageModelKey = (model: LanguageModelInfo) => {
return `${model.provider}-${model.model}-${model.displayName}`;
}
askCodebase uses this function to match the requested model against configured models in packages/web/src/features/mcp/askCodebase.ts:
const matchingModel = configuredModels.find(
(m) => getLanguageModelKey(m) === getLanguageModelKey(requestedLanguageModel)
);
The MCP JSON schema for ask_codebase.languageModel only requires {provider, model} — displayName is not part of the schema and clients cannot provide it:
languageModel: {
provider: (required),
model: (required)
}
So at match time:
- Configured entry key:
anthropic-claude-opus-4-7-Claude Opus 4.7 (slow, highest quality) - Requested entry key:
anthropic-claude-opus-4-7-undefined
Keys never match → 400 for any explicit selection.
Suggested fix
Either:
- Match on provider+model only in
askCodebase.ts(simplest —displayNameis a cosmetic label, not an identity key):const matchingModel = configuredModels.find( (m) => m.provider === requestedLanguageModel.provider && m.model === requestedLanguageModel.model ); - Or drop
displayNamefromgetLanguageModelKeyso the match is consistent with the externally-visible identity.
Option 1 is the minimal change that keeps getLanguageModelKey untouched if it is used elsewhere where displayName matters.
Impact
- MCP clients cannot route a specific question to a non-default model — the dropdown selection in the Web UI works because the UI presumably submits the full
LanguageModelInfo(includingdisplayName), but the MCP tool schema intentionally does not exposedisplayName, so there is no workaround. - Defaulting to the first model in config still works, so this is not a total outage, but it removes a documented MCP capability.
Happy to open a PR if helpful.
- 主要语言
- TypeScript
- 星标
- 3.9k
- 派生
- 374
- 平均合并
- 21 小时 18 分钟
- 30 天内合并 PR
- 39
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sourcebot-dev/sourcebot 的其他 Issue
-
bug triage needed
难度 2/5 1-3 小时 新手友好度 84/100
sourcebot-dev/sourcebot#1681 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
sourcebot-dev/sourcebot#1633 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
sourcebot-dev/sourcebot#1384 · 4 条评论 ·
-
bug triage needed
难度 3/5 1-2 天 新手友好度 48/100
sourcebot-dev/sourcebot#1661 · 1 条评论 ·
-
Feature
难度 4/5 3-5 天 新手友好度 50/100
sourcebot-dev/sourcebot#1659 · 1 条评论 ·
查看 sourcebot-dev/sourcebot 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
bug v2
难度 2/5 1-3 小时 新手友好度 75/100
modelcontextprotocol/inspector#2458 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 75/100
railmapgen/rmp-gallery#4068 ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
难度 2/5 1-3 小时 新手友好度 70/100
carbon-design-system/ibm-products#9907 ·