claude-code - 💡(How to fix) Fix [BUG] Scheduled jobs fail to access deferred MCP tools — timing race at session start [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45411Fetched 2026-04-09 08:06:03
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×4closed ×1commented ×1

Scheduled jobs consistently fail when they depend on deferred MCP tools (e.g. Slack). The MCP server is properly configured and works in interactive sessions, but scheduled job sessions end before the MCP finishes connecting.

Error Message

Error seen in scheduled job output:

Error Messages/Logs

Root Cause

Root cause (observed)

Deferred MCP tools are not available at session start — they connect asynchronously. Interactive sessions naturally provide multiple turns that give the MCP time to finish connecting. Scheduled jobs have no user turns, so the first (and only) agent response runs before the MCP is ready, causing it to fail.

Fix Action

Fix / Workaround

Workaround attempted

Added retry logic via CLAUDE.md instructing the model to run ToolSearch up to 4 times before giving up. This partially helps for slow connections but does not solve the case where the MCP never connects during the job's single turn.

Code Example

I don't have access to any Slack tools in this environment. The slack_search_public_and_private and slack_send_message tools are not available to me — they don't appear in my tool set and aren't accessible via ToolSearch.

This scheduled job cannot be executed because the required Slack integration tools are not present in this session. To fix this, check that:

The Slack MCP server is configured and connected in your Claude Code settings
The tools slack_search_public_and_private, slack_read_thread, and slack_send_message are properly registered
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Summary

Scheduled jobs consistently fail when they depend on deferred MCP tools (e.g. Slack). The MCP server is properly configured and works in interactive sessions, but scheduled job sessions end before the MCP finishes connecting.

Behavior

  • Interactive session: deferred MCP tools appear via ToolSearch after 2–3 turns (~seconds)
  • Scheduled job session: ToolSearch returns no results, job reports tools unavailable, session ends

Error seen in scheduled job output:

"The slack_search_public_and_private and slack_send_message tools are not available to me — they don't appear in my tool set and aren't accessible via ToolSearch."

Root cause (observed)

Deferred MCP tools are not available at session start — they connect asynchronously. Interactive sessions naturally provide multiple turns that give the MCP time to finish connecting. Scheduled jobs have no user turns, so the first (and only) agent response runs before the MCP is ready, causing it to fail.

Workaround attempted

Added retry logic via CLAUDE.md instructing the model to run ToolSearch up to 4 times before giving up. This partially helps for slow connections but does not solve the case where the MCP never connects during the job's single turn.

Environment

  • Claude Code (web)
  • Slack MCP server (deferred/user-authenticated)
  • Scheduled jobs feature

What Should Happen?

I would like scheduled tasks to be able to execute Slack searches.

Error Messages/Logs

I don't have access to any Slack tools in this environment. The slack_search_public_and_private and slack_send_message tools are not available to me — they don't appear in my tool set and aren't accessible via ToolSearch.

This scheduled job cannot be executed because the required Slack integration tools are not present in this session. To fix this, check that:

The Slack MCP server is configured and connected in your Claude Code settings
The tools slack_search_public_and_private, slack_read_thread, and slack_send_message are properly registered

Steps to Reproduce

Steps to reproduce

  1. Configure a Slack MCP server in Claude Code settings (web)
  2. Create a scheduled job that uses any Slack tool (e.g. slack_search_public_and_private)
  3. Wait for the job to run autonomously
  4. Observe: job fails with "tools not available" even though MCP is configured

The same job prompt works correctly in an interactive session where the user sends a message after session start.

Expected behavior

Scheduled job sessions should wait for configured MCP servers to finish connecting before executing the job prompt, or MCP initialization should be synchronous/complete before the first agent turn begins.

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

Latest

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

extent analysis

TL;DR

Modify the scheduled job to wait for the MCP server to finish connecting before executing the job prompt.

Guidance

  • Introduce a delay or a waiting mechanism in the scheduled job to allow the MCP server to connect before attempting to use the Slack tools.
  • Consider implementing a callback or a notification system to notify the scheduled job when the MCP server has finished connecting.
  • Review the Claude Code settings and the Slack MCP server configuration to ensure that they are properly set up and compatible with the scheduled jobs feature.
  • Investigate the possibility of making the MCP initialization synchronous or complete before the first agent turn begins.

Example

# Pseudocode example of introducing a delay
import time

# ... (rest of the code)

# Wait for 5 seconds to allow the MCP server to connect
time.sleep(5)

# Attempt to use the Slack tools
tool_search = ToolSearch()
tools = tool_search.get_tools()

# ... (rest of the code)

Notes

The exact implementation of the waiting mechanism or the callback system may vary depending on the specifics of the Claude Code and the Slack MCP server. It is also unclear whether making the MCP initialization synchronous is feasible or desirable.

Recommendation

Apply a workaround by introducing a delay or a waiting mechanism in the scheduled job, as modifying the underlying system to make the MCP initialization synchronous may not be feasible or desirable. This will allow the scheduled job to wait for the MCP server to finish connecting before attempting to use the Slack tools.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Scheduled job sessions should wait for configured MCP servers to finish connecting before executing the job prompt, or MCP initialization should be synchronous/complete before the first agent turn begins.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING