Skip to content

perf(edge-worker): load only essential MCP tools at session start to cut Linear startup latency - #1369

Open
TropicalDog17 wants to merge 2 commits into
cyrusagents:mainfrom
TropicalDog17:feat/linear-mcp-essential-tool-loading
Open

TropicalDog17 wants to merge 2 commits into
cyrusagents:mainfrom
TropicalDog17:feat/linear-mcp-essential-tool-loading

Conversation

@TropicalDog17

Copy link
Copy Markdown

Problem

When a session starts, the agent often spends close to a minute running tool-search round-trips against Linear's remote MCP server before it can read or update the issue — a visible stall at the top of every session.

Root cause: the official Linear MCP (mcp.linear.app) registers ~50 verbose tools. Their combined tool descriptions on their own push past the Claude Agent SDK's ~10%-of-context threshold, which silently flips the SDK into MCP tool-search auto mode. In that mode every MCP tool — including Cyrus's own local ones — is deferred behind an on-demand ToolSearch. Because the Linear server is remote, discovering those deferred schemas costs real network round-trips, so turn 1 stalls before the agent can do anything with the issue.

Fix

Load only the essential, local tools into turn-1 context; defer the large remote catalog.

  • Mark Cyrus's small, locally-served MCP servers (cyrus-tools, cyrus-docs) with alwaysLoad: true, exempting them from the auto-defer bucket. These are the tools Cyrus's workflow actually depends on (agent-session/feedback management, file uploads, issue relations, docs search) and they're served locally, so there's no round-trip cost and negligible context.
  • Leave the remote linear server deferred (no alwaysLoad). Its ~50 tools would otherwise bloat turn-1 context, and the issue essentials the agent needs on turn 1 — title, description, state, priority, URL, and comment threads — are already injected into the prompt by the standard session template. The long tail of Linear operations remains reachable on demand via ToolSearch when genuinely needed.

The SDK only exposes alwaysLoad per-server (not per-tool for remote HTTP servers), so curating the essentials into always-loaded local servers is the mechanism that satisfies both goals: lean turn-1 context and no startup tool-search stall for the tools Cyrus relies on.

Why this is safe

  • mcp__cyrus-tools / mcp__cyrus-docs are already in the default allowed-tool lists — no permission changes.
  • No new tools are introduced, so the cyrus-hosted /settings/tools catalog needs no update.
  • Behavior for the remote Linear catalog is unchanged (still deferred); this only changes which servers are eagerly loaded.

Testing

  • Added packages/edge-worker/test/McpConfigService.alwaysLoad.test.ts — asserts cyrus-tools/cyrus-docs are alwaysLoad, the remote linear server is left deferred, and CLI mode (no Linear client) still always-loads cyrus-docs. All 3 pass.
  • McpConfigService typechecks clean and lints clean.

Changelog

Added an entry under ## [Unreleased] → ### Changed describing the faster session startup.

…-startup latency

The official Linear MCP registers ~50 verbose tools whose combined
descriptions alone exceed the Claude Agent SDK's ~10%-of-context
threshold, silently enabling MCP tool-search auto mode. That deferred
every MCP tool — including Cyrus's own local ones — behind an on-demand
ToolSearch, so turn 1 stalled on remote round-trips before the agent
could act on the issue.

Mark the small, local cyrus-tools and cyrus-docs servers alwaysLoad so
they're exempt from the auto-defer bucket, while leaving the large remote
Linear catalog deferred (its 50 tools would otherwise bloat turn-1
context; the issue essentials are already injected into the prompt).
@TropicalDog17

Copy link
Copy Markdown
Author

Hi can you review for me @Connoropolous

TropicalDog17 pushed a commit to TropicalDog17/cyrus that referenced this pull request Jul 18, 2026
…ream

gh pr create defaults a fork's PR to the upstream parent repo, which
silently opened PRs on cyrusagents/cyrus (e.g. cyrusagents#1376, cyrusagents#1369). Derive the
target from origin via --repo/--head so the PR always lands on the fork.

Claude-Session: https://claude.ai/code/session_01Y7j2xZhmHbNhMRq6665PXy
TropicalDog17 added a commit to TropicalDog17/cyrus that referenced this pull request Jul 18, 2026
…ream (#50)

gh pr create defaults a fork's PR to the upstream parent repo, which
silently opened PRs on cyrusagents/cyrus (e.g. cyrusagents#1376, cyrusagents#1369). Derive the
target from origin via --repo/--head so the PR always lands on the fork.

Claude-Session: https://claude.ai/code/session_01Y7j2xZhmHbNhMRq6665PXy

Co-authored-by: tropicaldog17 <tropicaldog17aa@gmail.com>
@TropicalDog17 TropicalDog17 reopened this Jul 24, 2026
@Connoropolous

Copy link
Copy Markdown
Contributor

have you verified that this has the intended effect?

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