6.4 The embedding provider abstraction

The only vendor-coupled seam in the codebase is one Java interface:

public interface EmbeddingProvider {
    float[]        embed(String text)             throws Exception;
    List<float[]>  embedBatch(List<String> texts) throws Exception;
    String         modelName();
    int            dimensions();
}

The shipped implementation is OpenAIEmbeddingProvider, which POSTs to EMBEDDING_ENDPOINT with the OpenAI-compatible /v1/embeddings shape. The endpoint URL is configurable, so the same class works against any OpenAI-compatible service: a self-hosted Ollama with the OpenAI shim, OpenRouter, an in-VPC proxy, etc.

For tests, MockEmbeddingProvider hashes the input and produces a deterministic vector — offline, fast, repeatable.

Adding a genuinely new provider (different request/response shape) is one new class implementing EmbeddingProvider plus a one-line change in MCPServer.<clinit> to instantiate it.

The two “provider” fields stamped on every row (embedding_provider, embedding_model) let the system tell what produced what without inspecting vectors directly.