|
| 1 | +# MCP Integration Guide |
| 2 | + |
| 3 | +This guide provides detailed information on integrating with the Multi-Cloud Platform (MCP) and utilizing the IRIS SQL Tool within your RAG applications. |
| 4 | + |
| 5 | +## 1. Overview of MCP Integration |
| 6 | + |
| 7 | +The MCP integration allows you to deploy and manage RAG services as microservices, providing a flexible and scalable architecture. This design facilitates seamless integration with various enterprise systems and cloud environments. |
| 8 | + |
| 9 | +## 2. Creating MCP Servers |
| 10 | + |
| 11 | +To create an MCP server, use the `createMCPServer` function from the `@rag-templates/mcp` package. |
| 12 | + |
| 13 | +### Example: |
| 14 | +```javascript |
| 15 | +import { createMCPServer } from '@rag-templates/mcp'; |
| 16 | + |
| 17 | +const server = createMCPServer({ |
| 18 | + name: "my-rag-server", |
| 19 | + description: "A custom RAG server for specific knowledge base", |
| 20 | + ragConfig: { |
| 21 | + technique: 'basic', // or 'colbert', 'crag', etc. |
| 22 | + llm_provider: 'openai', |
| 23 | + embedding_model: 'text-embedding-ada-002' |
| 24 | + }, |
| 25 | + // Additional server configurations can be added here |
| 26 | + port: 3000 |
| 27 | +}); |
| 28 | + |
| 29 | +server.start(); |
| 30 | +``` |
| 31 | + |
| 32 | +### Configuration Options for `createMCPServer`: |
| 33 | + |
| 34 | +- `name`: (String, required) A unique name for your MCP server. |
| 35 | +- `description`: (String, optional) A brief description of the server's purpose. |
| 36 | +- `ragConfig`: (Object, required) Configuration for the RAG pipeline. This object can include: |
| 37 | + - `technique`: (String) The RAG technique to use (e.g., 'basic', 'colbert', 'crag', 'hyde', 'graphrag', 'hybrid_ifind', 'noderag'). |
| 38 | + - `llm_provider`: (String) The LLM provider (e.g., 'openai', 'azure_openai'). |
| 39 | + - `embedding_model`: (String) The embedding model to use. |
| 40 | + - Any other valid RAG configuration parameters. |
| 41 | +- `port`: (Number, optional) The port on which the MCP server will listen. Defaults to a system-assigned port if not specified. |
| 42 | + |
| 43 | +## 3. IRIS SQL Tool Integration |
| 44 | + |
| 45 | +The IRIS SQL Tool provides direct SQL access and advanced vector search capabilities, allowing you to interact with your InterSystems IRIS database directly from your MCP-deployed RAG services. This is particularly useful for: |
| 46 | + |
| 47 | +- **Complex Data Retrieval**: Executing custom SQL queries to fetch data that might not be directly accessible via standard RAG pipeline methods. |
| 48 | +- **Vector Search**: Leveraging IRIS's native vector search capabilities for highly efficient similarity searches. |
| 49 | +- **Data Management**: Performing CRUD operations on your RAG data within the IRIS database. |
| 50 | + |
| 51 | +### How to Use the IRIS SQL Tool: |
| 52 | + |
| 53 | +The IRIS SQL Tool is exposed through the MCP server's API. You can send SQL queries or vector search requests to the MCP server, which will then execute them against the configured InterSystems IRIS database. |
| 54 | + |
| 55 | +### Example (Conceptual API Call): |
| 56 | + |
| 57 | +```javascript |
| 58 | +// Assuming you have an MCP server running at http://localhost:3000 |
| 59 | +const mcpServerUrl = 'http://localhost:3000'; |
| 60 | + |
| 61 | +// Example: Execute a SQL query |
| 62 | +async function executeSqlQuery(query) { |
| 63 | + const response = await fetch(`${mcpServerUrl}/sql`, { |
| 64 | + method: 'POST', |
| 65 | + headers: { |
| 66 | + 'Content-Type': 'application/json' |
| 67 | + }, |
| 68 | + body: JSON.stringify({ query: query }) |
| 69 | + }); |
| 70 | + return response.json(); |
| 71 | +} |
| 72 | + |
| 73 | +// Example: Perform a vector search |
| 74 | +async function performVectorSearch(vector, topK) { |
| 75 | + const response = await fetch(`${mcpServerUrl}/vector-search`, { |
| 76 | + method: 'POST', |
| 77 | + headers: { |
| 78 | + 'Content-Type': 'application/json' |
| 79 | + }, |
| 80 | + body: JSON.stringify({ vector: vector, topK: topK }) |
| 81 | + }); |
| 82 | + return response.json(); |
| 83 | +} |
| 84 | + |
| 85 | +// Usage |
| 86 | +// executeSqlQuery("SELECT TOP 10 * FROM MyDocuments WHERE Category = 'Science'") |
| 87 | +// .then(data => console.log("SQL Query Result:", data)) |
| 88 | +// .catch(error => console.error("Error executing SQL query:", error)); |
| 89 | + |
| 90 | +// performVectorSearch([0.1, 0.2, ..., 0.N], 5) // Replace with actual vector |
| 91 | +// .then(data => console.log("Vector Search Result:", data)) |
| 92 | +// .catch(error => console.error("Error performing vector search:", error)); |
| 93 | +``` |
| 94 | + |
| 95 | +**Note**: The exact API endpoints and request/response formats for the IRIS SQL Tool will depend on the implementation within the MCP server. Refer to the server's API documentation or source code for precise details. |
| 96 | + |
| 97 | +## 4. Deployment and Management |
| 98 | + |
| 99 | +Details on deploying MCP servers to various environments (e.g., Docker, Kubernetes) and managing their lifecycle will be covered in separate deployment guides. |
| 100 | + |
| 101 | +## 5. Troubleshooting |
| 102 | + |
| 103 | +For common issues and troubleshooting tips related to MCP integration and the IRIS SQL Tool, refer to the project's main documentation or open an issue on the GitHub repository. |
0 commit comments