BigPizzaV3/CodexPlusPlus · error

未知上下文类型:

Error message

未知上下文类型:{other}

What it means

context_table_name maps a context kind string ("mcp", "skill", "plugin", and plural variants) to its backing table name; any other kind is rejected with this error. It is an allowlist: only MCP servers, skills, and plugins are supported context types for this operation.

Solutions

  1. Use one of the supported kinds: "mcp", "skill", or "plugin" (or their plurals)
  2. Fix casing/typos — matching is exact ("mcpServer", not "MCP" or "mcpserver")
  3. If a new context type is genuinely needed, add it to the match in context_table_name
  4. Confirm you are calling the context API, not the config-file API, with this string

Example fix

// before
await listContext("tools")
// after
await listContext("plugins")
Defensive patterns

Strategy: validation

Validate before calling

const KINDS = new Set(['mcp','mcpServer','mcpServers','skill','skills','plugin','plugins']);
if (!KINDS.has(kind)) throw new Error(`unsupported context kind: ${kind}`);

Type guard

const isContextKind = (k) => ['mcp','mcpServer','mcpServers','skill','skills','plugin','plugins'].includes(k);

Try / catch

try { await listContext(kind); } catch (e) { if (String(e).includes('未知上下文类型')) { console.error(`Use mcp/skill/plugin, got: ${kind}`); } else throw e; }

Prevention

When it happens

Trigger: Calling the context-related command/lookup with kind values other than mcp/mcpServer/mcpServers/skill/skills/plugin/plugins — e.g. "extension", "tool", "agent", or an empty string. (Note: commands.rs:5821 has a similar error '未知配置文件类型' for config file types "config"/"auth"; do not confuse the two.)

Common situations: A UI or script passes a new/unfamiliar context category added by a newer Codex version that this build doesn't know; a typo like "mcpserver" or "Skill" (case-sensitive match); passing a config-file type where a context kind is expected.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/978d11e5f2724250. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/relay_config.rs:2643

                toml_body: body,
                enabled: context_entry_enabled(table),
            })
        })
        .collect()
}

fn table_body_to_string(table: &Table) -> String {
    let mut doc = DocumentMut::new();
    merge_toml_table_like(doc.as_table_mut(), table);
    normalize_optional_toml(doc)
}

fn context_table_name(kind: &str) -> anyhow::Result<&'static str> {
    match kind {
        "mcp" | "mcpServer" | "mcpServers" => Ok("mcp_servers"),
        "skill" | "skills" => Ok("skills"),
        "plugin" | "plugins" => Ok("plugins"),
        other => anyhow::bail!("未知上下文类型:{other}"),
    }
}

fn context_kind_name(table: &str) -> &'static str {
    match table {
        "mcp_servers" => "mcp",
        "skills" => "skill",
        "plugins" => "plugin",
        _ => "unknown",
    }
}

fn context_entry_summary(body: &str) -> String {
    body.lines()
        .map(str::trim)
        .find(|line| !line.is_empty() && !line.starts_with('#'))
        .unwrap_or("")
        .chars()

View on GitHub (pinned to b1ed92e5e4)