modelcontextprotocol / modelcontextprotocol/servers

MCP Servers Not Detected on Initial Runs of main.py; Tools Recognized Only After Multiple Restarts

Open
#1,679 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
90.5k
Forks
11.7k
Avg merge
2d 2h
Merged PRs (30d)
5

Description

Describe the bug
When running main.py, the MCP client frequently fails to detect and connect to available MCP servers on the first few attempts. The tool discovery and response handling only begin working correctly after restarting the script 3–4 times. This seems to indicate a race condition or delay in server registration or discovery.

To Reproduce
Steps to reproduce the behavior:

Start the MCP servers.

Immediately run main.py.

Observe that no tools are identified or invoked.

Stop main.py and restart it.

Repeat 3–4 times until it begins identifying tools and responding as expected.

Expected behavior
The MCP client should detect available MCP servers and tools correctly on the first run of main.py, assuming the servers are already running.

IM GETTING RESPONSE FROM LLM IT CANT IDENTIFY TOOLS THAT ARE UN SERVER JSON FILE BUT AFTER SOME RETRIES LIKE JUST RUNNING AND EXITING MAIN.PY RANDOMLY THE SERVERS ARE IDENTIFIED AND IT WORKS PROPERLY

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the MCP servers and main.py as described, using the server JSON configuration mentioned in the report. Trace the initial server registration, discovery, and tool-response flow to determine why the first run misses available tools. Done means main.py detects and invokes the configured tools on its first run without repeated restarts.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.