openrag-mcp 0.1.0__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.
@@ -0,0 +1,44 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+ .env
12
+
13
+ # RSA keys for JWT signing
14
+ *.pem
15
+
16
+ .idea/
17
+
18
+ 1001*.pdf
19
+ *.json
20
+ !**/package.json
21
+ !**/package-lock.json
22
+ !**/tsconfig.json
23
+ !flows/*.json
24
+ !src/tui/_assets/flows/*.json
25
+ !src/tui/_assets/flows/components/*.json
26
+ !frontend/*.json
27
+ .DS_Store
28
+
29
+ /config/
30
+
31
+ .docling.pid
32
+
33
+ # OpenSearch data directory
34
+ opensearch-data/
35
+
36
+ node_modules
37
+
38
+ # AI Tools
39
+ /.claude
40
+ /CLAUDE.md
41
+ /.gemini
42
+ /GEMINI.md
43
+ /.bob
44
+ /AGENTS.md
@@ -0,0 +1,257 @@
1
+ Metadata-Version: 2.4
2
+ Name: openrag-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for OpenRAG
5
+ Author: OpenRAG Team
6
+ License: Apache-2.0
7
+ Keywords: ai,llm,mcp,openrag,rag
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: Apache Software License
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
+ Requires-Python: >=3.10
16
+ Requires-Dist: httpx>=0.27.0
17
+ Requires-Dist: mcp>=1.0.0
18
+ Requires-Dist: openrag-sdk>=0.1.0
19
+ Description-Content-Type: text/markdown
20
+
21
+ # OpenRAG MCP Server
22
+
23
+ An [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) server that exposes your OpenRAG knowledge base to AI assistants. It lets MCP-compatible apps like Cursor, Claude Desktop, and IBM Watson Orchestrate use OpenRAG’s RAG capabilities (chat, search, settings) over a standard protocol—no custom integrations per platform.
24
+
25
+ ---
26
+
27
+ ## What is OpenRAG MCP?
28
+
29
+ OpenRAG MCP is a **connectivity layer** between your OpenRAG instance and AI applications. The host app (e.g. Cursor or Claude Desktop) runs the MCP server as a subprocess and talks to it over stdio using JSON-RPC. The server then calls your OpenRAG API with your API key. Your knowledge base stays the single source of truth; all connected apps get the same RAG-backed chat and search.
30
+
31
+ ---
32
+
33
+ ## Quick Start
34
+
35
+ Run the server with **uvx** (no local install required; requires Python 3.10+ and [uv](https://docs.astral.sh/uv/)):
36
+
37
+ ```bash
38
+ uvx openrag-mcp
39
+ ```
40
+
41
+ Set required environment variables first (or pass them via your MCP client config):
42
+
43
+ ```bash
44
+ export OPENRAG_URL="https://your-openrag-instance.com"
45
+ export OPENRAG_API_KEY="orag_your_api_key"
46
+ uvx openrag-mcp
47
+ ```
48
+
49
+ To pin a version:
50
+
51
+ ```bash
52
+ uvx --from openrag-mcp==0.2.1 openrag-mcp
53
+ ```
54
+
55
+ ### Prerequisites
56
+
57
+ - Python 3.10+
58
+ - A running OpenRAG instance
59
+ - An OpenRAG API key (create one in **Settings → API Keys** in OpenRAG)
60
+ - `uv` installed (for `uvx`)
61
+
62
+ ---
63
+
64
+ ## Available Tools
65
+
66
+ These tools are currently exposed by the server:
67
+
68
+ | Tool | Description |
69
+ |:-----|:------------|
70
+ | `openrag_chat` | Send a message and get a RAG-enhanced response. Optional: `chat_id`, `filter_id`, `limit`, `score_threshold`. |
71
+ | `openrag_search` | Semantic search over the knowledge base. Optional: `limit`, `score_threshold`, `filter_id`, `data_sources`, `document_types`. |
72
+ | `openrag_get_settings` | Get current OpenRAG configuration (LLM, embeddings, chunk settings, system prompt, etc.). |
73
+ | `openrag_update_settings` | Update OpenRAG configuration (LLM model, embedding model, chunk size/overlap, system prompt, table structure, OCR, picture descriptions). |
74
+ | `openrag_list_models` | List available language and embedding models for a provider (`openai`, `anthropic`, `ollama`, `watsonx`). |
75
+
76
+ ### Coming later (document tools)
77
+
78
+ Document ingestion and management tools (`openrag_ingest_file`, `openrag_ingest_url`, `openrag_delete_document`, `openrag_get_task_status`, `openrag_wait_for_task`) are implemented but not yet registered in this server; they will be enabled in a future release.
79
+
80
+ ---
81
+
82
+ ## Environment Variables
83
+
84
+ | Variable | Description | Required | Default |
85
+ |:---------|:------------|:--------:|:--------|
86
+ | `OPENRAG_API_KEY` | Your OpenRAG API key | Yes | — |
87
+ | `OPENRAG_URL` | Base URL of your OpenRAG instance | No | `http://localhost:3000` |
88
+
89
+ **MCP HTTP client (optional):**
90
+
91
+ | Variable | Description | Required | Default |
92
+ |:---------|:------------|:--------:|:--------|
93
+ | `OPENRAG_MCP_TIMEOUT` | Request timeout in seconds | No | `60.0` |
94
+ | `OPENRAG_MCP_MAX_CONNECTIONS` | Maximum concurrent connections | No | `100` |
95
+ | `OPENRAG_MCP_MAX_KEEPALIVE_CONNECTIONS` | Maximum keepalive connections | No | `20` |
96
+ | `OPENRAG_MCP_MAX_RETRIES` | Maximum retry attempts for failed requests | No | `3` |
97
+ | `OPENRAG_MCP_FOLLOW_REDIRECTS` | Whether to follow HTTP redirects | No | `true` |
98
+
99
+ These must be set in the environment when the MCP server runs (e.g. in the `env` block of your MCP client config).
100
+
101
+ ---
102
+
103
+ ## How to Use
104
+
105
+ ### Cursor
106
+
107
+ **Config file:** `~/.cursor/mcp.json`
108
+
109
+ ```json
110
+ {
111
+ "mcpServers": {
112
+ "openrag": {
113
+ "command": "uvx",
114
+ "args": ["openrag-mcp"],
115
+ "env": {
116
+ "OPENRAG_URL": "https://your-openrag-instance.com",
117
+ "OPENRAG_API_KEY": "orag_your_api_key_here"
118
+ }
119
+ }
120
+ }
121
+ }
122
+ ```
123
+
124
+ Restart Cursor after changing the config.
125
+
126
+ ### Claude Desktop
127
+
128
+ **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
129
+ **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
130
+
131
+ ```json
132
+ {
133
+ "mcpServers": {
134
+ "openrag": {
135
+ "command": "uvx",
136
+ "args": ["openrag-mcp"],
137
+ "env": {
138
+ "OPENRAG_URL": "https://your-openrag-instance.com",
139
+ "OPENRAG_API_KEY": "orag_your_api_key_here"
140
+ }
141
+ }
142
+ }
143
+ }
144
+ ```
145
+
146
+ Restart Claude Desktop after editing the file.
147
+
148
+ ---
149
+
150
+ ## Run from source (development)
151
+
152
+ To use the **latest MCP code** from the repo (including settings and models tools), run from source. Do **not** install the package if you want local edits to apply.
153
+
154
+ ### Steps
155
+
156
+ | Step | What | Command | Required for |
157
+ |------|------|---------|---------------|
158
+ | 1 | OpenRAG backend | Run your OpenRAG app (e.g. frontend + API) | All tools |
159
+ | 2 | MCP from source | `cd sdks/mcp && uv sync` | All tools; no wheel needed |
160
+ | 3 | (Optional) SDK from repo | `cd sdks/python && uv pip install -e .` | Only if you need unreleased chat/search SDK changes |
161
+
162
+ Settings and models tools (`openrag_get_settings`, `openrag_update_settings`, `openrag_list_models`) use direct HTTP. Chat and search use the OpenRAG SDK (PyPI version is fine unless you need unreleased SDK changes).
163
+
164
+ ### Run the MCP from source
165
+
166
+ ```bash
167
+ cd sdks/mcp
168
+ uv sync
169
+ export OPENRAG_URL="http://localhost:3000"
170
+ export OPENRAG_API_KEY="orag_your_api_key"
171
+ uv run openrag-mcp
172
+ ```
173
+
174
+ ### Cursor: use repo path so it runs your code
175
+
176
+ In `~/.cursor/mcp.json`, set `--directory` to your **actual repo path** so Cursor runs the MCP from source:
177
+
178
+ ```json
179
+ {
180
+ "mcpServers": {
181
+ "openrag": {
182
+ "command": "uv",
183
+ "args": [
184
+ "run",
185
+ "--directory",
186
+ "/path/to/openrag/sdks/mcp",
187
+ "openrag-mcp"
188
+ ],
189
+ "env": {
190
+ "OPENRAG_URL": "https://your-openrag-instance.com",
191
+ "OPENRAG_API_KEY": "orag_your_api_key_here"
192
+ }
193
+ }
194
+ }
195
+ }
196
+ ```
197
+
198
+ Replace `/path/to/openrag` with your real path (e.g. `/Users/edwin.jose/Documents/openrag`).
199
+
200
+ If you previously installed the MCP (`pip install openrag-mcp` or a wheel), uninstall it so Cursor uses the repo:
201
+
202
+ ```bash
203
+ uv pip uninstall openrag-mcp
204
+ ```
205
+
206
+ Then restart Cursor.
207
+
208
+ ---
209
+
210
+ ## Use cases and benefits
211
+
212
+ - **One integration, many apps** – Same MCP server works with Cursor, Claude Desktop, Watson Orchestrate, and any MCP client.
213
+ - **RAG in the loop** – Chat and search are grounded in your OpenRAG knowledge base, with optional filters and scoring.
214
+ - **Agent-friendly** – Agents can call OpenRAG for answers, list models, and read/update settings without custom APIs.
215
+ - **Lightweight** – No extra service to deploy; the host app spawns the server as a subprocess and talks over stdio.
216
+ - **Secure** – Only clients that have your `OPENRAG_API_KEY` (via env) can use the server to access OpenRAG.
217
+
218
+ **Example scenarios:** Query internal docs and runbooks from your IDE; power support bots with your product docs; search and summarize across ingested documents; automate workflows that need RAG (when document tools are enabled).
219
+
220
+ ---
221
+
222
+
223
+ ## Example prompts
224
+
225
+ Once the server is configured, you can ask the AI to:
226
+
227
+ - *"Search my knowledge base for authentication best practices"*
228
+ - *"Chat with OpenRAG about the Q4 roadmap"*
229
+ - *"What are the current OpenRAG settings?"*
230
+ - *"List available models for the openai provider"*
231
+ - *"Update OpenRAG to use chunk size 512"*
232
+
233
+ ---
234
+
235
+ ## Troubleshooting
236
+
237
+ ### "OPENRAG_API_KEY environment variable is required"
238
+
239
+ Set `OPENRAG_API_KEY` in the `env` section of your MCP config (Cursor or Claude Desktop). The server reads it at startup.
240
+
241
+ ### "Connection refused" or network errors
242
+
243
+ 1. Confirm your OpenRAG instance is running and reachable.
244
+ 2. Check `OPENRAG_URL` (no trailing slash; include `https://` if applicable).
245
+ 3. Ensure no firewall or proxy is blocking the client machine from reaching OpenRAG.
246
+
247
+ ### Tools not appearing
248
+
249
+ 1. Restart the host app (Cursor or Claude Desktop) after changing the MCP config.
250
+ 2. Check the app’s MCP/log output for errors (e.g. wrong `command`/`args` or missing `uv`/`uvx`).
251
+ 3. If using "run from source", ensure `args` includes `--directory` and the correct path to `sdks/mcp`.
252
+
253
+ ---
254
+
255
+ ## License
256
+
257
+ Apache 2.0 - See [LICENSE](../../LICENSE) for details.
@@ -0,0 +1,237 @@
1
+ # OpenRAG MCP Server
2
+
3
+ An [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) server that exposes your OpenRAG knowledge base to AI assistants. It lets MCP-compatible apps like Cursor, Claude Desktop, and IBM Watson Orchestrate use OpenRAG’s RAG capabilities (chat, search, settings) over a standard protocol—no custom integrations per platform.
4
+
5
+ ---
6
+
7
+ ## What is OpenRAG MCP?
8
+
9
+ OpenRAG MCP is a **connectivity layer** between your OpenRAG instance and AI applications. The host app (e.g. Cursor or Claude Desktop) runs the MCP server as a subprocess and talks to it over stdio using JSON-RPC. The server then calls your OpenRAG API with your API key. Your knowledge base stays the single source of truth; all connected apps get the same RAG-backed chat and search.
10
+
11
+ ---
12
+
13
+ ## Quick Start
14
+
15
+ Run the server with **uvx** (no local install required; requires Python 3.10+ and [uv](https://docs.astral.sh/uv/)):
16
+
17
+ ```bash
18
+ uvx openrag-mcp
19
+ ```
20
+
21
+ Set required environment variables first (or pass them via your MCP client config):
22
+
23
+ ```bash
24
+ export OPENRAG_URL="https://your-openrag-instance.com"
25
+ export OPENRAG_API_KEY="orag_your_api_key"
26
+ uvx openrag-mcp
27
+ ```
28
+
29
+ To pin a version:
30
+
31
+ ```bash
32
+ uvx --from openrag-mcp==0.2.1 openrag-mcp
33
+ ```
34
+
35
+ ### Prerequisites
36
+
37
+ - Python 3.10+
38
+ - A running OpenRAG instance
39
+ - An OpenRAG API key (create one in **Settings → API Keys** in OpenRAG)
40
+ - `uv` installed (for `uvx`)
41
+
42
+ ---
43
+
44
+ ## Available Tools
45
+
46
+ These tools are currently exposed by the server:
47
+
48
+ | Tool | Description |
49
+ |:-----|:------------|
50
+ | `openrag_chat` | Send a message and get a RAG-enhanced response. Optional: `chat_id`, `filter_id`, `limit`, `score_threshold`. |
51
+ | `openrag_search` | Semantic search over the knowledge base. Optional: `limit`, `score_threshold`, `filter_id`, `data_sources`, `document_types`. |
52
+ | `openrag_get_settings` | Get current OpenRAG configuration (LLM, embeddings, chunk settings, system prompt, etc.). |
53
+ | `openrag_update_settings` | Update OpenRAG configuration (LLM model, embedding model, chunk size/overlap, system prompt, table structure, OCR, picture descriptions). |
54
+ | `openrag_list_models` | List available language and embedding models for a provider (`openai`, `anthropic`, `ollama`, `watsonx`). |
55
+
56
+ ### Coming later (document tools)
57
+
58
+ Document ingestion and management tools (`openrag_ingest_file`, `openrag_ingest_url`, `openrag_delete_document`, `openrag_get_task_status`, `openrag_wait_for_task`) are implemented but not yet registered in this server; they will be enabled in a future release.
59
+
60
+ ---
61
+
62
+ ## Environment Variables
63
+
64
+ | Variable | Description | Required | Default |
65
+ |:---------|:------------|:--------:|:--------|
66
+ | `OPENRAG_API_KEY` | Your OpenRAG API key | Yes | — |
67
+ | `OPENRAG_URL` | Base URL of your OpenRAG instance | No | `http://localhost:3000` |
68
+
69
+ **MCP HTTP client (optional):**
70
+
71
+ | Variable | Description | Required | Default |
72
+ |:---------|:------------|:--------:|:--------|
73
+ | `OPENRAG_MCP_TIMEOUT` | Request timeout in seconds | No | `60.0` |
74
+ | `OPENRAG_MCP_MAX_CONNECTIONS` | Maximum concurrent connections | No | `100` |
75
+ | `OPENRAG_MCP_MAX_KEEPALIVE_CONNECTIONS` | Maximum keepalive connections | No | `20` |
76
+ | `OPENRAG_MCP_MAX_RETRIES` | Maximum retry attempts for failed requests | No | `3` |
77
+ | `OPENRAG_MCP_FOLLOW_REDIRECTS` | Whether to follow HTTP redirects | No | `true` |
78
+
79
+ These must be set in the environment when the MCP server runs (e.g. in the `env` block of your MCP client config).
80
+
81
+ ---
82
+
83
+ ## How to Use
84
+
85
+ ### Cursor
86
+
87
+ **Config file:** `~/.cursor/mcp.json`
88
+
89
+ ```json
90
+ {
91
+ "mcpServers": {
92
+ "openrag": {
93
+ "command": "uvx",
94
+ "args": ["openrag-mcp"],
95
+ "env": {
96
+ "OPENRAG_URL": "https://your-openrag-instance.com",
97
+ "OPENRAG_API_KEY": "orag_your_api_key_here"
98
+ }
99
+ }
100
+ }
101
+ }
102
+ ```
103
+
104
+ Restart Cursor after changing the config.
105
+
106
+ ### Claude Desktop
107
+
108
+ **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
109
+ **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
110
+
111
+ ```json
112
+ {
113
+ "mcpServers": {
114
+ "openrag": {
115
+ "command": "uvx",
116
+ "args": ["openrag-mcp"],
117
+ "env": {
118
+ "OPENRAG_URL": "https://your-openrag-instance.com",
119
+ "OPENRAG_API_KEY": "orag_your_api_key_here"
120
+ }
121
+ }
122
+ }
123
+ }
124
+ ```
125
+
126
+ Restart Claude Desktop after editing the file.
127
+
128
+ ---
129
+
130
+ ## Run from source (development)
131
+
132
+ To use the **latest MCP code** from the repo (including settings and models tools), run from source. Do **not** install the package if you want local edits to apply.
133
+
134
+ ### Steps
135
+
136
+ | Step | What | Command | Required for |
137
+ |------|------|---------|---------------|
138
+ | 1 | OpenRAG backend | Run your OpenRAG app (e.g. frontend + API) | All tools |
139
+ | 2 | MCP from source | `cd sdks/mcp && uv sync` | All tools; no wheel needed |
140
+ | 3 | (Optional) SDK from repo | `cd sdks/python && uv pip install -e .` | Only if you need unreleased chat/search SDK changes |
141
+
142
+ Settings and models tools (`openrag_get_settings`, `openrag_update_settings`, `openrag_list_models`) use direct HTTP. Chat and search use the OpenRAG SDK (PyPI version is fine unless you need unreleased SDK changes).
143
+
144
+ ### Run the MCP from source
145
+
146
+ ```bash
147
+ cd sdks/mcp
148
+ uv sync
149
+ export OPENRAG_URL="http://localhost:3000"
150
+ export OPENRAG_API_KEY="orag_your_api_key"
151
+ uv run openrag-mcp
152
+ ```
153
+
154
+ ### Cursor: use repo path so it runs your code
155
+
156
+ In `~/.cursor/mcp.json`, set `--directory` to your **actual repo path** so Cursor runs the MCP from source:
157
+
158
+ ```json
159
+ {
160
+ "mcpServers": {
161
+ "openrag": {
162
+ "command": "uv",
163
+ "args": [
164
+ "run",
165
+ "--directory",
166
+ "/path/to/openrag/sdks/mcp",
167
+ "openrag-mcp"
168
+ ],
169
+ "env": {
170
+ "OPENRAG_URL": "https://your-openrag-instance.com",
171
+ "OPENRAG_API_KEY": "orag_your_api_key_here"
172
+ }
173
+ }
174
+ }
175
+ }
176
+ ```
177
+
178
+ Replace `/path/to/openrag` with your real path (e.g. `/Users/edwin.jose/Documents/openrag`).
179
+
180
+ If you previously installed the MCP (`pip install openrag-mcp` or a wheel), uninstall it so Cursor uses the repo:
181
+
182
+ ```bash
183
+ uv pip uninstall openrag-mcp
184
+ ```
185
+
186
+ Then restart Cursor.
187
+
188
+ ---
189
+
190
+ ## Use cases and benefits
191
+
192
+ - **One integration, many apps** – Same MCP server works with Cursor, Claude Desktop, Watson Orchestrate, and any MCP client.
193
+ - **RAG in the loop** – Chat and search are grounded in your OpenRAG knowledge base, with optional filters and scoring.
194
+ - **Agent-friendly** – Agents can call OpenRAG for answers, list models, and read/update settings without custom APIs.
195
+ - **Lightweight** – No extra service to deploy; the host app spawns the server as a subprocess and talks over stdio.
196
+ - **Secure** – Only clients that have your `OPENRAG_API_KEY` (via env) can use the server to access OpenRAG.
197
+
198
+ **Example scenarios:** Query internal docs and runbooks from your IDE; power support bots with your product docs; search and summarize across ingested documents; automate workflows that need RAG (when document tools are enabled).
199
+
200
+ ---
201
+
202
+
203
+ ## Example prompts
204
+
205
+ Once the server is configured, you can ask the AI to:
206
+
207
+ - *"Search my knowledge base for authentication best practices"*
208
+ - *"Chat with OpenRAG about the Q4 roadmap"*
209
+ - *"What are the current OpenRAG settings?"*
210
+ - *"List available models for the openai provider"*
211
+ - *"Update OpenRAG to use chunk size 512"*
212
+
213
+ ---
214
+
215
+ ## Troubleshooting
216
+
217
+ ### "OPENRAG_API_KEY environment variable is required"
218
+
219
+ Set `OPENRAG_API_KEY` in the `env` section of your MCP config (Cursor or Claude Desktop). The server reads it at startup.
220
+
221
+ ### "Connection refused" or network errors
222
+
223
+ 1. Confirm your OpenRAG instance is running and reachable.
224
+ 2. Check `OPENRAG_URL` (no trailing slash; include `https://` if applicable).
225
+ 3. Ensure no firewall or proxy is blocking the client machine from reaching OpenRAG.
226
+
227
+ ### Tools not appearing
228
+
229
+ 1. Restart the host app (Cursor or Claude Desktop) after changing the MCP config.
230
+ 2. Check the app’s MCP/log output for errors (e.g. wrong `command`/`args` or missing `uv`/`uvx`).
231
+ 3. If using "run from source", ensure `args` includes `--directory` and the correct path to `sdks/mcp`.
232
+
233
+ ---
234
+
235
+ ## License
236
+
237
+ Apache 2.0 - See [LICENSE](../../LICENSE) for details.
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "openrag-mcp"
3
+ version = "0.1.0"
4
+ description = "MCP server for OpenRAG"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = { text = "Apache-2.0" }
8
+ authors = [{ name = "OpenRAG Team" }]
9
+ keywords = ["mcp", "openrag", "rag", "ai", "llm"]
10
+ classifiers = [
11
+ "Development Status :: 4 - Beta",
12
+ "Intended Audience :: Developers",
13
+ "License :: OSI Approved :: Apache Software License",
14
+ "Programming Language :: Python :: 3",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ ]
19
+ dependencies = [
20
+ "mcp>=1.0.0",
21
+ "httpx>=0.27.0",
22
+ "openrag-sdk>=0.1.0",
23
+ ]
24
+
25
+ [project.scripts]
26
+ openrag-mcp = "openrag_mcp:main"
27
+
28
+ [build-system]
29
+ requires = ["hatchling"]
30
+ build-backend = "hatchling.build"
31
+
32
+ [tool.hatch.build.targets.wheel]
33
+ packages = ["src/openrag_mcp"]
34
+
@@ -0,0 +1,7 @@
1
+ """OpenRAG MCP Server - Expose OpenRAG capabilities via Model Context Protocol."""
2
+
3
+ from openrag_mcp.server import main
4
+
5
+ __version__ = "0.1.0"
6
+ __all__ = ["main"]
7
+
@@ -0,0 +1,7 @@
1
+ """Entry point for running as a module: python -m openrag_mcp"""
2
+
3
+ from openrag_mcp.server import main
4
+
5
+ if __name__ == "__main__":
6
+ main()
7
+
@@ -0,0 +1,111 @@
1
+ """Configuration for OpenRAG MCP server."""
2
+
3
+ import os
4
+
5
+ from openrag_sdk import OpenRAGClient
6
+
7
+
8
+ def _parse_float(key: str, default: float) -> float:
9
+ """Parse a positive float from environment."""
10
+ raw = os.environ.get(key)
11
+ if raw is None:
12
+ return default
13
+ try:
14
+ value = float(raw)
15
+ return value if value > 0 else default
16
+ except ValueError:
17
+ return default
18
+
19
+
20
+ def _parse_int(key: str, default: int) -> int:
21
+ """Parse a positive int from environment."""
22
+ raw = os.environ.get(key)
23
+ if raw is None:
24
+ return default
25
+ try:
26
+ value = int(raw)
27
+ return value if value > 0 else default
28
+ except ValueError:
29
+ return default
30
+
31
+
32
+ def _parse_bool(key: str, default: bool) -> bool:
33
+ """Parse a boolean from environment (true/false, 1/0)."""
34
+ raw = os.environ.get(key)
35
+ if raw is None:
36
+ return default
37
+ return raw.strip().lower() in ("true", "1", "yes")
38
+
39
+
40
+ class Config:
41
+ """Configuration loaded from environment variables."""
42
+
43
+ def __init__(self):
44
+ self.openrag_url = os.environ.get("OPENRAG_URL", "http://localhost:3000")
45
+ self.api_key = os.environ.get("OPENRAG_API_KEY")
46
+
47
+ if not self.api_key:
48
+ raise ValueError(
49
+ "OPENRAG_API_KEY environment variable is required. "
50
+ "Create an API key in OpenRAG Settings > API Keys."
51
+ )
52
+
53
+ # MCP httpx client configuration (OPENRAG_MCP_*)
54
+ self.mcp_timeout = _parse_float("OPENRAG_MCP_TIMEOUT", 60.0)
55
+ self.mcp_max_connections = _parse_int("OPENRAG_MCP_MAX_CONNECTIONS", 100)
56
+ self.mcp_max_keepalive_connections = _parse_int(
57
+ "OPENRAG_MCP_MAX_KEEPALIVE_CONNECTIONS", 20
58
+ )
59
+ self.mcp_max_retries = _parse_int("OPENRAG_MCP_MAX_RETRIES", 3)
60
+ self.mcp_follow_redirects = _parse_bool("OPENRAG_MCP_FOLLOW_REDIRECTS", True)
61
+
62
+ @property
63
+ def headers(self) -> dict[str, str]:
64
+ """Get HTTP headers for API requests."""
65
+ return {
66
+ "X-API-Key": self.api_key,
67
+ "Content-Type": "application/json",
68
+ }
69
+
70
+
71
+ _config: Config | None = None
72
+ _openrag_client: OpenRAGClient | None = None
73
+
74
+
75
+ def get_config() -> Config:
76
+ """Get singleton config instance."""
77
+ global _config
78
+ if _config is None:
79
+ _config = Config()
80
+ return _config
81
+
82
+
83
+ def get_openrag_client() -> OpenRAGClient:
84
+ """Get singleton OpenRAGClient instance."""
85
+ global _openrag_client
86
+ if _openrag_client is None:
87
+ # OpenRAGClient reads OPENRAG_API_KEY and OPENRAG_URL from env
88
+ _openrag_client = OpenRAGClient()
89
+ return _openrag_client
90
+
91
+
92
+ def get_client():
93
+ """Get an httpx async client configured for OpenRAG.
94
+
95
+ This is kept for backward compatibility with operations
96
+ not yet supported by the SDK (list_documents, ingest_url).
97
+ """
98
+ import httpx
99
+
100
+ config = get_config()
101
+ return httpx.AsyncClient(
102
+ base_url=config.openrag_url,
103
+ headers=config.headers,
104
+ timeout=config.mcp_timeout,
105
+ limits=httpx.Limits(
106
+ max_connections=config.mcp_max_connections,
107
+ max_keepalive_connections=config.mcp_max_keepalive_connections,
108
+ ),
109
+ transport=httpx.AsyncHTTPTransport(retries=config.mcp_max_retries),
110
+ follow_redirects=config.mcp_follow_redirects,
111
+ )