You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/client/mcp/rag/README.md
+98-84Lines changed: 98 additions & 84 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ You need:
16
16
- Claude Desktop free
17
17
18
18
## Setup
19
-
With **[`uv`](https://docs.astral.sh/uv/getting-started/installation/)** installed, run the following commands in your current project directory `<PROJECT_DIR>/src/client/mcp/rag/`:
19
+
With **[`uv`](https://docs.astral.sh/uv/getting-started/installation/)** installed, run the following commands in your current project directory `<PROJECT_DIR>`:
In the **AI Optimizer & Toolkit** web interface, after tested a configuration, in `Settings/Client Settings`:
29
+
In the **AI Optimizer & Toolkit** web interface, after tested a configuration, in `Configuration/Settings/Client Settings`:
30
30
31
31

32
32
33
-
* select the checkbox `Include Sensitive Settings`
34
-
* press button `Download Settings` to download configuration in the project directory: `src/client/mcp/rag` as `optimizer_settings.json`.
35
-
*in `<PROJECT_DIR>/src/client/mcp/rag/rag_base_optimizer_config_mcp.py` change filepath with the absolute path of your `optimizer_settings.json` file.
33
+
* select the checkbox `Include Sensitive Settings`.
34
+
* press button `Download LangchainMCP` to download an VectorSearch MCP Agent built on current configuration.
35
+
*unzip the file in a `<PROJECT_DIR>` dir.
36
36
37
37
38
38
## Standalone client
39
-
There is a client that you can run without MCP via commandline to test it:
39
+
There is a client that you can run without MCP via command-line to test it:
40
40
41
41
```bash
42
42
uv run rag_base_optimizer_config.py "[YOUR_QUESTION]"
43
43
```
44
+
In `rag_base_optimizer_config_mcp.py`:
44
45
45
-
## Quick test via MCP "inspector"
46
+
## Claude Desktop setup
46
47
47
-
* Run the inspector:
48
+
Claude Desktop, in free version, not allows to connect remote server. You can overcome, for testing purpose only, with a proxy library called `mcp-remote`. These are the options.
49
+
If you have already installed Node.js v20.17.0+, it should work.
48
50
49
-
```bash
50
-
npx @modelcontextprotocol/inspector uv run rag_base_optimizer_config_mcp.py
51
-
```
51
+
* In **Claude Desktop** application, in `Settings/Developer/Edit Config`, get the `claude_desktop_config.json` to
52
52
53
-
* connect to the port `http://localhost:6274/` with your browser on the link printed, like in the following example:
* setup the `Inspector Proxy Address` with `http://127.0.0.1:6277`
62
-
* test the tool developed.
53
+
* Set **remote sse** execution:
63
54
55
+
add the references to the local MCP server for RAG in the `<PROJECT_DIR>`:
56
+
```json
57
+
{
58
+
"mcpServers": {
59
+
...
60
+
,
61
+
"rag":{
62
+
"command": "npx",
63
+
"args": [
64
+
"mcp-remote",
65
+
"http://127.0.0.1:9090/sse"
66
+
]
67
+
}
68
+
}
69
+
}
70
+
```
64
71
65
-
## Claude Desktop setup
66
72
67
-
* In **Claude Desktop** application, in `Settings/Developer/Edit Config`, get the `claude_desktop_config.json` to add the references to the local MCP server for RAG in the `<PROJECT_DIR>/src/client/mcp/rag/`:
68
-
```json
69
-
{
70
-
"mcpServers": {
71
-
...
72
-
,
73
-
"rag":{
74
-
"command":"bash",
75
-
"args":[
76
-
"-c",
77
-
"source <PROJECT_DIR>/src/client/mcp/rag/.venv/bin/activate && uv run <PROJECT_DIR>/src/client/mcp/rag/rag_base_optimizer_config_mcp.py"
78
-
]
79
-
}
80
-
}
81
-
}
82
-
```
83
73
* In **Claude Desktop** application, in `Settings/General/Claude Settings/Configure`, under `Profile` tab, update fields like:
74
+
84
75
-`Full Name`
85
76
-`What should we call you`
86
77
@@ -94,8 +85,10 @@ Show the rag_tool message as-is, without modification.
94
85
```
95
86
This will impose the usage of `rag_tool` in any case.
96
87
97
-
**NOTICE**: If you prefer, in this agent dashboard or any other, you could setup a message in the conversation with the same content of `Instruction` to enforce the LLM to use the rag tool as well.
98
-
88
+
* Start MCP server in another shell in <PROJECT_DIR> with:
89
+
```bash
90
+
uv run rag_base_optimizer_config_mcp.py
91
+
```
99
92
* Restart **Claude Desktop**.
100
93
101
94
* You will see two warnings on rag_tool configuration: they will disappear and will not cause any issue in activating the tool.
@@ -106,38 +99,45 @@ This will impose the usage of `rag_tool` in any case.
106
99
107
100
If the question is related to the knowledge base content stored in the vector store, you will have an answer based on that information. Otherwise, it will try to answer considering information on which has been trained the LLM o other tools configured in the same Claude Desktop.
108
101
102
+
***Optional**: for a **local stdio** execution, without launching the MCP Server:
103
+
104
+
* Add the references to the local MCP server for RAG in the `<PROJECT_DIR>`:
105
+
```json
106
+
{
107
+
"mcpServers": {
108
+
...
109
+
,
110
+
"rag":{
111
+
"command":"bash",
112
+
"args":[
113
+
"-c",
114
+
"source <PROJECT_DIR>/.venv/bin/activate && uv run <PROJECT_DIR>/rag_base_optimizer_config_mcp.py"
115
+
]
116
+
}
117
+
}
118
+
}
119
+
```
120
+
* Set `Local` with `Remote client` line in `<PROJECT_DIR>/rag_base_optimizer_config_mcp.py`:
109
121
110
-
## Make a remote MCP server the RAG Tool
111
-
112
-
In `rag_base_optimizer_config_mcp.py`:
113
-
114
-
* Update the absolute path of your `optimizer_settings.json`. Example:
Claude Desktop, in free version, not allows to connect remote server. You can overcome, for testing purpose only, with a proxy library called `mcp-remote`. These are the options.
159
-
If you have already installed Node.js v20.17.0+, it should work:
157
+
**Optional:** run with local **stdio** protocol
158
+
* Set as shown before the protolo to run locally in `<PROJECT_DIR>/rag_base_optimizer_config_mcp.py`:
160
159
161
-
* replace `rag` mcpServer, setting in `claude_desktop_config.json`:
162
-
```json
163
-
{
164
-
"mcpServers": {
165
-
"remote": {
166
-
"command": "npx",
167
-
"args": [
168
-
"mcp-remote",
169
-
"http://127.0.0.1:9001/sse"
170
-
]
171
-
}
172
-
}
173
-
}
160
+
```
161
+
* Set `Local` with `Remote client` line:
162
+
163
+
```python
164
+
#mcp = FastMCP("rag", port=9090) #Remote client
165
+
mcp = FastMCP("rag") #Local
166
+
```
167
+
168
+
* Substitute `stdio` with `sse` line of code:
169
+
```python
170
+
mcp.run(transport='stdio')
171
+
#mcp.run(transport='sse')
172
+
```
173
+
174
+
* Run the inspector:
175
+
176
+
```bash
177
+
npx @modelcontextprotocol/inspector uv run rag_base_optimizer_config_mcp.py
178
+
```
179
+
180
+
* connect to the port `http://localhost:6274/` with your browser on the link printed, like in the following example:
* setup the `Inspector Proxy Address` with `http://127.0.0.1:6277`
189
+
* test the tool developed.
190
+
191
+
176
192
177
193
**NOTICE**: If you have any problem running, check the logs if it's related to an old npx/nodejs version used with mcp-remote library. Check with:
178
194
```bash
179
195
nvm -list
180
196
```
181
197
if you have any other versions available than the default. It could happen that Claude Desktop uses the older one. Try to remove any other nvm versions available to force the use the only one avalable, at minimum v20.17.0+.
0 commit comments