BigPizzaV3/CodexPlusPlus · error · anyhow::Error
JSON 里没有找到任何 MCP 服务器
Error message
JSON 里没有找到任何 MCP 服务器
What it means
parse_mcp_servers_json resolves the servers map from one of the supported wrapper shapes and then requires it to contain at least one server entry. If the resolved map is empty — e.g. {"mcpServers":{}} — there is nothing to import and the function bails.
Solutions
- Include at least one server entry under mcpServers/servers before importing.
- If the object is meant as a single server, give it a command or url field so looks_like_single_server recognizes it.
- Check the source config actually contains servers before triggering import.
Example fix
// before
{"mcpServers":{}}
// after
{"mcpServers":{"fetch":{"command":"uvx","args":["mcp-server-fetch"]}}} Defensive patterns
Strategy: validation
Validate before calling
function hasServers(text) {
const v = JSON.parse(text);
const map = v.mcpServers ?? v.servers ?? (isSingleServer(v) ? {single: v} : v);
return map && Object.keys(map).length > 0;
} Try / catch
match parse_mcp_servers_json(&text) {
Ok(import) => apply(import),
Err(e) if e.to_string().contains("没有找到任何") => ui.hint("配置里没有任何服务器条目"),
Err(e) => return Err(e),
} Prevention
- Verify Object.keys on the servers map before calling import
- Don't export empty config files as import sources
- Check the source app still has servers configured
- Treat {} and {"mcpServers":{}} as invalid input at the UI layer
When it happens
Trigger: Calling parse_mcp_servers_json with '{"mcpServers":{}}', '{"servers":{}}', or '{}' (an object that is neither wrapper nor single server, resolving to an empty map).
Common situations: Config file was emptied by another tool; user deleted all servers in the source app then exported; keys exist but values were stripped by an export filter.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/f9d14dd6ab398a13.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/mcp_config.rs:282
let Value::Object(root) = root else {
anyhow::bail!("JSON 顶层必须是对象");
};
let servers = if let Some(Value::Object(map)) = root.get("mcpServers") {
map.clone()
} else if let Some(Value::Object(map)) = root.get("servers") {
map.clone()
} else if looks_like_single_server(&root) {
// 单个 server 对象,没有 id,用占位 id 让用户在界面上改
let mut map = Map::new();
map.insert("mcp-server".to_string(), Value::Object(root));
map
} else {
root
};
if servers.is_empty() {
anyhow::bail!("JSON 里没有找到任何 MCP 服务器");
}
let mut import = McpJsonImport::default();
for (id, config) in servers {
let Value::Object(config) = config else {
import.warnings.push(format!("已跳过 {id}:配置不是对象"));
continue;
};
match json_server_to_toml(&id, &config, &mut import.warnings) {
Ok(toml_body) => import.entries.push(McpJsonEntry { id, toml_body }),
Err(error) => import.warnings.push(format!("已跳过 {id}:{error}")),
}
}
if import.entries.is_empty() {
anyhow::bail!("JSON 里没有可导入的 MCP 服务器");
}
Ok(import)View on GitHub (pinned to b1ed92e5e4)