Skip to content

fix(mcp): use is not None to cache empty tools list correctly#3496

Closed
rmotgi1227 wants to merge 1 commit into
openai:mainfrom
rmotgi1227:fix/mcp-cache-empty-tools
Closed

fix(mcp): use is not None to cache empty tools list correctly#3496
rmotgi1227 wants to merge 1 commit into
openai:mainfrom
rmotgi1227:fix/mcp-cache-empty-tools

Conversation

@rmotgi1227
Copy link
Copy Markdown
Contributor

When an MCP server returns an empty tools list, self._tools_list is [] which is falsy. The cache check

if self.cache_tools_list and not self._cache_dirty and self._tools_list:

treats an empty cached list the same as an uncached one, causing a redundant re-fetch on every subsequent list_tools() call even when cache_tools_list=True and the cache is clean.

The field is initialized to None (line 600) to mean "not yet fetched," so the correct guard is is not None.

@seratch
Copy link
Copy Markdown
Member

seratch commented May 22, 2026

An empty list here is not expected plus if that happens, skipping the saved empty data should be fine

@seratch seratch closed this May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants