Skip to content

Conversation

@jerm-dro
Copy link
Contributor

@jerm-dro jerm-dro commented Jan 13, 2026

Merge jerm/2026-01-13-optimizer-in-vmcp into main

This PR merges 17 commits that integrate the MCP optimizer into vMCP, adding semantic tool discovery, observability, Kubernetes support, and various bug fixes and improvements.

Core Optimizer Integration

Add Optimizer Package (#3253)

  • Introduced optimizer package - Go port of the mcp-optimizer Python service
  • Semantic tool search using vector embeddings (384-dim)
  • Token counting for LLM cost estimation
  • Full-text search via SQLite FTS5
  • Multiple embedding backends: Ollama, vLLM, or placeholder (testing)
  • Production-ready database with sqlite-vec for vector similarity search

Add Optimizer Integration Endpoints (#3318)

  • Added find_tool and call_tool endpoints to vMCP optimizer
  • Implemented semantic search and string matching for tool discovery
  • Updated optimizer integration documentation
  • Added test scripts for optimizer functionality

Resolve Tool Names in optim.find_tool (#3337)

  • Fixed tool name resolution to match routing table
  • Ensures consistent tool discovery and routing

Observability & Metrics

Add Token Metrics and Observability (#3347)

  • Added comprehensive token metrics to optimizer integration
  • Enables monitoring of token usage and optimization effectiveness

Add OpenTelemetry Tracing to Capability Aggregation

  • Added tracing spans to all aggregator methods for visibility in Jaeger
  • Includes spans for:
    • AggregateCapabilities (parent span)
    • QueryAllCapabilities (parallel backend queries)
    • QueryCapabilities (per-backend queries)
    • ResolveConflicts (conflict resolution)
    • MergeCapabilities (final merge)
  • All spans include relevant attributes like backend counts, tool/resource/prompt counts, and error recording

Kubernetes Integration

Add Dynamic/Static Mode Support (#3235)

  • Added dynamic/static mode support to VirtualMCPServer operator
  • Enables flexible deployment configurations

Add DeepCopy and Kubernetes Service Resolution

  • Used DeepCopy() for automatic passthrough of config fields (Optimizer, Metadata, etc.)
  • Added resolveEmbeddingService() to resolve Kubernetes Service names to URLs
  • Ensures optimizer config is properly converted from CRD to runtime config
  • Resolves embeddingService references in Kubernetes deployments

Kubernetes Optimizer Integration Fixes (#3359)

  • Added CLI fallback for embeddingService when not resolved by operator
  • Normalized localhost to 127.0.0.1 in embeddings to avoid IPv6 issues
  • Added HTTP timeout (30s) to prevent hanging connections
  • Removed WithContinuousListening() to use timeout-based approach

Testing & Reliability Improvements

Run API E2E Test Server as Standalone Process (#3356)

  • Changed test server to run as standalone process instead of in-process
  • Uses full binary to ensure realistic test scenarios

Fix Flaky E2E Tests

  • Add HTTP client timeout to health check (10s timeout)
  • Add pod readiness checks before health endpoint verification
  • Skip completed pods in checkPodsReady to prevent flaky test failures
  • Improved error messages to help diagnose connection reset issues

Fix Unrecognized Dotty Names

  • Fixed issue with unrecognized dotty names in the codebase

Infrastructure

Bump Operator CRDs Chart Version

  • Updated operator-crds chart version to 0.0.97 after rebase

Documentation Updates

  • Updated vmcp/README with optimizer integration information

Summary

This PR consolidates the complete integration of the MCP optimizer into vMCP, enabling semantic tool discovery, reducing token usage, and providing comprehensive observability. The integration includes full Kubernetes support, robust error handling, and improved test reliability.

Related PRs

@jerm-dro jerm-dro changed the title Update vmcp/README Optimizer in vMCP Jan 13, 2026
@github-actions github-actions bot added the size/XS Extra small PR: < 100 lines changed label Jan 13, 2026
@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 26.14458% with 1226 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.13%. Comparing base (3cb3a8f) to head (b765590).

Files with missing lines Patch % Lines
pkg/vmcp/optimizer/optimizer.go 8.13% 335 Missing and 4 partials ⚠️
pkg/optimizer/db/fts.go 10.89% 175 Missing and 5 partials ⚠️
pkg/optimizer/ingestion/service.go 0.00% 157 Missing ⚠️
pkg/optimizer/db/backend_tool.go 9.80% 137 Missing and 1 partial ⚠️
pkg/optimizer/db/backend_server.go 12.28% 99 Missing and 1 partial ⚠️
pkg/optimizer/db/hybrid.go 0.00% 73 Missing ⚠️
pkg/vmcp/server/server.go 27.05% 58 Missing and 4 partials ⚠️
pkg/optimizer/embeddings/ollama.go 19.29% 43 Missing and 3 partials ⚠️
pkg/optimizer/embeddings/manager.go 47.50% 32 Missing and 10 partials ⚠️
cmd/vmcp/app/commands.go 0.00% 28 Missing ⚠️
... and 7 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3278      +/-   ##
==========================================
- Coverage   64.81%   63.13%   -1.69%     
==========================================
  Files         372      386      +14     
  Lines       36163    37791    +1628     
==========================================
+ Hits        23440    23860     +420     
- Misses      10884    12052    +1168     
- Partials     1839     1879      +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@therealnb therealnb force-pushed the jerm/2026-01-13-optimizer-in-vmcp branch from c897084 to 7b932fc Compare January 19, 2026 15:49
@github-actions github-actions bot added size/XS Extra small PR: < 100 lines changed and removed size/XS Extra small PR: < 100 lines changed labels Jan 19, 2026
@therealnb therealnb force-pushed the jerm/2026-01-13-optimizer-in-vmcp branch from fdb387b to 29e89d0 Compare January 20, 2026 10:34
@github-actions github-actions bot removed the size/XS Extra small PR: < 100 lines changed label Jan 20, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Large PR Detected

This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.

How to unblock this PR:

Add a section to your PR description with the following format:

## Large PR Justification

[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformation

Alternative:

Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.

See our Contributing Guidelines for more details.


This review will be automatically dismissed once you add the justification section.

@github-actions github-actions bot added the size/XL Extra large PR: 1000+ lines changed label Jan 20, 2026
jerm-dro and others added 5 commits January 20, 2026 10:39
#3253)

* feat: Add optimizer package with semantic tool discovery and ingestion

This PR introduces the optimizer package, a Go port of the mcp-optimizer Python
service that provides semantic tool discovery and ingestion for MCP servers.

- **Semantic tool search** using vector embeddings (384-dim)
- **Token counting** for LLM cost estimation
- **Full-text search** via SQLite FTS5
- **Multiple embedding backends**: Ollama, vLLM, or placeholder (testing)
- **Production-ready database** with sqlite-vec for vector similarity search
* feat: Add optimizer integration endpoints and tool discovery

- Add find_tool and call_tool endpoints to vmcp optimizer
- Add semantic search and string matching for tool discovery
- Update optimizer integration documentation
- Add test scripts for optimizer functionality
)

* fix: Resolve tool names in optim.find_tool to match routing table
* feat: Add token metrics and observability to optimizer integration
@therealnb therealnb force-pushed the jerm/2026-01-13-optimizer-in-vmcp branch from 29e89d0 to eb22a40 Compare January 20, 2026 10:39
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 20, 2026
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 20, 2026
…failures

The checkPodsReady function was checking all pods with matching labels,
including old pods that had completed (Phase: Succeeded) from previous
deployments. This caused the auth discovery e2e test to fail when old
pods were still present during deployment updates.

Fix: Skip pods that are not in Running phase and ensure at least one
running pod exists after filtering.
@github-actions github-actions bot dismissed their stale review January 20, 2026 11:14

Large PR justification has been provided. Thank you!

@github-actions
Copy link
Contributor

✅ Large PR justification has been provided. The size review has been dismissed and this PR can now proceed with normal review.

@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 20, 2026
The test was failing with 'connection reset by peer' errors when trying
to connect to the health endpoint. This can happen if pods crash or
restart between the BeforeAll setup and the actual test execution.

Fix: Add explicit pod readiness verification right before the health check
and also check pod readiness inside the Eventually loop to catch pods
that crash during health check retries. This makes the test more robust
by ensuring pods are stable before attempting HTTP connections.
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 20, 2026
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 20, 2026
The health check was using http.Get() without a timeout, which could
cause hangs. Add an explicit HTTP client with 10s timeout and improve
error messages to help diagnose connection reset issues.
@github-actions github-actions bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Jan 20, 2026
yrobla and others added 7 commits January 20, 2026 18:50
* remove docs

* fixes from review

* simplify code and fixes from review

* fixes from review

* fix ci

---------

Co-authored-by: taskbot <taskbot@users.noreply.github.com>
Run the server as a standalone process

Previously it was instantiating the server in-process. Use the full
binary to ensure that the tests are realistic.
)

* fix: Resolve tool names in optim.find_tool to match routing table
…nfig

- Use DeepCopy() for automatic passthrough of config fields (Optimizer, Metadata, etc.)
- Add resolveEmbeddingService() to resolve Kubernetes Service names to URLs
- Ensures optimizer config is properly converted from CRD to runtime config
- Resolves embeddingService references in Kubernetes deployments
- Add CLI fallback for embeddingService when not resolved by operator
- Normalize localhost to 127.0.0.1 in embeddings to avoid IPv6 issues
- Add HTTP timeout (30s) to prevent hanging connections
- Remove WithContinuousListening() to use timeout-based approach
Add tracing spans to all aggregator methods to enable visibility
of capability aggregation in Jaeger. This includes spans for:
- AggregateCapabilities (parent span)
- QueryAllCapabilities (parallel backend queries)
- QueryCapabilities (per-backend queries)
- ResolveConflicts (conflict resolution)
- MergeCapabilities (final merge)

All spans include relevant attributes like backend counts, tool/resource/prompt
counts, and error recording. This fixes the issue where capability aggregation
logs appeared but no spans were visible in Jaeger.
Signed-off-by: nigel brown <nigel@stacklok.com>
@therealnb
Copy link
Contributor

Closing to create a new PR with updated description.

@therealnb therealnb closed this Jan 21, 2026
@therealnb
Copy link
Contributor

Superseded by #3373

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Extra large PR: 1000+ lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants