Skip to content

Conversation

@4ndrelim
Copy link
Member

Key Changes:
Previously, we experimented with registering search_papers tool. It is tedious and not scalable to manually create separate files and extension for each tool. Here, we propose a dynamic loader that initializes connection with the XtraMCP and dynamically load tools exposed by XtraMCP.

XtraMCPLoader

  1. Initialize MCP session (get session ID)
  2. Send notifications/initialized (activate session)
  3. List available tools (using session ID)
  4. Create DynamicTool instances (passing session ID)

DynamicTool

  1. Use stored session ID (no re-initialization!)
  2. Call tools/call with session ID
  3. Return results

Overall Workflow

  1. AIClient startup
  2. DynamicToolLoader.LoadToolsFromBackend()
  3. initializeMCP() [Steps 1&2: initialize + notifications/initialized]
  4. fetchAvailableTools() [Step 3: tools/list]
  5. Create DynamicTools with session ID
  6. Runtime: DynamicTool.Call() uses stored session ID

See result below from the dynamic loading: Screenshot 2025-10-22 at 6 21 16 AM

Issues

  1. It seems snake_case has caused the output to be slightly less presentable, making it italics when it isn't supposed to be.

Copilot AI review requested due to automatic review settings October 21, 2025 23:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a dynamic tool loading system for XtraMCP integration, replacing the previous manual tool registration approach. The new system automatically initializes MCP sessions, fetches available tools, and creates dynamic tool instances that reuse session IDs for efficient execution.

Key changes:

  • Implemented XtraMCPLoader to dynamically discover and register tools from XtraMCP backend
  • Created DynamicTool to handle generic tool execution with session reuse
  • Added MCP initialization utilities and corresponding tests
  • Modified AIClient to use dynamic tool loading instead of static registration

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
internal/services/toolkit/tools/xtramcp/tool.go Implements DynamicTool with session ID reuse for executing MCP tools
internal/services/toolkit/tools/xtramcp/loader.go Implements XtraMCPLoader for MCP session initialization and dynamic tool discovery
internal/services/toolkit/tools/xtragpt/util_test.go Adds comprehensive tests for MCP initialization and notification workflows
internal/services/toolkit/tools/xtragpt/util.go Provides utility functions for MCP protocol communication
internal/services/toolkit/tools/xtragpt/search_papers.go Contains SearchPapersTool implementation (appears to be legacy code)
internal/services/toolkit/client/client.go Updates AIClient to use XtraMCPLoader for dynamic tool registration
internal/api/gin.go Changes CORS configuration to allow all origins
hack/values-dev.yaml Adds development configuration for namespace and MongoDB settings

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@4ndrelim 4ndrelim requested a review from Junyi-99 October 22, 2025 06:15
@Junyi-99 Junyi-99 changed the title XtraMCP Integration feat: XtraMCP Integration Oct 22, 2025
@Junyi-99 Junyi-99 added enhancement New feature or request good first issue Good for newcomers labels Oct 22, 2025
@PaperDebugger PaperDebugger deleted a comment from Copilot AI Oct 22, 2025
@PaperDebugger PaperDebugger deleted a comment from Copilot AI Oct 22, 2025
@PaperDebugger PaperDebugger deleted a comment from Copilot AI Oct 22, 2025
@PaperDebugger PaperDebugger deleted a comment from Copilot AI Oct 22, 2025
Copy link
Member

@Junyi-99 Junyi-99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Junyi-99 Junyi-99 merged commit 457999a into main Oct 22, 2025
1 of 2 checks passed
@Junyi-99 Junyi-99 deleted the feat-academic-mcp branch October 22, 2025 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants