Skip to content

Add Virtual MCP server support#293

Merged
ptelang merged 1 commit intomainfrom
add-vmcp-support
Jan 26, 2026
Merged

Add Virtual MCP server support#293
ptelang merged 1 commit intomainfrom
add-vmcp-support

Conversation

@ptelang
Copy link
Contributor

@ptelang ptelang commented Jan 24, 2026

  • Added virtual_mcp field to workload server model and database schema
  • Implemented intelligent group filtering: prioritizes virtual MCP servers when present in a group, falls back to all servers when absent
  • Updated tool discovery, search, and token counting to respect virtual MCP hierarchy
  • Enhanced k8s client to detect VirtualMCPServer resources and configure transport/URLs correctly
  • Added RBAC permissions for reading virtualmcpservers and mcpgroups CRDs
  • Created vmcp-github-fetch.yaml example with complete MCPGroup, backend servers, and VirtualMCPServer configuration
  • Created mcpserver_mcp-optimizer-vmcp.yaml for deploying MCP Optimizer with vMCP support
  • Updated documentation with vMCP setup instructions and usage examples

🤖 Generated with Claude Code

@claude
Copy link

claude bot commented Jan 24, 2026

Code Review - PR #293: Add Virtual MCP server support

Summary

This PR adds Virtual MCP (vMCP) support, enabling intelligent filtering that prioritizes virtual MCP servers when present in a group. The implementation includes database schema changes, K8s client enhancements, and comprehensive documentation.

Issues Found

1. Performance: Inefficient double query in _get_group_server_filter() (base_tool_ops.py:751-827)

The method executes a query to identify groups with virtual MCPs, then builds filter logic. This is called every time find_similar_tools() or get_all_tools() is invoked, adding significant overhead.

Recommendation: Cache the group→virtual_mcp mapping or use a single query with conditional logic (e.g., using CASE statements).

2. Missing Tests

No tests verify the new virtual MCP filtering logic. The existing test_group_filtering.py doesn't cover:

  • Virtual MCP server prioritization
  • Fallback to all servers when no virtual MCPs exist
  • Token counting with virtual MCP filtering
  • Mixed groups (some with vMCP, some without)

Recommendation: Add tests to test_group_filtering.py covering these scenarios.

3. Migration doesn't handle existing data (migrations/versions/...py:71)

The migration adds virtual_mcp INTEGER NOT NULL DEFAULT 0 but doesn't verify existing rows handle the default correctly.

Recommendation: Consider using ALTER TABLE ... ADD COLUMN virtual_mcp INTEGER DEFAULT 0 NOT NULL explicitly or verify the migration works on existing databases.

4. Type inconsistency in virtual_mcp field

  • Database: INTEGER (migrations:71)
  • Model: bool (models.py:119)
  • API: bool | None (api_models/core.py:61)

SQLite stores as 0/1, Python uses True/False. This works but could be clearer.

Recommendation: Add comment explaining the INTEGER→bool mapping, or use consistent integer types.

5. Verbose logging could impact performance (base_tool_ops.py:793-797)

Debug logging serializes sets to lists on every call, even when debug logging is disabled.

Recommendation: Use lazy evaluation or check log level first.

Positive Aspects

✓ Comprehensive documentation with working examples
✓ Consistent application across all tool operations
✓ Proper parameter handling prevents SQL injection
✓ Clear code structure and naming
✓ Backward compatible (defaults to virtual_mcp=False)

Minor Suggestions

  • k8s_client.py:200-203 - Package naming vmcp:{name} is clever but consider if collisions are possible
  • ingestion.py:735 - Consider extracting the new_virtual_mcp=workload.virtual_mcp or False pattern since it's repeated
  • Documentation - Excellent! Very clear setup instructions

Verdict

Strong feature implementation with good documentation. Primary concern is the performance issue with repeated queries. Consider addressing before merge or in immediate follow-up.

Estimated reading time: 1.5 minutes

therealnb
therealnb previously approved these changes Jan 26, 2026
Copy link
Contributor

@therealnb therealnb left a comment

Choose a reason for hiding this comment

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

I think the code is ok.

What is the use case for this? It looks redundant to me, if we have optimizer included in vmcp. Is it a temporary thing?

- Added virtual_mcp field to workload server model and database schema
- Implemented intelligent group filtering: prioritizes virtual MCP servers when present in a group, falls back to all servers when absent
- Updated tool discovery, search, and token counting to respect virtual MCP hierarchy
- Enhanced k8s client to detect VirtualMCPServer resources and configure transport/URLs correctly
- Added RBAC permissions for reading virtualmcpservers and mcpgroups CRDs
- Created vmcp-github-fetch.yaml example with complete MCPGroup, backend servers, and VirtualMCPServer configuration
- Created mcpserver_mcp-optimizer-vmcp.yaml for deploying MCP Optimizer with vMCP support
- Updated documentation with vMCP setup instructions and usage examples

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ptelang ptelang merged commit f001acc into main Jan 26, 2026
7 checks passed
@ptelang ptelang deleted the add-vmcp-support branch January 26, 2026 17:11
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.

3 participants