Skip to content

MCP server: fix config generation (cwd, env, per-client differences) #395

Closed

Description

@admarble

MCP Config Generation Gaps

Problem

getSequantMcpConfig() in src/lib/mcp-config.ts returns a minimal config:

{ command: "npx", args: ["sequant@latest", "serve"] }

This config works in Cursor (runs from workspace root) but fails in Claude Desktop (runs from an undefined directory, can't find the project).

Additionally, sequant init auto-adds this same incomplete config to all detected clients without per-client adjustments.

Issues

1. Missing cwd for Claude Desktop

Claude Desktop spawns MCP servers without a project-aware working directory. Without cwd, the server can't find .sequant/settings.json, the git repo, or worktrees. Every Claude Desktop user will get a broken setup.

Fix: getSequantMcpConfig() should accept a projectDir parameter and include cwd for clients that need it.

2. Auth guidance missing from config

The issue's design section showed "env": { "ANTHROPIC_API_KEY": "..." } but this is wrong for Max plan users who authenticate via claude login. The config should not hardcode an API key requirement.

Fix: Only include env field when ANTHROPIC_API_KEY is already set in the current environment. Never include it as a placeholder — it confuses Max plan users and could overwrite working OAuth auth.

3. All clients get identical config

sequant init writes the same JSON to Claude Desktop, Cursor, and VS Code configs. But:

  • Cursor doesn't need cwd (runs from workspace)
  • Claude Desktop needs cwd (doesn't run from project)
  • VS Code + Continue may need cwd depending on extension behavior

Fix: addSequantToMcpConfig() should accept a client type and generate appropriate config per client.

Acceptance Criteria

  • getSequantMcpConfig() accepts projectDir and clientType parameters
  • Claude Desktop config includes cwd: process.cwd() (absolute path)
  • Cursor config omits cwd (not needed)
  • env.ANTHROPIC_API_KEY is only included when the env var is currently set
  • sequant init generates per-client configs with correct fields
  • Docs example configs match what sequant init generates
  • Tests cover per-client config generation

Files to Change

  • src/lib/mcp-config.ts — getSequantMcpConfig(), addSequantToMcpConfig()
  • src/lib/mcp-config.test.ts — per-client test cases
  • src/commands/init.ts — pass client type to config generator

Activity

  1. added
    bug
    multi-agent
    on Mar 23, 2026
  2. added a commit that references this issue on Mar 24, 2026
  3. admarble commented on Mar 24, 2026

    @admarble
    ContributorAuthor

    Exec Phase Complete

    AC Coverage

    AC Description Status
    AC-1 getSequantMcpConfig() accepts projectDir and clientType ✅
    AC-2 Claude Desktop config includes cwd ✅
    AC-3 Cursor config omits cwd ✅
    AC-4 env.ANTHROPIC_API_KEY only when set ✅
    AC-5 sequant init generates per-client configs ✅
    AC-6 Docs match generated configs ✅
    AC-7 Tests cover per-client config ✅

    Key Files Changed

    • src/lib/mcp-config.ts — Added McpClientType, updated getSequantMcpConfig() and addSequantToMcpConfig()
    • src/lib/mcp-config.test.ts — Added 7 new per-client tests (17 total)
    • src/commands/init.ts — Passes clientType to config generator
    • docs/features/mcp-server.md — Updated auto-setup note
    • CHANGELOG.md — Added entry

    Quality Gates

    • npm run build ✅
    • npm run lint ✅
    • npm test ✅ (1843/1843)

    PR

    PR #412: #412

  4. admarble commented on Mar 24, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #395

    AC Coverage

    AC Source Description Status Notes
    AC-1 Original getSequantMcpConfig() accepts projectDir and clientType MET Function signature updated with optional {projectDir?, clientType?} params
    AC-2 Original Claude Desktop config includes cwd: process.cwd() MET CLIENTS_NEEDING_CWD set includes claude-desktop; falls back to process.cwd()
    AC-3 Original Cursor config omits cwd MET cursor not in CLIENTS_NEEDING_CWD set — cwd never added
    AC-4 Original env.ANTHROPIC_API_KEY only included when set MET Conditional on process.env.ANTHROPIC_API_KEY being truthy
    AC-5 Original sequant init generates per-client configs MET init.ts passes client.clientType to addSequantToMcpConfig()
    AC-6 Original Docs example configs match what sequant init generates MET Docs show cwd for Claude Desktop/VS Code, omit for Cursor, env conditional
    AC-7 Original Tests cover per-client config generation MET 17 tests: per-client cwd, env presence/absence, clientType mapping, addSequantToMcpConfig

    Coverage: 7/7 AC items fully met


    Quality Plan Verification

    N/A — No quality plan found in issue comments


    CI Status

    Check State Bucket Impact
    build (20.x) SUCCESS pass ✅ MET
    build (22.x) SUCCESS pass ✅ MET
    validate-skills SUCCESS pass ✅ MET
    typecheck SUCCESS pass ✅ MET
    validate-plugin SUCCESS pass ✅ MET

    CI Summary: 5 passed, 0 pending, 0 failed


    Stale Branch Check

    Check Value
    Commits behind main 0
    Status ✅ OK

    Quality Metrics

    Metric Value Status
    Type issues (any) 0 OK
    Deleted tests 0 OK
    Files changed 5 OK
    Lines added +145 -
    Lines deleted -8 -

    Build Verification

    N/A — Build passed (local and CI)


    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    src/lib/mcp-config.ts Standard ✅ Yes src/lib/mcp-config.test.ts
    src/commands/init.ts Standard ✅ Yes (integration via mcp-config tests) src/lib/mcp-config.test.ts
    docs/features/mcp-server.md Optional N/A - (docs)
    CHANGELOG.md Optional N/A - (changelog)

    Coverage: 2/2 changed source files have corresponding tests


    Code Review

    Strengths:

    • Clean CLIENTS_NEEDING_CWD set pattern — easy to extend for new clients
    • McpClientType type exported for type safety across the codebase
    • Backward-compatible: both getSequantMcpConfig() and addSequantToMcpConfig() work with no args (existing callers unaffected)
    • Tests properly save/restore process.env.ANTHROPIC_API_KEY in afterEach
    • Good separation: config logic in mcp-config.ts, wiring in init.ts

    Issues:

    • None found

    Suggestions:

    • None — implementation is minimal and focused

    Test Quality Review

    Category Status Notes
    Behavior vs Implementation ✅ OK Tests assert on config output shape, not internals
    Coverage Depth ✅ OK Covers all 3 clients, env set/unset, fallback to process.cwd()
    Mock Hygiene ✅ OK Only env var manipulation, no module mocks
    Test Reliability ✅ OK Deterministic, no timing dependencies

    Anti-Pattern Detection

    Dependency Audit

    N/A — No dependency changes

    Code Patterns

    No anti-patterns detected in changed files.


    Call-Site Review

    New exported functions detected: 0 (existing functions modified, no new functions)

    McpClientType is a new exported type (not a function). getSequantMcpConfig and addSequantToMcpConfig had their signatures extended but already existed.

    Call-site for addSequantToMcpConfig: init.ts:565 — now passes client.clientType as second arg. Correct per AC-5.


    Execution Evidence

    N/A — No executable scripts changed (only library code and docs)


    Skill Command Verification

    N/A — No skill files changed


    CLI Registration Verification

    N/A — No option interface changes


    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅ Found
    User-facing changes ✅ Yes (fix: commit)
    [Unreleased] entry ✅ Present
    Entry format ✅ Valid (includes #395, proper action verb)

    Result: CHANGELOG requirements met


    Smoke Test

    Not Required — No workflow-affecting changes (library code and docs only)


    Self-Evaluation

    • Verified working: Yes — 17 tests pass covering all per-client paths, env conditional, and fallback behavior
    • Test efficacy: High — tests directly verify the per-client config shape which is the core feature
    • Likely failure mode: A new MCP client type added without updating CLIENTS_NEEDING_CWD or detectMcpClients — but that's a future concern, not a current gap
    • Verdict confidence: High — small, focused change with clear AC and comprehensive tests

    Verdict: READY_FOR_MERGE

    All 7 acceptance criteria are met. Implementation is clean, minimal, and well-tested. CI is green. No regressions detected.

    Documentation

    • docs/ updated (docs/features/mcp-server.md — auto-setup note updated)
    • CHANGELOG entry added

    Next Steps

    1. Run /docs 395 to generate admin-facing documentation if needed
    2. Merge PR fix(#395): generate per-client MCP configs with cwd and env #412
  5. added
    ready-for-review
    on Mar 24, 2026
  6. added 2 commits that reference this issue on Mar 24, 2026
  7. admarble commented on Mar 24, 2026

    @admarble
    ContributorAuthor

    Documentation Updated

    File: docs/features/mcp-server.md (existing doc updated)

    Changes:

    • Per-client config examples already present (added by exec phase)
    • Added note about env.ANTHROPIC_API_KEY conditional inclusion in auto-setup section
    • Updated provenance line

    Status:

    ✅ Documentation ready for review and merge.

  8. added a commit that references this issue on Mar 24, 2026
  9. added 3 commits that reference this issue on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmulti-agentready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions