Repository navigation
Keep Sharesight's portfolio list and single-day reports warm - #27
Merged
Merged
Conversation
keep_warm on the sharesight server: list_portfolios, and get_performance_report only for a start_date..end_date window of at most one day. Those results are refetched in the background just before the 30-minute cache expires, but only while someone asked for them since the last fetch (an idle query is dropped, so it stops costing API calls). A failed refresh drops the entry. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014k4kywyN5dAo39izUPvxbw
get_performance_report is kept warm only when start_date equals end_date. Tests cover both limits. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014k4kywyN5dAo39izUPvxbw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
keep_warmoption on MCP servers refetches cached results in the background just before the 30-minutecache_ttlexpires, so asking about a portfolio never waits on a cold fetch. Sharesight is configured with{"list_portfolios": null, "get_performance_report": 0}: the portfolio list always, andget_performance_reportonly for a single-day window (start_dateequal toend_date).Behaviour
keep_warmtakes a list of tool names or{tool: longest start_date..end_date window in days, 0 = a single day}. A name that matches no tool is warned about, likeblocked_tools.Files
lib/mcp/server.py: cache entries carry their tool and arguments; a background loop runs while the server is connected. The module is now 325 lines, a little over the ~300 guideline.mcp_servers.json,README.md: config and documentation.tests/test_mcp.py: refresh before expiry and serving the refreshed copy, idle entries dropped, window rule fordays0 and 1, failed refresh, unknown name warning, shipped config pinned.Test plan
make checkon Python 3.13.5 (ruff + pytest): 220 passedcheckjob on this PR🤖 Generated with Claude Code
https://claude.ai/code/session_014k4kywyN5dAo39izUPvxbw
Generated by Claude Code