Skip to content

Conversation

@richhankins
Copy link
Contributor

Summary

This PR adds dynamic index management capabilities to the MCP server, allowing agents to create, list, and delete indexes on-demand.

New MCP Tools

Tool Description
list_indexes List available indexes with metadata (name, source, last synced)
index_repo Create/update an index from GitHub, GitLab, BitBucket, or website
delete_index Remove an index from the store

Key Changes

1. Dynamic MultiIndexRunner (src/search/multi-index-runner.ts)

  • Made index list mutable (removed readonly)
  • Added refreshIndexList() to reload indexes after creation/deletion
  • Added invalidateClient(indexName) to clear cached SearchClient after updates

2. MCP Server (src/mcp/mcp-server.ts)

  • Added handlers for new tools
  • Tools only appear when store supports required operations
  • After index_repo/delete_index, automatically refreshes runner state

3. Tool Descriptions (src/mcp/tool-descriptions.ts)

  • Added withIndexesReference() that appends "Use list_indexes to see available indexes."
  • Keeps tool definitions stable (good for token cache utilization)

4. CLI (src/bin/cmd-mcp.ts)

  • Removed check that exited if no indexes exist
  • Server now starts successfully with zero indexes

Architecture: Three-Layer Context Model

This feature enables the "exploration layer" in our context hierarchy:

Layer Component Purpose
1. Active Workspace Auggie CLI The code you're editing now
2. Organization Remote-MCP Your team's curated repos
3. Exploration Context-Connector MCP Agent's curiosity - explore beyond boundaries

Testing

  • ✅ All 163 tests pass
  • ✅ TypeScript compiles cleanly
  • ✅ Manual testing via MCP client confirmed all tools work

Configuration Note

For dynamic indexing to work, the MCP server must be started without -i flags:

ctxc mcp stdio  # Uses writable FilesystemStore

With -i flags, it uses CompositeStoreReader (read-only) and index_repo/delete_index will fail.

Commits

  • 4981a79 - Support dynamic index list in MultiIndexRunner
  • 427a1bc - Add list_indexes tool to MCP server
  • 2ea4cdf - Add index_repo tool to MCP server
  • 6447099 - Add delete_index tool to MCP server
  • 35f06b1 - Allow MCP server to start with zero indexes

Pull Request opened by Augment Code with guidance from the PR author

- Remove readonly from indexNames and indexes fields
- Remove empty-index checks at initialization (allow zero indexes)
- Add refreshIndexList() method to reload indexes from store
- Add invalidateClient() method to clear cached SearchClient
- Update MCPServerConfig.store to accept both IndexStoreReader and IndexStore

Agent-Id: agent-49436113-35bf-4532-983a-fb01da818555
- Add list_indexes tool to ListToolsRequestSchema handler
- Add handler in CallToolRequestSchema that refreshes index list and
  returns formatted metadata (name, type, identifier, syncedAt)
- Returns helpful message when no indexes exist
- Add withListIndexesReference() helper in tool-descriptions.ts
- Update MCP server to use withListIndexesReference instead of
  embedding static index list in tool descriptions
- Keep withIndexList() for CLI agent backward compatibility

Agent-Id: agent-b187383f-2e44-4592-9ec9-6f0f4e0eafb6
- Add delete_index tool definition (only when store supports delete)
- Add handler to delete index from store, refresh runner state, and invalidate cached client
- Validates index exists before attempting delete
- Returns appropriate error messages for missing index or unsupported store

Agent-Id: agent-8cf675a5-fcdf-402a-a3a1-f3fa2a8c3f1b
Agent-Id: agent-8cf675a5-fcdf-402a-a3a1-f3fa2a8c3f1b
Linked-Note-Id: 18ee4796-4931-48c2-80e4-e85d51fe2ccd
This tool allows creating/updating indexes dynamically from:
- GitHub repositories (requires owner and repo)
- GitLab repositories (requires project_id)
- BitBucket repositories (requires workspace and repo)
- Websites (requires url)

Features:
- Validates required parameters for each source type
- Checks if store supports write operations
- Refreshes runner state after indexing
- Invalidates cached client for updated indexes
- Returns success message with stats (type, filesIndexed, duration)

Agent-Id: agent-4dd9b0b4-3ecf-4a2a-850a-49fd55aba0b5
Remove the empty-index check from the CLI so the MCP server can start
even when no indexes exist. This enables the dynamic indexing workflow
where users can call list_indexes (empty) then index_repo to create
indexes on-demand.
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