Skip to content

Add MCP tools for log inspection and Script API/XSD docs#420

Draft
clavery wants to merge 2 commits into
mainfrom
feature/mcp-diag-log-tail
Draft

Add MCP tools for log inspection and Script API/XSD docs#420
clavery wants to merge 2 commits into
mainfrom
feature/mcp-diag-log-tail

Conversation

@clavery
Copy link
Copy Markdown
Collaborator

@clavery clavery commented May 12, 2026

Summary

  • Logs MCP tools for the B2C Commerce instance via WebDAV: logs_list_files, logs_get_recent, plus a watch lifecycle (logs_watch_start / logs_watch_poll / logs_watch_stop / logs_watch_list) that buffers entries between polls so an agent doesn't miss logs produced between tool calls.
  • Docs MCP tools over the bundled Script API and XSD corpora: docs_search, docs_read, docs_list, docs_schema_search, docs_schema_read, docs_schema_list. No instance auth required.
  • New DIAGNOSTICS toolset that groups the script debugger and log tools. Existing debug tools are re-tagged onto DIAGNOSTICS in addition to their current CARTRIDGES / SCAPI assignments.
  • SDK promotion: log filter helpers (parseSinceTime, filterBy*, matchesLevel, matchesSearch) moved from packages/b2c-cli/src/utils/logs into @salesforce/b2c-tooling-sdk/operations/logs so the MCP package can reuse them. CLI re-exports from the SDK; existing CLI tests and behavior unchanged.
  • New LogWatchRegistry on ServerContext (mirrors DebugSessionRegistry): UUID watch ids, hostname-level dedup, capped buffer with eviction counter, idle TTL cleanup, poll waiters with timeout. New docs pages for both tool families and sidebar updates.

Tool reference

Logs (CARTRIDGES, DIAGNOSTICS, SCAPI)

Tool Input Behavior
logs_list_files prefixes?, sort_by?, sort_order? One-shot WebDAV listing
logs_get_recent prefixes?, count?, since?, level?, search? One-shot fetch with client-side filters
logs_watch_start prefixes?, last_entries?, poll_interval_ms?, level?, search? Starts a buffered tail; returns watch_id
logs_watch_poll watch_id, timeout_ms?, max_entries? Drains buffer; blocks up to timeout_ms if empty
logs_watch_stop watch_id Stops tail, releases registry slot
logs_watch_list Lists active watches (recovery aid)

Docs (all toolsets)

docs_search / docs_read / docs_list for Script API; docs_schema_search / docs_schema_read / docs_schema_list for XSD.

Test plan

  • pnpm run typecheck:agent
  • pnpm run lint:agent
  • pnpm --filter @salesforce/b2c-tooling-sdk run test:agent (1722 passing — verifies log filter helper promotion didn't break SDK or CLI usage)
  • pnpm --filter @salesforce/b2c-cli run test:agent (1218 passing — verifies CLI still consumes filter helpers via SDK re-export)
  • pnpm --filter @salesforce/b2c-dx-mcp run test:agent (767 passing — includes new log-watch-registry.test.ts, logs-tools.test.ts, docs-tools.test.ts)
  • Manual smoke against a sandbox via MCP inspector:
    • logs_list_files returns files
    • logs_get_recent {prefixes: ["error"], count: 5} returns parsed entries
    • logs_watch_start → trigger storefront error → logs_watch_poll returns the entry → logs_watch_stop cleans up
    • docs_search ProductMgrdocs_read dw.catalog.ProductMgr → markdown body
    • docs_schema_listdocs_schema_read catalog → XSD content
  • pnpm run docs:dev — sidebar shows Logs under Diagnostics + new Documentation group; both new pages render

clavery added 2 commits May 11, 2026 21:35
- Logs: logs_list_files, logs_get_recent, plus a watch lifecycle
  (logs_watch_start/poll/stop/list) that buffers entries between polls
  via a new LogWatchRegistry on ServerContext, so agents don't miss
  entries produced between request/response turns.
- Docs: docs_search/read/list and docs_schema_search/read/list over the
  bundled Script API and XSD corpora; no instance auth required.
- Adds a new DIAGNOSTICS toolset that groups the script debugger and
  log tools; existing debug-* tools also re-tagged.
- Promotes log filter helpers (parseSinceTime, filterBy*, matchesLevel,
  matchesSearch) from the CLI to @salesforce/b2c-tooling-sdk so the MCP
  package can reuse them.
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.

1 participant