ims-mcp 1.0.16__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ims_mcp-1.0.16/LICENSE ADDED
@@ -0,0 +1,52 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Igor Solomatov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ================================================================================
24
+ THIRD-PARTY SOFTWARE NOTICES AND INFORMATION
25
+ ================================================================================
26
+
27
+ This package integrates with and depends on R2R (RAG to Riches), which is
28
+ licensed under the MIT License:
29
+
30
+ R2R - Advanced AI Retrieval System
31
+ Copyright (c) 2024 SciPhi AI
32
+ Repository: https://github.com/SciPhi-AI/R2R
33
+ License: MIT
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining a copy
36
+ of this software and associated documentation files (the "Software"), to deal
37
+ in the Software without restriction, including without limitation the rights
38
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39
+ copies of the Software, and to permit persons to whom the Software is
40
+ furnished to do so, subject to the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be included in all
43
+ copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
48
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
51
+ SOFTWARE.
52
+
@@ -0,0 +1,359 @@
1
+ Metadata-Version: 2.4
2
+ Name: ims-mcp
3
+ Version: 1.0.16
4
+ Summary: Model Context Protocol server for IMS (Instruction Management Systems)
5
+ Author: Igor Solomatov
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://pypi.org/project/ims-mcp/
8
+ Keywords: mcp,ims,retrieval,rag,ai,llm,model-context-protocol,knowledge-base
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: r2r>=3.6.0
21
+ Requires-Dist: mcp>=1.0.0
22
+ Provides-Extra: dev
23
+ Requires-Dist: build>=1.0.0; extra == "dev"
24
+ Requires-Dist: twine>=4.0.0; extra == "dev"
25
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # ims-mcp
29
+
30
+ **Model Context Protocol (MCP) server for Rosetta (Enterprise Engineering Governance and Instructions Management System)**
31
+
32
+ *Powered by R2R technology for advanced RAG capabilities*
33
+
34
+ This package provides a FastMCP server that connects to IMS servers for advanced retrieval-augmented generation (RAG) capabilities. It enables AI assistants like Claude Desktop, Cursor, and other MCP clients to search, retrieve, and manage documents in Rosetta knowledge bases.
35
+
36
+ ## Features
37
+
38
+ - 🔍 **Semantic Search** - Vector-based and full-text search across documents
39
+ - 🤖 **RAG Queries** - Retrieval-augmented generation with configurable LLM settings
40
+ - 📝 **Document Management** - Upload, update, list, and delete documents with upsert semantics
41
+ - 🏷️ **Metadata Filtering** - Advanced filtering by tags, domain, and custom metadata
42
+ - 🌐 **Environment-Based Config** - Zero configuration, reads from environment variables
43
+ - 📋 **Bootstrap Instructions** - Automatically includes PREP step instructions for LLMs on connection
44
+
45
+ ## Installation
46
+
47
+ ### Using uvx (recommended)
48
+
49
+ The easiest way to use ims-mcp is with `uvx`, which automatically handles installation:
50
+
51
+ ```bash
52
+ uvx ims-mcp
53
+ ```
54
+
55
+ ### Using pip
56
+
57
+ Install globally or in a virtual environment:
58
+
59
+ ```bash
60
+ pip install ims-mcp
61
+ ```
62
+
63
+ Then run:
64
+
65
+ ```bash
66
+ ims-mcp
67
+ ```
68
+
69
+ ### As a Python Module
70
+
71
+ You can also run it as a module:
72
+
73
+ ```bash
74
+ python -m ims_mcp
75
+ ```
76
+
77
+ ## Configuration
78
+
79
+ The server automatically reads configuration from environment variables:
80
+
81
+ | Variable | Description | Default |
82
+ |----------|-------------|---------|
83
+ | `R2R_API_BASE` or `R2R_BASE_URL` | IMS server URL | `http://localhost:7272` |
84
+ | `R2R_COLLECTION` | Collection name for queries | Server default |
85
+ | `R2R_API_KEY` | API key for authentication | None |
86
+ | `R2R_EMAIL` | Email for authentication (requires R2R_PASSWORD) | None |
87
+ | `R2R_PASSWORD` | Password for authentication (requires R2R_EMAIL) | None |
88
+ | `IMS_DEBUG` | Enable debug logging to stderr (1/true/yes/on) | None (disabled) |
89
+
90
+ **Authentication Priority:**
91
+ 1. If `R2R_API_KEY` is set, it will be used
92
+ 2. If `R2R_EMAIL` and `R2R_PASSWORD` are set, they will be used to login and obtain an access token
93
+ 3. If neither is set, the client will attempt unauthenticated access (works for local servers)
94
+
95
+ **Note:** Environment variables use `R2R_` prefix for compatibility with the underlying R2R SDK.
96
+
97
+ ## Usage with MCP Clients
98
+
99
+ ### Cursor IDE
100
+
101
+ **Local server (no authentication):**
102
+
103
+ Add to `.cursor/mcp.json`:
104
+
105
+ ```json
106
+ {
107
+ "mcpServers": {
108
+ "KnowledgeBase": {
109
+ "command": "uvx",
110
+ "args": ["ims-mcp"],
111
+ "env": {
112
+ "R2R_API_BASE": "http://localhost:7272",
113
+ "R2R_COLLECTION": "aia-r1"
114
+ }
115
+ }
116
+ }
117
+ }
118
+ ```
119
+
120
+ **Remote server (with email/password authentication):**
121
+
122
+ ```json
123
+ {
124
+ "mcpServers": {
125
+ "KnowledgeBase": {
126
+ "command": "uvx",
127
+ "args": ["ims-mcp"],
128
+ "env": {
129
+ "R2R_API_BASE": "https://your-server.example.com/",
130
+ "R2R_COLLECTION": "your-collection",
131
+ "R2R_EMAIL": "your-email@example.com",
132
+ "R2R_PASSWORD": "your-password"
133
+ }
134
+ }
135
+ }
136
+ }
137
+ ```
138
+
139
+ ### Claude Desktop
140
+
141
+ Add to Claude Desktop configuration (`~/Library/Application Support/Claude/claude_desktop_config.json` on macOS):
142
+
143
+ ```json
144
+ {
145
+ "mcpServers": {
146
+ "ims": {
147
+ "command": "uvx",
148
+ "args": ["ims-mcp"],
149
+ "env": {
150
+ "R2R_API_BASE": "http://localhost:7272",
151
+ "R2R_COLLECTION": "my-collection"
152
+ }
153
+ }
154
+ }
155
+ }
156
+ ```
157
+
158
+ ### Other MCP Clients
159
+
160
+ Any MCP client can use ims-mcp by specifying the command and environment variables:
161
+
162
+ ```json
163
+ {
164
+ "command": "uvx",
165
+ "args": ["ims-mcp"],
166
+ "env": {
167
+ "R2R_API_BASE": "http://localhost:7272"
168
+ }
169
+ }
170
+ ```
171
+
172
+ ## Available MCP Tools
173
+
174
+ ### 1. search
175
+
176
+ Perform semantic and full-text search across documents.
177
+
178
+ **Parameters:**
179
+ - `query` (str): Search query
180
+ - `filters` (dict, optional): Metadata filters (e.g., `{"tags": {"$in": ["agents"]}}`)
181
+ - `limit` (int, optional): Maximum results
182
+ - `use_semantic_search` (bool, optional): Enable vector search
183
+ - `use_fulltext_search` (bool, optional): Enable full-text search
184
+
185
+ **Example:**
186
+ ```python
187
+ search("machine learning", filters={"tags": {"$in": ["research"]}}, limit=5)
188
+ ```
189
+
190
+ ### 2. rag
191
+
192
+ Retrieval-augmented generation with LLM.
193
+
194
+ **Parameters:**
195
+ - `query` (str): Question to answer
196
+ - `filters` (dict, optional): Metadata filters
197
+ - `limit` (int, optional): Max search results to use
198
+ - `model` (str, optional): LLM model name
199
+ - `temperature` (float, optional): Response randomness (0-1)
200
+ - `max_tokens` (int, optional): Max response length
201
+
202
+ **Example:**
203
+ ```python
204
+ rag("What is machine learning?", model="gpt-4", temperature=0.7)
205
+ ```
206
+
207
+ ### 3. put_document
208
+
209
+ Upload or update a document with upsert semantics.
210
+
211
+ **Parameters:**
212
+ - `content` (str): Document text content
213
+ - `title` (str): Document title
214
+ - `metadata` (dict, optional): Custom metadata (e.g., `{"tags": ["research"], "author": "John"}`)
215
+ - `document_id` (str, optional): Explicit document ID
216
+
217
+ **Example:**
218
+ ```python
219
+ put_document(
220
+ content="Machine learning is...",
221
+ title="ML Guide",
222
+ metadata={"tags": ["research", "ml"]}
223
+ )
224
+ ```
225
+
226
+ ### 4. list_documents
227
+
228
+ List documents with pagination and optional tag filtering.
229
+
230
+ **Parameters:**
231
+ - `offset` (int, optional): Documents to skip (default: 0)
232
+ - `limit` (int, optional): Max documents (default: 100)
233
+ - `document_ids` (list[str], optional): Specific IDs to retrieve
234
+ - `compact_view` (bool, optional): Show only ID and title (default: True)
235
+ - `tags` (list[str], optional): Filter by tags (e.g., `["agents", "r1"]`)
236
+ - `match_all_tags` (bool, optional): If True, document must have ALL tags; if False (default), document must have ANY tag
237
+
238
+ **Examples:**
239
+ ```python
240
+ # List all documents (compact view - ID and title only)
241
+ list_documents(offset=0, limit=10)
242
+
243
+ # List with full details
244
+ list_documents(offset=0, limit=10, compact_view=False)
245
+
246
+ # Filter by tags (ANY mode - documents with "research" OR "ml")
247
+ list_documents(tags=["research", "ml"])
248
+
249
+ # Filter by tags (ALL mode - documents with both "research" AND "ml")
250
+ list_documents(tags=["research", "ml"], match_all_tags=True)
251
+ ```
252
+
253
+ **Note:** Tag filtering is performed client-side after fetching results. For large collections with complex filtering needs, consider using the `search()` tool with metadata filters instead.
254
+
255
+ ### 5. get_document
256
+
257
+ Retrieve a specific document by ID or title.
258
+
259
+ **Parameters:**
260
+ - `document_id` (str, optional): Document ID
261
+ - `title` (str, optional): Document title
262
+
263
+ **Example:**
264
+ ```python
265
+ get_document(title="ML Guide")
266
+ ```
267
+
268
+ ### 6. delete_document
269
+
270
+ Delete a document by ID.
271
+
272
+ **Parameters:**
273
+ - `document_id` (str, required): The unique identifier of the document to delete
274
+
275
+ **Example:**
276
+ ```python
277
+ delete_document(document_id="550e8400-e29b-41d4-a716-446655440000")
278
+ ```
279
+
280
+ **Returns:**
281
+ - Success message with document ID on successful deletion
282
+ - Error message if document not found or permission denied
283
+
284
+ ## Metadata Filtering
285
+
286
+ All filter operators supported:
287
+
288
+ - `$eq`: Equal
289
+ - `$neq`: Not equal
290
+ - `$gt`, `$gte`: Greater than (or equal)
291
+ - `$lt`, `$lte`: Less than (or equal)
292
+ - `$in`: In array
293
+ - `$nin`: Not in array
294
+ - `$like`, `$ilike`: Pattern matching (case-sensitive/insensitive)
295
+
296
+ **Examples:**
297
+
298
+ ```python
299
+ # Filter by tags
300
+ filters={"tags": {"$in": ["research", "ml"]}}
301
+
302
+ # Filter by domain
303
+ filters={"domain": {"$eq": "instructions"}}
304
+
305
+ # Combined filters
306
+ filters={"tags": {"$in": ["research"]}, "created_at": {"$gte": "2024-01-01"}}
307
+ ```
308
+
309
+ ## Development
310
+
311
+ ### Local Installation
312
+
313
+ Install directly from PyPI:
314
+
315
+ ```bash
316
+ pip install ims-mcp
317
+ ```
318
+
319
+ Or for the latest development version, install from source if you have the code locally:
320
+
321
+ ```bash
322
+ pip install -e .
323
+ ```
324
+
325
+ ### Running Tests
326
+
327
+ ```bash
328
+ pip install -e ".[dev]"
329
+ pytest
330
+ ```
331
+
332
+ ### Building for Distribution
333
+
334
+ ```bash
335
+ python -m build
336
+ ```
337
+
338
+ ## Requirements
339
+
340
+ - Python >= 3.10
341
+ - IMS server running and accessible (powered by R2R Light)
342
+ - r2r Python SDK >= 3.6.0
343
+ - mcp >= 1.0.0
344
+
345
+ ## License
346
+
347
+ MIT License - see LICENSE file for details
348
+
349
+ This package is built on R2R (RAG to Riches) technology by SciPhi AI, which is licensed under the MIT License. We gratefully acknowledge the R2R project and its contributors.
350
+
351
+ ## Links
352
+
353
+ - **R2R Technology**: https://github.com/SciPhi-AI/R2R
354
+ - **Model Context Protocol**: https://modelcontextprotocol.io/
355
+ - **FastMCP**: https://github.com/jlowin/fastmcp
356
+
357
+ ## Support
358
+
359
+ For issues and questions, visit the package page: https://pypi.org/project/ims-mcp/