m8ty_client_mcprag
Package overview
Section titled “Package overview”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.
Before you start
Section titled “Before you start”Check the documentation of the m8ty_client_mcprag library.
Import all needed libraries
Section titled “Import all needed libraries”import 'package:dio/dio.dart';import 'package:m8ty_client_mcprag/m8ty_client_mcprag.dart';Client Setup
Section titled “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
Section titled “API Surface”McpRagApi
Section titled “McpRagApi”| 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 |
How to perform different tasks
Section titled “How to perform different tasks”Here some examples how the dart client can be used
Create an embedding
Section titled “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
Section titled “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
Section titled “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
Section titled “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
Section titled “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
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}');}© m8ty GmbH 2023 · m8ty.eu
