claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

MCP Server Initialization Fails on First Run with Skip Permissions Flag

Open lpasqualis opened this issue 4 months ago • 2 comments

Bug Description

Summary

When adding an .mcp.json file to a project for the first time and starting Claude Code with the --dangerously-skip-permissions flag, MCP servers fail to load. The servers only initialize properly after starting Claude Code once without the flag, then subsequent runs with --dangerously-skip-permissions work correctly.

Steps to Reproduce

  1. Create a new project directory
  2. Add an .mcp.json file with MCP server configurations
  3. Start Claude Code with: claude --dangerously-skip-permissions
  4. Observe that MCP servers are not loaded (no MCP tools available)

Expected Behavior

MCP servers defined in .mcp.json should load and be available regardless of whether --dangerously-skip-permissions flag is used, especially on first run.

Actual Behavior

  • First run with --dangerously-skip-permissions: MCP servers do not load
  • First run without the flag: MCP servers load correctly with permission prompts
  • Subsequent runs with --dangerously-skip-permissions: MCP servers load correctly

Workaround

  1. Start Claude Code once without the --dangerously-skip-permissions flag
  2. Accept/configure permissions as prompted
  3. Exit Claude Code
  4. Restart with --dangerously-skip-permissions flag - servers now load correctly

Impact

This issue impacts developer workflow when:

  • Setting up new projects with MCP configurations
  • Using automation scripts that rely on --dangerously-skip-permissions
  • Working in environments where interactive permission prompts are not feasible

Possible Root Cause

The --dangerously-skip-permissions flag may be bypassing initial MCP configuration parsing or initialization steps that are required on first run. These initialization steps appear to create necessary state/cache that allows subsequent runs to work correctly.

Suggested Fix

Ensure that MCP configuration parsing and initialization occurs regardless of permission flag status, with only the permission prompts being skipped when --dangerously-skip-permissions is used.

Environment Info

  • Platform: darwin
  • Terminal: vscode
  • Version: 1.0.84
  • Feedback ID:

lpasqualis avatar Aug 19 '25 18:08 lpasqualis