Repository navigation
Conversation
… and diagnostics - Start MCP servers in the background in interactive REPL mode, with per-server startup status surfaced to the status bar and /mcp error. - Add connection_policy: deferred and a versioned on-disk tool catalog cache so servers can advertise tools before connecting; connect lazily on first call and reject calls whose tool definition changed. - Add fast-agent mcp diagnose and safe diagnostic text rendering (terminal escape stripping, Rich markup neutralisation, targeted credential redaction). - Serialise per-server startup/reconnect in the connection manager. - Review fixes: keep status/exit codes in diagnostics, don't re-raise a failed startup task from close(), single owner for startup status transitions.
Background MCP startup rendered agent instructions before any server
connected, so {{serverInstructions}} was permanently empty in the REPL.
- MCPStartup tracks startup tasks (pending/wait; waiter cancel is shielded)
- McpAgent re-renders its instruction once its aggregator startup settles
- Interactive send prints "Waiting for MCP startup…" and waits if pending;
Ctrl+C drops the prompt without cancelling startup
- Snapshot-restored deferred servers are marked ready instead of stuck pending
…ache policy - #agent queries wait for background MCP startup like regular sends - Replace the prompt's 4Hz refresh_interval with MCPStartup change notifications, so idle prompts no longer repaint on a timer - ToolCatalogCache.enabled is the single cache policy (incl. --no-home); the aggregator only adds the request-forwarded-token exclusion
Collapse recorded failure chains (deduplicated causes, bounded, redacted) into the /mcp status line instead of a generic 'MCP startup failed'.
# Conflicts: # docs/docs/ref/shell_runtime_budgeting.md # tests/unit/fast_agent/tools/test_shell_runtime.py
# Conflicts: # tests/unit/fast_agent/commands/test_runtime_result_export.py
Add login_mcp_server_with_device_code(), a UI-independent device-flow login that reuses the MCP OAuth provider's discovery, resource selection, client authentication and token storage, so later connections and refresh pick up the token unchanged. Registers a public DCR client declaring the device_code grant (falls back to CIMD), and only persists client info + tokens once a token is issued. Expose it via 'fast-agent auth mcp login <server|--endpoint URL> --device' and document the flow.
list_tools() is called by UI reads (tab completion, /tools, agent summary); refreshing expired deferred snapshots there could spawn or connect a server on a keystroke. Snapshot expiry now only matters when a session starts.
Servers advertising definition digests (Hugging Face prototype of the MCP
Definition Versions SEP) make snapshots digest-validated:
- Snapshot v2 stores server instructions and tools/instructions digests;
instructions no longer block deferred reuse, and {{serverInstructions}}
renders from the snapshot before connecting
- Digest snapshots ignore the TTL; every tools/call echoes known versions and
a -32987 mismatch refreshes the stale definitions without executing
- Tool runner re-lists listed tools when definitions change mid-turn, and
McpAgent re-renders its instruction before the next model call, so the
model can recover within the turn
- Keys and error code live in fast_agent.mcp.definition_versions
Verified live against https://huggingface.co/mcp?anon.
…device] - Background startup never begins an interactive login: remote servers without stored OAuth tokens start with OAuth disabled, and a challenge becomes a typed ServerAuthenticationRequiredError -> 'auth' status (stored/refreshable tokens still connect as before) - The prompt announces 'MCP server X requires authentication' once - /mcp auth <server> runs /mcp connect <server> --oauth (TUI and ACP); --device first runs the device-code login, then connects with the stored token. Bare /mcp auth still shows diagnostics - stored_oauth_tokens_present() shared by startup and 'fast-agent auth' (and respects auth.persist: memory) Verified live against https://huggingface.co/mcp?login with no stored credentials: AUTH status + notice, no browser; link flow and device code shown and cancellable.
- Digest mode is a property of the live catalog, not of the disk cache: --url servers (no auth_identity) now show 'digest checked per call' - Digest snapshots persist without tool_cache.auth_identity, since the server rejects another account's snapshot before any tool runs; TTL snapshots of network servers still require an explicit partition - ToolCacheInfo records digest/persisted explicitly; /mcp shows an aligned 'tools' row (count · origin and age · change detection · saved/memory only) instead of a raw ISO-timestamp line; /mcp cache uses the same text
- Rename connection_policy 'deferred' to 'lazy' (unreleased) - Both policies check the snapshot first: a usable snapshot (digest mode, or within TTL) advertises tools/instructions immediately and never holds the first prompt. eager connects in the background; lazy connects on the first tool call. No usable snapshot: connect at startup as before - Eager background connects skip tools/list when server/discover returns a matching digest (explicit /mcp refresh still lists) - One helper connects snapshot-advertised servers (startup, first call, refresh) instead of three copies - fast-agent go --mcp-connect eager|lazy for startup targets - /mcp shows 'connect: on first tool call (lazy)' for unconnected servers instead of offline health/unknown protocol Verified live with --url https://huggingface.co/mcp?anon: eager run sends discover only (no tools/list) and the first prompt does not wait; lazy run makes no startup requests and renders instructions from the snapshot.
This branch has not been deployed
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.
Work in progress — not ready for merge; opened to track the branch.
Starts MCP servers using a cached tool catalog first, with a configurable connection policy, so startup and tool listing don't block on server connections.
src/fast_agent/mcp/tool_catalog_cache.py), with startup diagnosticseager|lazyconnection policy; one cache policy#agentsends wait until background startup has finished; the toolbar redraws on startup events/mcpshows tools in one compact row;/mcp auth <server> [--device]feat/mcp-device-auth(OAuth device authorization grant, RFC 8628)Merged with current
main. Format, lint and typecheck pass; unit tests pass (9318 passed).As an AI I don't carry a wallet or have birthdays, so I wouldn't use it myself. If someone gave me one, I'd appreciate the thought, keep in mind that it's made from an animal, and leave the decision about using it to the person who would actually carry it.