Skip to content

feat: add MCP tools for ingest pipeline control (status/pause/resume/retry-failed) - #656

Open
Kinghammer1 wants to merge 1 commit into
nashsu:mainfrom
Kinghammer1:codex/ingest-mcp-tools
Open

feat: add MCP tools for ingest pipeline control (status/pause/resume/retry-failed)#656
Kinghammer1 wants to merge 1 commit into
nashsu:mainfrom
Kinghammer1:codex/ingest-mcp-tools

Conversation

@Kinghammer1

Copy link
Copy Markdown

Summary

Adds 4 new MCP tools so AI agents can control the ingest pipeline without the UI, closing the gap described in the issue where ingest pause/resume was locked behind UI buttons.

New MCP Tools

Tool Description
llm_wiki_ingest_status Queue counts (pending/processing/failed/cancelled/completed), paused flag, and task list
llm_wiki_ingest_pause Abort in-flight LLM task, stop new tasks from starting (token spend stops immediately)
llm_wiki_ingest_resume Resume processing after pause
llm_wiki_ingest_retry_failed Requeue all failed tasks back to pending

Architecture

The ingest queue lives entirely in frontend TypeScript (src/lib/ingest-queue.ts). Since the MCP server talks to the Rust HTTP API, a Tauri event bridge connects them:

  1. Rust HTTP endpoints (api_server.rs): 4 new routes emit ingest-api://request Tauri events with a unique request ID
  2. Frontend listener (ingest-api-bridge.ts): Listens for events, calls the corresponding ingest-queue function, responds via the ingest_api_response Tauri command
  3. Rust response channel: The HTTP handler blocks on an mpsc channel until the frontend responds (15s timeout)

Changes

  • src-tauri/src/api_server.rs: 4 new routes (/ingest/status, /ingest/pause, /ingest/resume, /ingest/retry-failed), event bridge with timeout, complete_ingest_api_request function
  • src-tauri/src/lib.rs: ingest_api_response Tauri command + registration in invoke handler
  • src/lib/ingest-api-bridge.ts (new): Frontend event listener that calls ingest-queue functions
  • src/App.tsx: Start bridge on app startup
  • mcp-server/src/api-client.ts: 4 new API client methods + types + parsers
  • mcp-server/src/index.ts: 4 tool definitions + handler cases + output formatters
  • mcp-server/test/api-client.test.ts: 4 new tests (all passing)

Testing

  • MCP server: npm run typecheck and npm test — 24/24 tests pass
  • Rust backend: cargo check — compiles cleanly
  • Frontend TypeScript: npx tsc --noEmit — compiles cleanly

Backward Compatibility

  • No changes to existing MCP tools or API endpoints
  • No changes to the UI behavior — the ingest-queue functions are unchanged
  • The new endpoints follow the same auth pattern as existing endpoints

…retry-failed)

Adds 4 new MCP tools so AI agents can control the ingest pipeline
without the UI, closing the gap described in the issue where ingest
pause/resume was locked behind UI buttons.

New MCP tools:
- llm_wiki_ingest_status: queue counts + paused flag + task list
- llm_wiki_ingest_pause: abort in-flight task, stop new tasks
- llm_wiki_ingest_resume: resume processing after pause
- llm_wiki_ingest_retry_failed: requeue all failed tasks

Architecture: the ingest queue lives in frontend TypeScript
(src/lib/ingest-queue.ts). Since the MCP server talks to the Rust
HTTP API, a Tauri event bridge connects them:

1. Rust HTTP endpoints emit 'ingest-api://request' events
2. Frontend listener (ingest-api-bridge.ts) calls ingest-queue fns
3. Frontend responds via 'ingest_api_response' Tauri command
4. Rust returns the result to the MCP client

Changes:
- src-tauri/src/api_server.rs: 4 new routes, event bridge, timeout
- src-tauri/src/lib.rs: ingest_api_response command + registration
- src/lib/ingest-api-bridge.ts: frontend event listener (new file)
- src/App.tsx: start bridge on app startup
- mcp-server/src/api-client.ts: 4 new API client methods + types
- mcp-server/src/index.ts: 4 tool definitions + handlers + formatters
- mcp-server/test/api-client.test.ts: 4 new tests (all passing)

Closes #{issue-number}
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