Skip to content

m8ty_client_mcprag

m8ty_client_mcprag solves this with embeddings and semantic tool search, allowing applications to discover relevant MCP tools from intent rather than rigid keyword or menu navigation.

MCP RAG client for semantic tool search, embeddings, and tool catalog access. Enables AI-powered discovery of API tools via vector similarity search.

Check the documentation of the m8ty_client_mcprag library.

import 'package:dio/dio.dart';
import 'package:m8ty_client_mcprag/m8ty_client_mcprag.dart';
final client = M8tyClientMcprag();
client.setOAuthToken('ApiOAuth2', accessToken);
final ragApi = client.getMcpRagApi();

Use basePathOverride for tests, staging, or tenant-specific routing:

final client = M8tyClientMcprag(
basePathOverride: 'https://staging.example.com/api/v1',
);
Method Description
createMcpRagEmbedding Create text embeddings for semantic search
getMcpRagCatalog Get the full MCP tool catalog
getMcpRagVectorizedCatalog Get tool catalog with pre-computed vectors
searchMcpRagTools Search tools by natural language or vector

Here some examples how the dart client can be used

final request = McpEmbedRequestModel((b) => b
..text = 'Find tools that can summarize PDF documents'
..inputType = 'query');
try {
final response = await ragApi.createMcpRagEmbedding(
mcpEmbedRequestModel: request,
);
final embedding = response.data;
if (embedding == null) {
throw StateError('Embedding response was empty.');
}
final vector = embedding.vector;
} on DioException catch (e) {
throw StateError('Embedding request failed: ${e.response?.statusCode}');
}
final request = McpToolSearchRequestModel((b) => b
..text = 'Find a tool that can retrieve a portfolio position'
..topK = 10
..minScore = 0.25);
final response = await ragApi.searchMcpRagTools(
mcpToolSearchRequestModel: request,
);
final matches = response.data?.matches;
if (matches == null || matches.isEmpty) {
return;
}
final request = McpToolSearchRequestModel((b) => b
..vector.addAll(queryVector)
..topK = 5);
final response = await ragApi.searchMcpRagTools(
mcpToolSearchRequestModel: request,
);
final request = McpToolSearchRequestModel((b) => b
..text = 'Create an order'
..toolNames.addAll(['orders_create_order'])
..topK = 3);
final response = await ragApi.searchMcpRagTools(
mcpToolSearchRequestModel: request,
);
final response = await ragApi.getMcpRagCatalog();
final catalog = response.data;
if (catalog == null) {
return;
}
for (final tool in catalog.tools) {
print('${tool.toolName}: ${tool.summary}');
}

Get vectorized catalog for synchronization

Section titled “Get vectorized catalog for synchronization”
final response = await ragApi.getMcpRagVectorizedCatalog();
final catalog = response.data;
for (final item in catalog!.tools) {
print('Tool: ${item.tool.toolName}, Vector length: ${item.vector.length}');
}