Asynchronous Tasks

Celery tasks of the mcpclient app, and how everything else queues them.

  • refresh: refresh one MCPClient’s catalog, or every active one’s.

  • queue: the queue_* functions, the one place that queues these tasks (ADR-030, rule 10, issue #1098). Celery Beat sends refresh_mcpclients by its name.

The package exports the queue_* functions, never a task. Importing queue imports the task module, so that Celery registers its tasks. Each task names itself smarter.apps.mcpclient.tasks.<function> (TASK_NAME_PREFIX), the name it had when the tasks were this module. Anything else, e.g. a task that a test runs, is imported from its own module.

Note

Experimental. The MCPClient was designed and coded by Claude Code (Anthropic’s Claude Opus 5.5), with Lawrence McDaniel as co-author. It is experimental, and will be documented.

smarter.apps.mcpclient.tasks.queue_refresh_mcpclient(mcpclient)[source]

Queue refresh_mcpclient(), which refreshes an MCPClient’s catalog.

Only an active MCPClient with an endpoint is refreshed: there is nothing to connect to otherwise. The MCPClient’s post_save receiver calls it, and refresh_mcpclients() for every active MCPClient. It is queued once the current transaction commits, so that the worker finds the MCPClient as it was saved.

Parameters:

mcpclient (MCPClient) – The MCPClient.

Return type:

bool

Returns:

True if the refresh was queued, False if the MCPClient is inactive or has no endpoint.

Queueing the Tasks

The one place that queues the mcpclient app’s Celery tasks.

Every task of the app is queued by a function of this module, never by <task>.delay() or <task>.apply_async() anywhere else, the tasks themselves included (ADR-030, rule 10, issue #1098). So this module is where to look for what queues a task, and the one place that a test patches so that nothing reaches a real worker, which would connect to an MCP server. Celery Beat sends refresh_mcpclients by its name.

smarter.apps.mcpclient.tasks.queue.queue_refresh_mcpclient(mcpclient)[source]

Queue refresh_mcpclient(), which refreshes an MCPClient’s catalog.

Only an active MCPClient with an endpoint is refreshed: there is nothing to connect to otherwise. The MCPClient’s post_save receiver calls it, and refresh_mcpclients() for every active MCPClient. It is queued once the current transaction commits, so that the worker finds the MCPClient as it was saved.

Parameters:

mcpclient (MCPClient) – The MCPClient.

Return type:

bool

Returns:

True if the refresh was queued, False if the MCPClient is inactive or has no endpoint.

Refreshing Catalogs

Celery tasks that refresh MCPClients’ catalogs.

  • refresh_mcpclient() connects to one MCPClient’s MCP server, refreshes its cached catalog, and records the result in the MCPClient’s status. It is queued whenever an MCPClient is saved.

  • refresh_mcpclients() refreshes every active MCPClient. Celery Beat runs it hourly.

A server that cannot be reached is recorded in the MCPClient’s status. It is not an error of the task, so the tasks do not retry. Each is queued by a function of smarter.apps.mcpclient.tasks.queue, never with .delay() (ADR-030, rule 10), or sent by Celery Beat.