m8ty_client_mcprag
MCP RAG client for semantic tool search, embeddings, and tool catalog access. Enables AI-powered discovery of API tools via vector similarity search.
Before you start
Check the documentation of the m8ty_client_mcprag library.
Import all needed libraries
import 'package:dio/dio.dart';
import 'package:m8ty_client_mcprag/m8ty_client_mcprag.dart';
Client Setup
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',
);
API Surface
McpRagApi
Method | Description |
|---|---|
| Create text embeddings for semantic search |
| Get the full MCP tool catalog |
| Get tool catalog with pre-computed vectors |
| Search tools by natural language or vector |
How to perform different tasks
Here some examples how the dart client can be used
Create an embedding
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}');
}
Search tools by natural language
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;
}
Search tools by precomputed vector
final request = McpToolSearchRequestModel((b) => b
..vector.addAll(queryVector)
..topK = 5);
final response = await ragApi.searchMcpRagTools(
mcpToolSearchRequestModel: request,
);
Restrict search to specific tool names
final request = McpToolSearchRequestModel((b) => b
..text = 'Create an order'
..toolNames.addAll(['orders_create_order'])
..topK = 3);
final response = await ragApi.searchMcpRagTools(
mcpToolSearchRequestModel: request,
);
Get tool catalog
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
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}');
}
03 June 2026