mcp-server-milvus 0.1.1.dev3__tar.gz → 0.1.1.dev4__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.
Potentially problematic release.
This version of mcp-server-milvus might be problematic. Click here for more details.
- mcp_server_milvus-0.1.1.dev4/LICENSE +201 -0
- {mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/PKG-INFO +22 -13
- {mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/README.md +18 -7
- {mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/pyproject.toml +10 -7
- {mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/src/mcp_server_milvus/server.py +67 -28
- mcp_server_milvus-0.1.1.dev4/uv.lock +816 -0
- mcp_server_milvus-0.1.1.dev3/src/mcp_server_milvus/example.env +0 -3
- mcp_server_milvus-0.1.1.dev3/src/mcp_server_milvus/main.py +0 -4
- mcp_server_milvus-0.1.1.dev3/uv.lock +0 -757
- {mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/.cursor/mcp.json +0 -0
- {mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/.gitattributes +0 -0
- {mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/.gitignore +0 -0
- {mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/.python-version +0 -0
- {mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/Claude_mcp+1080.gif +0 -0
- {mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/src/mcp_server_milvus/__init__.py +0 -0
- {mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/src/mcp_server_milvus/blogpost.md +0 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2019 Zilliz
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp-server-milvus
|
|
3
|
-
Version: 0.1.1.
|
|
3
|
+
Version: 0.1.1.dev4
|
|
4
4
|
Summary: MCP server for Milvus
|
|
5
|
+
License-File: LICENSE
|
|
5
6
|
Requires-Python: >=3.10
|
|
6
|
-
Requires-Dist:
|
|
7
|
-
Requires-Dist:
|
|
8
|
-
Requires-Dist: mcp[cli]>=1.1.2
|
|
9
|
-
Requires-Dist: pymilvus>=2.5.1
|
|
10
|
-
Requires-Dist: ruff>=0.11.0
|
|
7
|
+
Requires-Dist: mcp[cli]>=1.9.0
|
|
8
|
+
Requires-Dist: pymilvus>=2.5.8
|
|
11
9
|
Description-Content-Type: text/markdown
|
|
12
10
|
|
|
13
11
|
# MCP Server for Milvus
|
|
@@ -16,6 +14,8 @@ Description-Content-Type: text/markdown
|
|
|
16
14
|
|
|
17
15
|
This repository contains a MCP server that provides access to [Milvus](https://milvus.io/) vector database functionality.
|
|
18
16
|
|
|
17
|
+
**Note:** This repository is a fork of https://github.com/zilliztech/mcp-server-milvus.git with various improvements and added support for `uvx` execution, making it easier to run without installation.
|
|
18
|
+
|
|
19
19
|

|
|
20
20
|
|
|
21
21
|
## Prerequisites
|
|
@@ -33,7 +33,7 @@ The recommended way to use this MCP server is to run it directly with `uv` witho
|
|
|
33
33
|
If you want to clone the repository:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
git clone https://github.com/
|
|
36
|
+
git clone https://github.com/danchev/mcp-server-milvus.git
|
|
37
37
|
cd mcp-server-milvus
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -42,15 +42,20 @@ Then you can run the server directly:
|
|
|
42
42
|
```bash
|
|
43
43
|
uv run mcp-server-milvus --milvus-uri http://localhost:19530
|
|
44
44
|
```
|
|
45
|
-
|
|
46
|
-
Alternatively you can change the .env file in the `src/mcp_server_milvus/` directory to set the environment variables and run the server with the following command:
|
|
45
|
+
Alternatively, you can set environment variables using a `.env` file in your project directory and then run the server with a simpler command:
|
|
47
46
|
|
|
48
47
|
```bash
|
|
48
|
+
# Create a .env file with your Milvus configuration
|
|
49
|
+
cat > .env <<EOF
|
|
50
|
+
MILVUS_URI=http://localhost:19530
|
|
51
|
+
MILVUS_TOKEN=your_token_if_needed
|
|
52
|
+
MILVUS_DB=default
|
|
53
|
+
EOF
|
|
54
|
+
|
|
55
|
+
# Run the server (it will automatically read from .env)
|
|
49
56
|
uv run mcp-server-milvus
|
|
50
57
|
```
|
|
51
58
|
|
|
52
|
-
### Important: the .env file will have higher priority than the command line arguments.
|
|
53
|
-
|
|
54
59
|
## Supported Applications
|
|
55
60
|
|
|
56
61
|
This MCP server can be used with various LLM applications that support the Model Context Protocol:
|
|
@@ -194,6 +199,10 @@ The server provides the following tools:
|
|
|
194
199
|
- Parameters:
|
|
195
200
|
- `collection_name`: Name of collection to release
|
|
196
201
|
|
|
202
|
+
- `milvus_get_collection_info`: Lists detailed information like schema, properties, collection ID, and other metadata of a specific collection.
|
|
203
|
+
- Parameters:
|
|
204
|
+
- `collection_name`: Name of the collection to get detailed information about
|
|
205
|
+
|
|
197
206
|
### Data Operations
|
|
198
207
|
|
|
199
208
|
- `milvus_insert_data`: Insert data into a collection
|
|
@@ -215,10 +224,10 @@ The server provides the following tools:
|
|
|
215
224
|
|
|
216
225
|
## Development
|
|
217
226
|
|
|
218
|
-
To run the server
|
|
227
|
+
To run the server using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):
|
|
219
228
|
|
|
220
229
|
```bash
|
|
221
|
-
uv run server.py
|
|
230
|
+
uv run mcp dev src/mcp_server_milvus/server.py
|
|
222
231
|
```
|
|
223
232
|
|
|
224
233
|
## Examples
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
This repository contains a MCP server that provides access to [Milvus](https://milvus.io/) vector database functionality.
|
|
6
6
|
|
|
7
|
+
**Note:** This repository is a fork of https://github.com/zilliztech/mcp-server-milvus.git with various improvements and added support for `uvx` execution, making it easier to run without installation.
|
|
8
|
+
|
|
7
9
|

|
|
8
10
|
|
|
9
11
|
## Prerequisites
|
|
@@ -21,7 +23,7 @@ The recommended way to use this MCP server is to run it directly with `uv` witho
|
|
|
21
23
|
If you want to clone the repository:
|
|
22
24
|
|
|
23
25
|
```bash
|
|
24
|
-
git clone https://github.com/
|
|
26
|
+
git clone https://github.com/danchev/mcp-server-milvus.git
|
|
25
27
|
cd mcp-server-milvus
|
|
26
28
|
```
|
|
27
29
|
|
|
@@ -30,15 +32,20 @@ Then you can run the server directly:
|
|
|
30
32
|
```bash
|
|
31
33
|
uv run mcp-server-milvus --milvus-uri http://localhost:19530
|
|
32
34
|
```
|
|
33
|
-
|
|
34
|
-
Alternatively you can change the .env file in the `src/mcp_server_milvus/` directory to set the environment variables and run the server with the following command:
|
|
35
|
+
Alternatively, you can set environment variables using a `.env` file in your project directory and then run the server with a simpler command:
|
|
35
36
|
|
|
36
37
|
```bash
|
|
38
|
+
# Create a .env file with your Milvus configuration
|
|
39
|
+
cat > .env <<EOF
|
|
40
|
+
MILVUS_URI=http://localhost:19530
|
|
41
|
+
MILVUS_TOKEN=your_token_if_needed
|
|
42
|
+
MILVUS_DB=default
|
|
43
|
+
EOF
|
|
44
|
+
|
|
45
|
+
# Run the server (it will automatically read from .env)
|
|
37
46
|
uv run mcp-server-milvus
|
|
38
47
|
```
|
|
39
48
|
|
|
40
|
-
### Important: the .env file will have higher priority than the command line arguments.
|
|
41
|
-
|
|
42
49
|
## Supported Applications
|
|
43
50
|
|
|
44
51
|
This MCP server can be used with various LLM applications that support the Model Context Protocol:
|
|
@@ -182,6 +189,10 @@ The server provides the following tools:
|
|
|
182
189
|
- Parameters:
|
|
183
190
|
- `collection_name`: Name of collection to release
|
|
184
191
|
|
|
192
|
+
- `milvus_get_collection_info`: Lists detailed information like schema, properties, collection ID, and other metadata of a specific collection.
|
|
193
|
+
- Parameters:
|
|
194
|
+
- `collection_name`: Name of the collection to get detailed information about
|
|
195
|
+
|
|
185
196
|
### Data Operations
|
|
186
197
|
|
|
187
198
|
- `milvus_insert_data`: Insert data into a collection
|
|
@@ -203,10 +214,10 @@ The server provides the following tools:
|
|
|
203
214
|
|
|
204
215
|
## Development
|
|
205
216
|
|
|
206
|
-
To run the server
|
|
217
|
+
To run the server using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):
|
|
207
218
|
|
|
208
219
|
```bash
|
|
209
|
-
uv run server.py
|
|
220
|
+
uv run mcp dev src/mcp_server_milvus/server.py
|
|
210
221
|
```
|
|
211
222
|
|
|
212
223
|
## Examples
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mcp-server-milvus"
|
|
3
|
-
version = "0.1.1.
|
|
3
|
+
version = "0.1.1.dev4"
|
|
4
4
|
description = "MCP server for Milvus"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
7
7
|
dependencies = [
|
|
8
|
-
"mcp[cli]>=1.
|
|
9
|
-
"pymilvus>=2.5.
|
|
10
|
-
"click>=8.0.0",
|
|
11
|
-
"ruff>=0.11.0",
|
|
12
|
-
"dotenv>=0.9.9",
|
|
8
|
+
"mcp[cli]>=1.9.0",
|
|
9
|
+
"pymilvus>=2.5.8",
|
|
13
10
|
]
|
|
14
11
|
|
|
15
12
|
[project.scripts]
|
|
16
|
-
mcp-server-milvus = "mcp_server_milvus:main"
|
|
13
|
+
mcp-server-milvus = "mcp_server_milvus.server:main"
|
|
17
14
|
|
|
18
15
|
[build-system]
|
|
19
16
|
requires = ["hatchling"]
|
|
@@ -21,3 +18,9 @@ build-backend = "hatchling.build"
|
|
|
21
18
|
|
|
22
19
|
[tool.hatch.build.targets.wheel]
|
|
23
20
|
packages = ["src/mcp_server_milvus"]
|
|
21
|
+
|
|
22
|
+
[dependency-groups]
|
|
23
|
+
dev = [
|
|
24
|
+
"ruff>=0.11.10",
|
|
25
|
+
"ty>=0.0.1a4",
|
|
26
|
+
]
|
{mcp_server_milvus-0.1.1.dev3 → mcp_server_milvus-0.1.1.dev4}/src/mcp_server_milvus/server.py
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import argparse
|
|
2
|
+
import json
|
|
2
3
|
import os
|
|
3
4
|
from contextlib import asynccontextmanager
|
|
4
5
|
from typing import Any, AsyncIterator, Optional
|
|
5
|
-
from dotenv import load_dotenv
|
|
6
6
|
|
|
7
7
|
from mcp.server.fastmcp import Context, FastMCP
|
|
8
8
|
from pymilvus import DataType, MilvusClient
|
|
@@ -16,6 +16,25 @@ class MilvusConnector:
|
|
|
16
16
|
self.token = token
|
|
17
17
|
self.client = MilvusClient(uri=uri, token=token, db_name=db_name)
|
|
18
18
|
|
|
19
|
+
@classmethod
|
|
20
|
+
def from_env(cls) -> "MilvusConnector":
|
|
21
|
+
"""
|
|
22
|
+
Create a MilvusConnector instance from environment variables.
|
|
23
|
+
|
|
24
|
+
Environment variables:
|
|
25
|
+
- MILVUS_URI: Milvus server URI (required)
|
|
26
|
+
- MILVUS_TOKEN: Authentication token (optional)
|
|
27
|
+
- MILVUS_DB: Database name (defaults to "default")
|
|
28
|
+
"""
|
|
29
|
+
uri = os.environ.get("MILVUS_URI")
|
|
30
|
+
if not uri:
|
|
31
|
+
raise ValueError("MILVUS_URI environment variable must be set")
|
|
32
|
+
|
|
33
|
+
token = os.environ.get("MILVUS_TOKEN")
|
|
34
|
+
db_name = os.environ.get("MILVUS_DB", "default")
|
|
35
|
+
|
|
36
|
+
return cls(uri=uri, token=token, db_name=db_name)
|
|
37
|
+
|
|
19
38
|
async def list_collections(self) -> list[str]:
|
|
20
39
|
"""List all collections in the database."""
|
|
21
40
|
try:
|
|
@@ -89,6 +108,7 @@ class MilvusConnector:
|
|
|
89
108
|
limit: int = 5,
|
|
90
109
|
output_fields: Optional[list[str]] = None,
|
|
91
110
|
metric_type: str = "COSINE",
|
|
111
|
+
filter_expr: Optional[str] = None,
|
|
92
112
|
) -> list[dict]:
|
|
93
113
|
"""
|
|
94
114
|
Perform vector similarity search on a collection.
|
|
@@ -112,7 +132,7 @@ class MilvusConnector:
|
|
|
112
132
|
search_params=search_params,
|
|
113
133
|
limit=limit,
|
|
114
134
|
output_fields=output_fields,
|
|
115
|
-
|
|
135
|
+
filter=filter_expr,
|
|
116
136
|
)
|
|
117
137
|
return results
|
|
118
138
|
except Exception as e:
|
|
@@ -126,6 +146,7 @@ class MilvusConnector:
|
|
|
126
146
|
limit: int = 5,
|
|
127
147
|
output_fields: Optional[list[str]] = None,
|
|
128
148
|
metric_type: str = "COSINE",
|
|
149
|
+
filter_expr: Optional[str] = None,
|
|
129
150
|
) -> list[dict]:
|
|
130
151
|
"""
|
|
131
152
|
Perform hybrid search combining vector similarity and attribute filtering.
|
|
@@ -138,8 +159,9 @@ class MilvusConnector:
|
|
|
138
159
|
limit: Maximum number of results
|
|
139
160
|
output_fields: Fields to return in results
|
|
140
161
|
metric_type: Distance metric (COSINE, L2, IP)
|
|
162
|
+
filter_expr: Optional filter expression
|
|
141
163
|
"""
|
|
142
|
-
raise NotImplementedError(
|
|
164
|
+
raise NotImplementedError("This method is not yet supported.")
|
|
143
165
|
|
|
144
166
|
async def create_collection(
|
|
145
167
|
self,
|
|
@@ -239,6 +261,7 @@ class MilvusConnector:
|
|
|
239
261
|
limit: int = 5,
|
|
240
262
|
output_fields: Optional[list[str]] = None,
|
|
241
263
|
metric_type: str = "COSINE",
|
|
264
|
+
filter_expr: Optional[str] = None,
|
|
242
265
|
search_params: Optional[dict[str, Any]] = None,
|
|
243
266
|
) -> list[list[dict]]:
|
|
244
267
|
"""
|
|
@@ -265,6 +288,7 @@ class MilvusConnector:
|
|
|
265
288
|
search_params=search_params,
|
|
266
289
|
limit=limit,
|
|
267
290
|
output_fields=output_fields,
|
|
291
|
+
filter=filter_expr,
|
|
268
292
|
)
|
|
269
293
|
return results
|
|
270
294
|
except Exception as e:
|
|
@@ -442,11 +466,7 @@ class MilvusConnector:
|
|
|
442
466
|
"""
|
|
443
467
|
try:
|
|
444
468
|
# Create a new client with the specified database
|
|
445
|
-
self.client = MilvusClient(
|
|
446
|
-
uri=self.uri,
|
|
447
|
-
token=self.token,
|
|
448
|
-
db_name=db_name
|
|
449
|
-
)
|
|
469
|
+
self.client = MilvusClient(uri=self.uri, token=self.token, db_name=db_name)
|
|
450
470
|
return True
|
|
451
471
|
except Exception as e:
|
|
452
472
|
raise ValueError(f"Failed to switch database: {str(e)}")
|
|
@@ -460,15 +480,8 @@ class MilvusContext:
|
|
|
460
480
|
@asynccontextmanager
|
|
461
481
|
async def server_lifespan(server: FastMCP) -> AsyncIterator[MilvusContext]:
|
|
462
482
|
"""Manage application lifecycle for Milvus connector."""
|
|
463
|
-
config = server.config
|
|
464
|
-
|
|
465
|
-
connector = MilvusConnector(
|
|
466
|
-
uri=config.get("milvus_uri", "http://localhost:19530"),
|
|
467
|
-
token=config.get("milvus_token"),
|
|
468
|
-
db_name=config.get("db_name", "default"),
|
|
469
|
-
)
|
|
470
|
-
|
|
471
483
|
try:
|
|
484
|
+
connector = MilvusConnector.from_env()
|
|
472
485
|
yield MilvusContext(connector)
|
|
473
486
|
finally:
|
|
474
487
|
pass
|
|
@@ -710,26 +723,52 @@ async def milvus_use_database(db_name: str, ctx: Context = None) -> str:
|
|
|
710
723
|
|
|
711
724
|
return f"Switched to database '{db_name}' successfully"
|
|
712
725
|
|
|
726
|
+
|
|
727
|
+
@mcp.tool()
|
|
728
|
+
async def milvus_get_collection_info(collection_name: str, ctx: Context = None) -> str:
|
|
729
|
+
"""
|
|
730
|
+
Lists detailed information about a specific collection
|
|
731
|
+
|
|
732
|
+
Args:
|
|
733
|
+
collection_name: Name of collection to load
|
|
734
|
+
"""
|
|
735
|
+
connector = ctx.request_context.lifespan_context.connector
|
|
736
|
+
collection_info = await connector.get_collection_info(collection_name)
|
|
737
|
+
info_str = json.dumps(collection_info, indent=2)
|
|
738
|
+
return f"Collection information:\n{info_str}"
|
|
739
|
+
|
|
740
|
+
|
|
713
741
|
def parse_arguments():
|
|
742
|
+
"""Parse command line arguments with environment variable fallbacks.
|
|
743
|
+
|
|
744
|
+
Returns:
|
|
745
|
+
argparse.Namespace: The parsed command line arguments
|
|
746
|
+
"""
|
|
714
747
|
parser = argparse.ArgumentParser(description="Milvus MCP Server")
|
|
715
|
-
parser.add_argument("--milvus-uri", type=str,
|
|
716
|
-
|
|
717
|
-
parser.add_argument("--milvus-
|
|
718
|
-
default=None, help="Milvus authentication token")
|
|
719
|
-
parser.add_argument("--milvus-db", type=str,
|
|
720
|
-
default="default", help="Milvus database name")
|
|
748
|
+
parser.add_argument("--milvus-uri", type=str, default=os.environ.get("MILVUS_URI", "http://localhost:19530"), help="Milvus server URI")
|
|
749
|
+
parser.add_argument("--milvus-token", type=str, default=os.environ.get("MILVUS_TOKEN"), help="Milvus authentication token")
|
|
750
|
+
parser.add_argument("--milvus-db", type=str, default=os.environ.get("MILVUS_DB", "default"), help="Milvus database name")
|
|
721
751
|
return parser.parse_args()
|
|
722
752
|
|
|
753
|
+
|
|
754
|
+
def setup_environment(args):
|
|
755
|
+
"""Set environment variables based on parsed arguments.
|
|
756
|
+
Args:
|
|
757
|
+
args (argparse.Namespace): The parsed command line arguments
|
|
758
|
+
"""
|
|
759
|
+
os.environ["MILVUS_URI"] = args.milvus_uri
|
|
760
|
+
if args.milvus_token:
|
|
761
|
+
os.environ["MILVUS_TOKEN"] = args.milvus_token
|
|
762
|
+
os.environ["MILVUS_DB"] = args.milvus_db
|
|
763
|
+
|
|
764
|
+
|
|
723
765
|
def main():
|
|
724
|
-
|
|
766
|
+
"""Main entry point for the Milvus MCP Server."""
|
|
725
767
|
args = parse_arguments()
|
|
726
|
-
|
|
727
|
-
"milvus_uri": os.environ.get("MILVUS_URI", args.milvus_uri),
|
|
728
|
-
"milvus_token": os.environ.get("MILVUS_TOKEN", args.milvus_token),
|
|
729
|
-
"db_name": os.environ.get("MILVUS_DB", args.milvus_db),
|
|
730
|
-
}
|
|
768
|
+
setup_environment(args)
|
|
731
769
|
|
|
732
770
|
mcp.run()
|
|
733
771
|
|
|
772
|
+
|
|
734
773
|
if __name__ == "__main__":
|
|
735
774
|
main()
|